I have the following script to check for the status of a service on remote machines:<\/p>\n
$computers = get-content D:\\DATA\\computers.txt<\/p>\n
foreach ($computer in $computers) {<\/p>\n
$wuauservstart = get-service -Name “wuauserv” -ComputerName $computer | select starttype
\nwrite-host “The Windows Update Service for $computer is set to $wuauservstart”<\/p>\n
}<\/p>\n
When I run it, the script seems to keep the status found for the first machine and use that for $wuauservstart<\/p>\n
For example:<\/p>\n
\"The Windows Update Service for machine1 is set to manual<\/p>\n
\"The Windows Update Service for machine2 is set to manual<\/p>\n
I know the service for machine2 is set to disabled but it’s not showing correctly.<\/p>","upvoteCount":3,"answerCount":4,"datePublished":"2018-05-29T12:54:45.000Z","author":{"@type":"Person","name":"8195564","url":"https://community.spiceworks.com/u/8195564"},"suggestedAnswer":[{"@type":"Answer","text":"
I have the following script to check for the status of a service on remote machines:<\/p>\n
$computers = get-content D:\\DATA\\computers.txt<\/p>\n
foreach ($computer in $computers) {<\/p>\n
$wuauservstart = get-service -Name “wuauserv” -ComputerName $computer | select starttype
\nwrite-host “The Windows Update Service for $computer is set to $wuauservstart”<\/p>\n
}<\/p>\n
When I run it, the script seems to keep the status found for the first machine and use that for $wuauservstart<\/p>\n
For example:<\/p>\n
\"The Windows Update Service for machine1 is set to manual<\/p>\n
\"The Windows Update Service for machine2 is set to manual<\/p>\n
I know the service for machine2 is set to disabled but it’s not showing correctly.<\/p>","upvoteCount":3,"datePublished":"2018-05-29T12:54:45.000Z","url":"https://community.spiceworks.com/t/check-service-status-on-remote-machines/654053/1","author":{"@type":"Person","name":"8195564","url":"https://community.spiceworks.com/u/8195564"}},{"@type":"Answer","text":"
If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>