Created
March 27, 2019 22:23
-
-
Save AlexFilipin/fb349a0e7c964ecac2310f4769d7d684 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[string]$Path | |
) | |
#Search PrivilegedAccount | |
$Accounts = Get-MVObject -ObjectType Person -Attribute PrivilegedAccount -Value true | |
#Get CS Object | |
$Data = foreach($Account in $Accounts){ | |
$ADMA_CSVMVLink = $Account.CSMVLinks | Where-Object -FilterScript {$PSItem.ManagementAgentName -eq "ADMA"} | |
$ADMA_CSOBject = Get-CSObject -ID $ADMA_CSVMVLink.ConnectorSpaceID -MA $ADMA_CSVMVLink.ManagementAgentName | |
foreach($Key in $ADMA_CSOBject.EscrowedExportDelta.Attributes.Keys){ | |
$Attribute = $ADMA_CSOBject.UnappliedExportHologram.Attributes.$Key | |
$DeltaAttribute = $ADMA_CSOBject.EscrowedExportDelta.Attributes.$Key | |
#PSObject | |
$Output = New-Object PSObject | |
$Output | Add-Member -MemberType NoteProperty -Name "DN" -Value $ADMA_CSOBject.DN | |
$Output | Add-Member -MemberType NoteProperty -Name "Domain" -Value $ADMA_CSOBject.DomainName | |
$Output | Add-Member -MemberType NoteProperty -Name "Name" -Value $Attribute.Name | |
$Output | Add-Member -MemberType NoteProperty -Name "Type" -Value $Attribute.Type | |
$Output | Add-Member -MemberType NoteProperty -Name "Multivalued" -Value $Attribute.Multivalued | |
#region Add | |
if($DeltaAttribute.Operation -eq "Add"){ | |
if($Attribute.Multivalued -eq $false){ | |
$Output | Add-Member -MemberType NoteProperty -Name "Values" -Value $Attribute.Values[0] | |
$Output | Add-Member -MemberType NoteProperty -Name "Operation" -Value "Replace" | |
}else{ | |
$Output | Add-Member -MemberType NoteProperty -Name "Values" -Value ($Attribute.Values -join "|") | |
$Output | Add-Member -MemberType NoteProperty -Name "Operation" -Value "ReplaceMV" | |
} | |
} | |
#endregion | |
#region Update | |
if($DeltaAttribute.Operation -eq "Update"){ | |
if($Attribute.Multivalued -eq $false){ | |
$Output | Add-Member -MemberType NoteProperty -Name "Values" -Value $Attribute.Values[0] | |
$Output | Add-Member -MemberType NoteProperty -Name "Operation" -Value "Replace" | |
}else{ | |
$Output | Add-Member -MemberType NoteProperty -Name "Values" -Value ($Attribute.Values -join "|") | |
$Output | Add-Member -MemberType NoteProperty -Name "Operation" -Value "ReplaceMV" | |
} | |
} | |
#endregion | |
#region Delete | |
if($DeltaAttribute.Operation -eq "Delete"){ | |
$Output | Add-Member -MemberType NoteProperty -Name "Values" -Value $Attribute.Values | |
$Output | Add-Member -MemberType NoteProperty -Name "Operation" -Value "Clear" | |
} | |
#endregion | |
#PSObject | |
$Output | |
} | |
if($ADMA_CSOBject.UnappliedExportHologram.DN -ne $ADMA_CSOBject.DN){ | |
#PSObject | |
$Output = New-Object PSObject | |
$Output | Add-Member -MemberType NoteProperty -Name "DN" -Value $ADMA_CSOBject.DN | |
$Output | Add-Member -MemberType NoteProperty -Name "Domain" -Value $ADMA_CSOBject.DomainName | |
$Output | Add-Member -MemberType NoteProperty -Name "Name" -Value "DN" | |
$Output | Add-Member -MemberType NoteProperty -Name "Type" -Value "String" | |
$Output | Add-Member -MemberType NoteProperty -Name "Multivalued" -Value "False" | |
$Output | Add-Member -MemberType NoteProperty -Name "Values" -Value ($ADMA_CSOBject.UnappliedExportHologram.DN -split ",",2)[1] | |
$Output | Add-Member -MemberType NoteProperty -Name "Operation" -Value "Move" | |
} | |
} | |
#Complete Deletions - check conterspace for pending deletes | |
$Deletes = Get-PendingExportDeletes -MA ADMA | |
foreach($Account in $Deletes){ | |
$Output = New-Object PSObject | |
$Output | Add-Member -MemberType NoteProperty -Name "DN" -Value $Account.DN | |
$Output | Add-Member -MemberType NoteProperty -Name "Domain" -Value $Account.DomainName | |
$Output | Add-Member -MemberType NoteProperty -Name "Operation" -Value "RemoveAccount" | |
$Data += $Output | |
} | |
#Dump to File | |
$Data | Export-Csv -Path $Path -Delimiter ";" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment