Forum Discussion

Chandra318's avatar
Chandra318
Copper Contributor
Jun 21, 2021
Solved

PowerShell script

Hi All,  Good day. I have 100 windows servers in AWS cloud. I want to check a windows service called "xxxxx" (eg.) running or exists. If exists or running, then it should be disabled. Servers list ca...
  • yuzoyox's avatar
    Jun 21, 2021

    Chandra318 

     

    Hi Chandra, 

     

    $password = ConvertTo-SecureString "password_here" -AsPlainText -Force

    $cred = New-Object System.Management.Automation.PSCredential ("username_here", $password )

    Invoke-Command -ComputerName remoteservername -Credential $cred -ScriptBlock {Stop-Service -Name "your_service_name"|Set-Service -Name "your_service_name" -Status stopped -StartupType disabled

     

    You can read your csv and write each line on a $var and change on remoteservername

     

Resources