$O365Account = 'admin.sanjiv.kumar@abcdef.onmicrosoft.com' $O365pw = ConvertTo-SecureString 'tytyt' -AsPlainText -Force $O365Credentials = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $O365Account, $O365pw Connect-AzureAD -Credential $O365Credentials $Alluser = Get-AzureADUser -All:$True | Select DisplayName,UserPrincipalName, PasswordPolicies, AccountEnabled $Alluser | Export-Csv C:\Temp\user.csv