Powershell - find computers that a specific us is logged on
say wanted find computer names specific user logged into. however, want @ computers online, not computers in ad. so this, combining get-adcomputer , foreach-object along get-ciminstance
however, error get-ciminstance... see below
$computers = get-adcomputer -filter {(enabled -eq "true") -and (operatingsystem -like "*xp*")} | select-object -expandproperty name $computers | foreach-object { $user = get-ciminstance win32_computersystem -computername $psitem | select-object -expandproperty username $obj = new-object -typename psobject -property @{ "computer" = $psitem "user" = $user } write-output $obj }
error:
get-ciminstance : winrm client cannot process request because server name cannot resolved.
suggestions?
hi shiftbit,
sorry delay.
please try script below , feedback:
$computers = get-adcomputer -filter {(enabled -eq "true") -and (operatingsystem -like "*xp*")} | select-object -expandproperty name $output=@() foreach($psitem in $computers) { $user = get-ciminstance win32_computersystem -computername $psitem | select-object -expandproperty username $obj = new-object -typename psobject -property @{ "computer" = $psitem "user" = $user } $output+=$obj } $output
best regards,
anna
Windows Server > Windows Server General Forum
Comments
Post a Comment