Skip to content

Instantly share code, notes, and snippets.

@roberttoups
Last active November 4, 2020 15:34
Show Gist options
  • Save roberttoups/5a7e7684350099cfb9778c4806469b47 to your computer and use it in GitHub Desktop.
Save roberttoups/5a7e7684350099cfb9778c4806469b47 to your computer and use it in GitHub Desktop.
PowerShell snippet to export users to CSV that have reversible encryption enabled on their object.
# Export-ReversibleEncryption.ps1
$TimeStamp = Get-Date -Format 'yyyyMMddHHmmss'
$PropertyList = @('Enabled', 'PasswordLastSet', 'Name', 'GivenName', 'SurName', 'SamAccountName', 'UserPrincipalName', 'DistinguishedName', 'manager')
[System.Array]$ExportData = Get-ADUser -Filter { userAccountControl -band 128 } -Properties $PropertyList
if($ExportData.Count -gt 0) {
$ExportData |
Select-Object -Property $PropertyList |
Export-Csv -Path (Join-Path -Path '.' -ChildPath "$TimeStamp-ReversibleEncryptionAccounts.csv") -NoTypeInformation
}
Write-Host "$($ExportData.Count.ToString('#,##0')) accounts have reversible encryption enabled." -ForegroundColor 'Red'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment