Skip to content

Instantly share code, notes, and snippets.

@HarmJ0y
Created April 18, 2016 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save HarmJ0y/81f7061407cf60f955c99c02afa37923 to your computer and use it in GitHub Desktop.
Save HarmJ0y/81f7061407cf60f955c99c02afa37923 to your computer and use it in GitHub Desktop.
anon.ps1
$GroupData = @{}
$UserData = @{}
$ServerData = @{}
Import-CSV .\DomainGroups.csv | ForEach-Object {
if($GroupData[$_.GroupName]) {
$_.GroupName = $GroupData[$_.GroupName]
}
else {
$guid = ([guid]::NewGuid()).Guid
$GroupData[$_.GroupName] = $guid
$_.GroupName = $guid
}
if($UserData[$_.MemberName]) {
$_.MemberName = $UserData[$_.MemberName]
}
else {
$guid = ([guid]::NewGuid()).Guid
$UserData[$_.MemberName] = $guid
$_.MemberName = $guid
}
$_
} | Export-CSV -NoTypeInformation DomainGroups_anon.csv
Import-CSV .\LocalAdmins.csv | ForEach-Object {
if($ServerData[$_.Server]) {
$_.Server = $ServerData[$_.Server]
}
else {
$guid = ([guid]::NewGuid()).Guid
$ServerData[$_.Server] = $guid
$_.Server = $guid
}
$AccountName = $_.AccountName.split("\")[-1]
if($_.IsGroup) {
if($GroupData[$AccountName]) {
$_.AccountName = $GroupData[$AccountName]
}
else {
$guid = ([guid]::NewGuid()).Guid
$GroupData[$AccountName] = $guid
$_.AccountName = $guid
}
}
else {
if($UserData[$AccountName]) {
$_.AccountName = $UserData[$AccountName]
}
else {
$guid = ([guid]::NewGuid()).Guid
$UserData[$AccountName] = $guid
$_.AccountName = $guid
}
}
$_
} | Export-CSV -NoTypeInformation LocalAdmins_anon.csv
Import-CSV .\UserLogons.csv | ForEach-Object {
if($UserData[$_.User]) {
$_.User = $UserData[$_.User]
}
else {
$guid = ([guid]::NewGuid()).Guid
$UserData[$_.User] = $guid
$_.User = $guid
}
if($ServerData[$_.Computer]) {
$_.Computer = $ServerData[$_.Computer]
}
else {
$guid = ([guid]::NewGuid()).Guid
$ServerData[$_.Computer] = $guid
$_.Computer = $guid
}
$_
} | Export-CSV -NoTypeInformation UserLogons_anon.csv
$GroupData.GetEnumerator() | sort-object Name | Export-Csv -NoTypeInformation group_lookup.csv
$UserData.GetEnumerator() | sort-object Name | Export-Csv -NoTypeInformation user_lookup.csv
$ServerData.GetEnumerator() | sort-object Name | Export-Csv -NoTypeInformation server_lookup.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment