Reputation: 109
I have the following script in as a cmd file
FOR /F "usebackq delims=" %%G IN (myservices.txt) DO (
echo "Start service: %%G”
NET START "%%G"
)
How would I translate that into powershell?
My guess would be something like this
FOR /F "usebackq delims=" %%G IN (myservice.txt) DO (
echo "Start service: %%G”
start-service -name "%%G"
)
Upvotes: 0
Views: 155
Reputation: 9056
If gsp_services.txt
contains service name on each line:
get-content gps_services.txt | % {
"Start service: $_”
start-service $_
}
Upvotes: 2