I have to find and remove something like this:
name: myvmname
device: drive
location: clustername
type: windows2003
name: myvmname2
device: drive
location: clustername
type: windows2003
..
...
etc..
...
I know I probably do something like:
Get-Content myfile.txt |foreach-object {$_ -replace "device drive",( "") }
So my question is:
1) Is there a better way to remove the line "device: drive"
2) After it is removed will there be and empty line space between "name and location", if so is there a way to push up location and everything below that?
3)When I run the command I posted above, it does not change the file "myfile.txt, but instead reports to the screen what is changed. How do you change the file also with the changes reported to the screen?
name: myvmname2
<--empty line --- yuk!!!
location: clustername
type: windows2003
more like what I want:
name: myvmname2
location: clustername
type: windows2003