5

can somebody help me to create a powershell script to check a particular service is running in all the machines in active directory.

for example process like ccsvchst is available in all systems. I got the code for how to check in a single machine. but need to get code for all machines in AD.

$ProcessName = "ccsvchst"
if((get-process $ProcessName -ErrorAction SilentlyContinue) -eq $Null)
{ echo "Process is not running" }else{ echo "Process is running" }
0

1 Answer 1

6
$ProcessName = "ccsvchst"
Get-ADComputer -Filter * | ForEach-Object {
    if((get-process $ProcessName -ComputerName $_.CN -ErrorAction SilentlyContinue) -eq $Null)
    { echo "Process is not running on $($_.CN)" }else{ echo "Process is running on $($_.CN)" }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.