Jun 21 2021 11:05 AM
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 can be given input as csv file in the script. Could any one suggest PowerShell script to achieve this?
Jun 21 2021 03:22 PM - edited Jun 21 2021 03:24 PM
Solution
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