locked
Script not working RRS feed

  • Question

  • I need some assistance as I am trying to run a script to disable a service on multiple computers that is not working.

    I ran a script to stop the services required, but then when I try to run a script where all the computer names are listed in a text file, it seems like it runs successfully but when i check the computers, the service is still set to automatic not disabled status. If I run the script and just input a computer name only, it runs fine.

    Here is the script. can you advise if I am doing something wrong.

    This fails

    $computers=Get-Content c:\temp\av.txt

     set-service -inputobject $(get-service -ComputerName $computers -Name SAVService ) -StartupType disabled 

    If I run this below it works

     set-service -inputobject $(get-service -ComputerName dc-itn29ds -Name SAVService ) -StartupType disabled 

    Monday, October 15, 2018 4:01 PM

All replies

  • $computers = Get-Content c:\temp\av.txt
    Get-Service -ComputerName $computers -Name SAVService | 
        Set-Service -StartupType disabled
    If you get errors then there are issues on the remote systems.

    \_(ツ)_/


    Monday, October 15, 2018 4:24 PM