I am using an array of hash tables that hold server information.
get-adcomputer -Filter "Enabled -eq '$true'" -Property Name,OperatingSystem,Enabled,DistinguishedName,DNSHostname |
Where-Object { ($_.OperatingSystem -like '*Server*') } |
ForEach-Object -Process {
$ServerDetails = [PSCustomObject]@{
FQDN = $_.DNSHostname
Enabled = $_.Enabled
DistinguishedName = $_.DistinguishedName
Online = 'Empty'
PrintServer = 'Empty'
PrintSpooler = 'Empty'
PrintSpoolerStartType = 'Empty'
PrintSpoolerSatus = 'Empty'
PrintSpoolerStartTypeNow = 'Empty'
Resolveable = 'Empty'
WinRMEnabled = 'Empty'
}
#Save to the global array
$EnabledADServers+= $ServerDetails
}
Later in my script I’m starting a bunch of persistent sessions with a subset of the array, running some commands remotely via those sessions as background jobs. I have hundreds of servers to query and get the data from. Doing them one at a time takes a long time vs running them remotely and retrieving the data.
Once that is done I have data sitting on the remote servers that I want to retrieve and put into the array of hash tables I have.
So far I am using the receive-job cmdlet to get the data results, but I’m saving it to a new variable. I would like to get the data and put it into the correct hash table within the array.
Is there a way to retrieve the remote data and populate the array? Can you point me to some online resources that could explain/expand this for me? I still get tripped up thinking like a programmer and often miss an easier way of doing things that PS provides.