Hello,
I have a text file with the following move-clustergroup data:
Move-ClusterGroup "SCVMM VM1 Resources" -Node HOST1
Move-ClusterGroup "SCVMM VM2 Resources" -Node HOST1
Move-ClusterGroup "SCVMM VM3 Resources" -Node HOST1
Move-ClusterGroup "SCVMM VM4 Resources" -Node HOST2
Move-ClusterGroup "SCVMM VM5 Resources" -Node HOST2
Move-ClusterGroup "SCVMM VM6 Resources" -Node HOST2
I'd like to split this file into two files by HOST. So file 1 would have:
Move-ClusterGroup "SCVMM VM1 Resources" -Node HOST1
Move-ClusterGroup "SCVMM VM2 Resources" -Node HOST1
Move-ClusterGroup "SCVMM VM3 Resources" -Node HOST1
And file 2 would have:
Move-ClusterGroup "SCVMM VM4 Resources" -Node HOST2
Move-ClusterGroup "SCVMM VM5 Resources" -Node HOST2
Move-ClusterGroup "SCVMM VM6 Resources" -Node HOST2
I have the following script that partly does what I need:
Select-String "HOST1" -path C:\apps\Powershell_Scripts\ClusterGroup_scripts\test.txt -AllMatches -simplematch
The above script will give the following results:
test.txt:1:Move-ClusterGroup "SCVMM VM1 Resources" -Node HOST1
test.txt:2:Move-ClusterGroup "SCVMM VM2 Resources" -Node HOST1
test.txt:3:Move-ClusterGroup "SCVMM VM3 Resources" -Node HOST1
Almost there..I need to show just the exact lines like were in my file and not the name of the file...therefore remove the following "test.txt:1:"
Also, what is the instruction to write this out to a new text file?
Thanks in advance for any advice you can provide.