powershell - Compare-Object remove parts of the resault -


i have code

compare-object $str $str1 | foreach inputobject | ft -auto | out-file "$resault" -width 5000 

and somthing looks this

\\server\path\path\config.current.running.rt-1.ci.cou.txt 

and want part of = rt-1.ci.cou in $relault .txt file

#set variable, path, full string you're looking @ [string]$path = '\\server\path\path\config.current.running.rt-1.ci.cou.txt'   #remove directory we're left filename [string]$filename = (split-path -path $path -leaf) #$filename: config.current.running.rt-1.ci.cou.txt  #use regular expressions capture text appears after 3rd period (`.`) , before last period. $filename -replace '^[^.]*\.[^.]*\.[^.]*\.(.*)\.[^.]*$', '$1' #output: rt-1.ci.cou 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -