Last active
November 4, 2020 15:34
-
-
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.
This file contains 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
# 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