Im trying to use the invoke-expression in powershell to call a script on an external Machine. I am reading in servers,service,remote script from a servers.txt file. Then calling the script on the external server is my second operation in my main script. I am looking to be able to use a variable to hold the name/path of the script for execution and then give an argument or start or stop. then when it is done i want to write this out to a log file. The code I have so far is incomplete. I also added a copy of my server.txt which will be used with a list of multiple servers.
Headers are computername,operation,ser
vice in this case I need to key on computername and Service (service will be a service script path. I am not sure if I need to use PSremoting or if I can do this with WMI?
elseif($computer.service -eq "script")
$service = [IO.File]::ReadAllText(".\
Invoke-Expression $operation -Command
Write-Output "$($computer.service) is ""$state"" on $($computer.name)" | Out-File C:\scripts\scriptlog.txt -append