Skip to content

Instantly share code, notes, and snippets.

@HarmJ0y
Last active Jul 16, 2018
Embed
What would you like to do?
user_workstation_mapping.ps1
Get-DomainUser -Properties samaccountname | % {
$a=(Get-DomainComputer "*$($_.samaccountname)*" -Properties dnshostname | `
select -expand dnshostname) -join '|';
if($a){[pscustomobject]@{'UserName'=$_.samaccountname;'ComputerName'=$a}}
| Export-Csv -NoTypeInformation user_workstations.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment