I tried this code:
$DCs = [DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() | Select-Object -ExpandProperty Sites | Select-Object -ExpandProperty Servers | Select-Object -ExpandProperty Name Invoke-Command -ComputerName $DCs { Get-Service | Select-Object -Property Name,Status,StartType | Where-Object {$_.Status -eq "Stopped" -and $_.StartType -eq "Automatic"} | Export-Csv -Path C:\Temp\AllDCs_RemoteRegistry.csv -NoTypeInformation }
…but nothing in csv.
Alternatively, how can I get a specific Service status running on all DCs in that variable?
Probably something like:
Invoke-Command -ComputerName $DCs { Get-Service | Select-Object -Property Name,Status,StartType | Where-Object {$_.Name -eq "RemoteRegistry"} | Export-Csv -Path C:\Temp\AllDCs_SingleService.csv -NoTypeInformation }
…but not until I can get the first part working.