These are the below services I wanted to check:
Code: Select all
Status Name DisplayName
------ ---- -----------
Running DFS DFS Namespace
Running DFSR DFS Replication
Running DNS DNS Server
Running EventSystem COM+ Event System
Running IsmServ Intersite Messaging
Running KDC Kerberos Key Distribution Center
Running LANMANServer Server
Running LANMANWorkstation Workstation
Running Netlogon NETLOGON
Running NTDS Active Directory Domain Services
Running RPCSs Remote Procedure Call (RPC)
Running SAMSs Security Accounts Manager
Running W32Time Windows Time
The script I have so far:
Code: Select all
$ServiceList = @(
'DFS'
'DFSR'
'DNS'
'EventSystem'
'IsmServ'
'KDC'
'LANMANServer'
'LANMANWorkstation'
'NETLOGON'
'NTDS'
'RPCSs'
'SAMSs'
'W32Time'
)
$input = Get-ADDomainController -Filter * | Select-Object -ExpandProperty HostName
$input | ForEach-Object {
$Servers = ($_ -split '\.')[0]
$Servers | ForEach-Object `
{
$Server = $_
Get-Service -ServiceName $ServiceToCheck -ComputerName $Server)
{
$services | Select-Object -ExpandProperty ServicesDependedOn | Select-Object StartType, Status, Name, DisplayName, Machinename, @{ N = 'Service Dependency'; E = { (Get-Service -Name $_.ServicesDependedOn -ComputerName $Server | ForEach-Object { "$($_.Name): $($_.Status)" }) -join '; ' } }
} | Out-GridView
Also not showing at all (blank) instead of service1: running; serviceN:stopped...@{ N = 'Service Dependency'; E = { (Get-Service -Name $_.ServicesDependedOn -ComputerName $Server | ForEach-Object { "$($_.Name): $($_.Status)" }) -join '; ' } }
Thank you in advance.