asked on
ASKER
query user /server:$SERVER
but for all domain members at once without me having to give up the names of the domain members
$threadLimit = 50
Get-ADComputer -Filter { Enabled -eq $true } | ForEach-Object {
while ((Get-Job -State Running | Measure-Object).Count -ge $threadLimit) {
Start-Sleep -Seconds 5
}
$null = Start-Job -ArgumentList $_.Name -ScriptBlock {
Get-CimInstance Win32_ComputerSystem -ComputerName $args[0] -Property Name, UserName
}
}
Get-Job | Wait-Job | Receive-Job | Select-Object Name, UserName
# Tidy up
Get-Job | Remove-Job
ASKER
WinRM cannot process the request. The following error occurred while using Kerberos authentication: Cannot find the computer <COMPUTERNAME>. Verify that the computer exists on the network and that the name provided is spelled correct
ly.
$threadLimit = 50
Get-ADComputer -Filter { Enabled -eq $true } | ForEach-Object {
while ((Get-Job -State Running | Measure-Object).Count -ge $threadLimit) {
Start-Sleep -Seconds 5
}
$null = Start-Job -ArgumentList $_.Name -ScriptBlock {
try {
Get-CimInstance Win32_ComputerSystem -ComputerName $args[0] -Property Name, UserName -ErrorAction Stop |
Add-Member State 'OK' -PassThru
} catch {
[PSCustomObject]@{
Name = $_.Name
UserName = ''
State = 'Failed ({0})' -f $_.Exception.Message.Trim()
}
}
}
}
# Variable assignment to show different output options
$report = Get-Job | Wait-Job | Receive-Job | Select-Object Name, UserName
# Tidy up
Get-Job | Remove-Job
# GridView
$report | Out-GridView
# File
$report | Export-Csv ComputersAndUsers.csv -NoTypeInformation
ASKER
ASKER
ASKER
ASKER
ASKER
Active Directory (AD) is a Microsoft brand for identity-related capabilities. In the on-premises world, Windows Server AD provides a set of identity capabilities and services, and is hugely popular (88% of Fortune 1000 and 95% of enterprises use AD). This topic includes all things Active Directory including DNS, Group Policy, DFS, troubleshooting, ADFS, and all other topics under the Microsoft AD and identity umbrella.
TRUSTED BY