{"id":3913,"date":"2022-09-07T16:50:20","date_gmt":"2022-09-07T14:50:20","guid":{"rendered":"https:\/\/leeryanrs.com\/?p=3913"},"modified":"2022-09-07T16:50:20","modified_gmt":"2022-09-07T14:50:20","slug":"export-all-azure-active-directory-users","status":"publish","type":"post","link":"https:\/\/leeryanrs.com\/?p=3913","title":{"rendered":"Export all Azure Active Directory Users"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Azure Active Directory has a ton of attributes which hold potentially useful information. I needed to compare what attributes are synced from an On-Premise AD environment to Azure AD. The client was using AD Sync Connector to synchronize their AD.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After collecting all the attributes from a Microsoft knowledgebase article, I added them all to the below script<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Export\/working path, please create it before running script\n$Path = Split-Path -Parent \"C:\\scripts\\*.*\"\n\n# Create variable for the date stamp in log file\n$LogDate = Get-Date -f yyyyMMddhhmm\n\n# Define CSV and log file location variables\n# They have to be on the same location as the script\n$Csvfile = $Path + \"\\AllAzADUsers_$logDate.csv\"\n\n# Get all Azure AD users\n$AzADUsers = Get-AzureADUser -All $true | Select-Object -Property *\n\n# Display progress bar\n$progressCount = 0\nfor ($i = 0; $i -le $AzADUsers.Count; $i++) {\n\n    Write-Progress `\n        -Id 0 `\n        -Activity \"Retrieving User \" `\n        -Status \"$progressCount of $($AzADUsers.Count)\" `\n        -PercentComplete (($progressCount \/ $AzADUsers.Count) * 100)\n\n    $progressCount++\n}\n\n# Create list\n$AzADUsers | Sort-Object GivenName | Select-Object `\n@{Label = \"First name\"; Expression = { $_.GivenName } },\n@{Label = \"Last name\"; Expression = { $_.Surname } },\n@{Label = \"Display name\"; Expression = { $_.DisplayName } },\n@{Label = \"User principal name\"; Expression = { $_.UserPrincipalName } },\n@{Label = \"Street\"; Expression = { $_.StreetAddress } },\n@{Label = \"City\"; Expression = { $_.City } },\n@{Label = \"State\/province\"; Expression = { $_.State } },\n@{Label = \"Zip\/Postal Code\"; Expression = { $_.PostalCode } },\n@{Label = \"Country\/region\"; Expression = { $_.Country } },\n@{Label = \"Job Title\"; Expression = { $_.JobTitle } },\n@{Label = \"Department\"; Expression = { $_.Department } },\n@{Label = \"Company\"; Expression = { $_.CompanyName } },\n@{Label = \"Description\"; Expression = { $_.Description } },\n@{Label = \"Office\"; Expression = { $_.PhysicalDeliveryOfficeName } },\n@{Label = \"Telephone number\"; Expression = { $_.TelephoneNumber } },\n@{Label = \"E-mail\"; Expression = { $_.Mail } },\n@{Label = \"Mobile\"; Expression = { $_.Mobile } },\n@{Label = \"User type\"; Expression = { $_.UserType } },\n@{Label = \"ageGroup\"; Expression = { $_.ageGroup } },\n@{Label = \"alernativeSecurityId\"; Expression = { $_.alernativeSecurityId } },\n@{Label = \"alernativeSecurityIds\"; Expression = { $_.alernativeSecurityIds } },\n@{Label = \"consentProvidedForMinor\"; Expression = { $_.consentProvidedForMinor } },\n@{Label = \"createdDateTime\"; Expression = { $_.createdDateTime } },\n@{Label = \"creationType\"; Expression = { $_.creationType } },\n@{Label = \"dateOfBirth\"; Expression = { $_.dateOfBirth } },\n@{Label = \"facsimileTelephoneNumber\"; Expression = { $_.facsimileTelephoneNumber } },\n@{Label = \"immutableId\"; Expression = { $_.immutableId } },\n@{Label = \"legalAgeGroupClassification\"; Expression = { $_.legalAgeGroupClassification } },\n@{Label = \"legalCountry\"; Expression = { $_.legalCountry } },\n@{Label = \"mailNickName\"; Expression = { $_.mailNickName } },\n@{Label = \"netId\"; Expression = { $_.netId } },\n@{Label = \"objectId\"; Expression = { $_.objectId } },\n@{Label = \"otherMails\"; Expression = { $_.otherMails } },\n@{Label = \"password\"; Expression = { $_.password } },\n@{Label = \"passwordPolicies\"; Expression = { $_.passwordPolicies } },\n@{Label = \"physicalDeliveryOfficeName (officeLocation)\"; Expression = { $_.physicalDeliveryOfficeName } },\n@{Label = \"preferredLanguage\"; Expression = { $_.preferredLanguage } },\n@{Label = \"signInNames\"; Expression = { $_.signInNames } },\n@{Label = \"signInNames.userName\"; Expression = { $_.signInNames.userName } },\n@{Label = \"signInNames.phoneNumber\"; Expression = { $_.signInNames.phoneNumber  } },\n@{Label = \"signInNames.emailAddress\"; Expression = { $_.signInNames.emailAddress  } },\n@{Label = \"strongAuthenticationAlternativePhoneNumber\"; Expression = { $_.strongAuthenticationAlternativePhoneNumber } },\n@{Label = \"strongAuthenticationEmailAddress\"; Expression = { $_.strongAuthenticationEmailAddress } },\n@{Label = \"strongAuthenticationPhoneNumber\"; Expression = { $_.strongAuthenticationPhoneNumber } },\n@{Label = \"usageLocation\"; Expression = { $_.usageLocation } },\n@{Label = \"userType\"; Expression = { $_.userType } },\n@{Label = \"userState\"; Expression = { $_.userState } },\n@{Label = \"userStateChangedOn\"; Expression = { $_.userStateChangedOn } },\n@{Label = \"Dirsync\"; Expression = { if (($_.DirSyncEnabled -eq 'True') ) { 'True' } Else { 'False' } } },\n@{Label = \"Account status\"; Expression = { if (($_.AccountEnabled -eq 'True') ) { 'Enabled' } Else { 'Disabled' } } } |\n\n\n# Export report to CSV file\nExport-Csv -Encoding UTF8 -Path $Csvfile -NoTypeInformation #-Delimiter \";\"<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Azure Active Directory has a ton of attributes which hold potentially useful information. I needed to compare what attributes are synced from an On-Premise AD environment to Azure AD. The client was using AD Sync Connector to synchronize their AD. After collecting all the attributes from a Microsoft knowledgebase article, I added them all to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,13],"tags":[21,23,25,38,43],"class_list":["post-3913","post","type-post","status-publish","format-standard","hentry","category-powershell","category-script","tag-active-directory","tag-ad","tag-azure","tag-powershell","tag-script"],"_links":{"self":[{"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/posts\/3913","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3913"}],"version-history":[{"count":0,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/posts\/3913\/revisions"}],"wp:attachment":[{"href":"https:\/\/leeryanrs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3913"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3913"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3913"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}