I am trying to write a powershell script that will take in a text file (or xml file or whatever I want ti to be) with a list of servername and some service names on that server to stop. I can get powershell to read in a line from a text file, but I can’t figure out how to get powershell to import the data into seperate variable for me to pass on to other functions. if this were arguemnts it seems trivial but there must be a simple way to do that rather than me using a regex on each line.
Share
Consider the XML below:
You could process the
$xmlvariable like so:For a kill script on remote machines, you could use the Invoke-Script cmdlet (requires PSRemoting be enabled), or PsExec, or WMI, whichever you’re most comfortable with. The
$serverand$processvariables will be required to execute the kill against the correct process on the correct server.