Last active
February 22, 2018 08:29
-
-
Save darzo27/6ff36378626491810591f3d166eef785 to your computer and use it in GitHub Desktop.
PS Scripts - https://community.spiceworks.com/topic/1094308-powershell-for-single-service-status-of-all-ad-computers-in-csv-result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-Process | Group-Object ProcessName | ForEach-Object { | |
$_ | Select-Object -ExpandProperty Group | Select-Object -First 5 | |
} | |
__________________________________________ | |
Get-ADComputer -Filter * | foreach-object { | |
$Computer = $_.Name | |
$Running = Get-Service -Name "Bonjour Service" -ComputerName $Computer | |
If( $Running.Status -eq "Running" ) { | |
$ServiceStatus = "Running" | |
Write-Host "$Computer `t `t $ServiceStatus" -ForeGroundColor Green | |
}ElseIf ( $Running.Status -eq "Stopped" ) { | |
$ServiceStatus = "Not Running" | |
Write-Host "$Computer `t `t `t $ServiceStatus" -ForeGroundColor Yellow | |
}Else { | |
$ServiceStatus = "Not Installed" | |
Write-Host "$Computer `t `t $ServiceStatus" -ForeGroundColor Red | |
} | |
} | |
========================================================================================= | |
Output to csv | |
Get-ADComputer -Filter * | foreach-object { | |
$Computer = $_.Name | |
If(Test-Connection -Cn $Computer -BufferSize 16 -Count 1 -ea 0 -quiet){ | |
$Running = Get-Service -Name "Bonjour Service" -ComputerName $Computer | |
If( $Running.Status -eq "Running" ) { | |
$ServiceStatus = "Running" | |
}ElseIf ( $Running.Status -eq "Stopped" ) { | |
$ServiceStatus = "Not Running" | |
}Else { | |
$ServiceStatus = "Not Installed" | |
} | |
}Else{ | |
$ServiceStatus = "Machine Offline" | |
} | |
$obj = New-Object PSCustomObject -Property @{ | |
"ComputerName" = $Computer | |
"Service Status" = $ServiceStatus | |
} | |
$obj | Export-Csv C:\bonjour.csv -Append -NoTypeInformation | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment