SOLVED

PowerShell command to export user's manager name

%3CLINGO-SUB%20id%3D%22lingo-sub-1020360%22%20slang%3D%22en-US%22%3EPowerShell%20command%20to%20export%20user's%20manager%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1020360%22%20slang%3D%22en-US%22%3E%3CP%3EDear%20all%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20like%20to%20know%20what%20is%20the%20powershell%20command%20to%20get%20this%20information%20%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%3E%3CP%3EFirst%20Name%3C%2FP%3E%3C%2FTD%3E%3CTD%3E%3CP%3ELast%20Name%3C%2FP%3E%3C%2FTD%3E%3CTD%3E%3CP%3EEmail%20address%3C%2FP%3E%3C%2FTD%3E%3CTD%3E%3CP%3EJobTitle%3C%2FP%3E%3C%2FTD%3E%3CTD%3E%3CP%3EManager%20report%20Name%3C%2FP%3E%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FTD%3E%3CTD%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FTD%3E%3CTD%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FTD%3E%3CTD%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FTD%3E%3CTD%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20is%20one%20week%20that%20I%20am%20struggling%20with%20this%20command%20and%20I%20do%20not%20succeed.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20in%20advance%20for%20your%20advice.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGianni%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1027625%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20command%20to%20export%20user's%20manager%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1027625%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F463212%22%20target%3D%22_blank%22%3E%40Gianni88%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%3CSPAN%3Ein%20which%20context%20are%20you%20working%3F%20SharePoint%20online%3F%20Azure%20Active%20Directory%3F%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1028174%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20command%20to%20export%20user's%20manager%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1028174%22%20slang%3D%22en-US%22%3EHi%20Federico%2C%3CBR%20%2F%3E%3CBR%20%2F%3EThank%20you%20for%20your%20reply.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20do%20have%20an%20Active%20Directory%20on%20permise%20synchronized%20to%20Azure.%20I%20hope%20it%20can%20helps%20you.%3CBR%20%2F%3E%3CBR%20%2F%3EGianni%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1028294%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20command%20to%20export%20user's%20manager%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1028294%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F463212%22%20target%3D%22_blank%22%3E%40Gianni88%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eyou%20can%20try%20using%26nbsp%3BAzure%20Active%20Directory%20PowerShell%20for%20Graph.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3Efirst%20of%20all%2C%20install%20it%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fazure%2Factive-directory%2Finstall-adv2%3Fview%3Dazureadps-2.0%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Efollowing%3C%2FA%3E%20this%20guide%20(%20Install-Module%20AzureAD%20)%3C%2FLI%3E%3CLI%3EConnect%20to%20Azure%20AD%20using%3C%2FLI%3E%3C%2FUL%3E%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3E%24AzureAdCred%20%3D%20Get-Credential%0AConnect-AzureAD%20-Credential%20%24AzureAdCred%3C%2FCODE%3E%3C%2FPRE%3E%3CUL%3E%3CLI%3EThen%20you%20can%20use%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fazuread%2Fget-azureaduser%3Fview%3Dazureadps-2.0%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%3CEM%3EGet-AzureADUser%3C%2FEM%3E%3C%2FA%3E%20command.%20%C3%B9%3C%2FLI%3E%3C%2FUL%3E%3CP%3EThe%20result%20could%20be%20something%20like%20this%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3EConnect-AzureAD%20-Credential%20%24AzureAdCred%0A%0A%24output%20%3D%20%40()%0A%0A%24users%20%3D%20Get-AzureADUser%20-All%20%24true%0A%0Aforeach%20(%24user%20in%20%24users)%20%7B%0A%20%20%20%20%24manager%20%3D%20Get-AzureADUserManager%20-ObjectId%20%24user.ObjectId%0A%0A%20%20%20%20%24data%20%3D%20New-Object%20-TypeName%20psobject%0A%0A%20%20%20%20%24data%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20Name%20-Value%20%24user.GivenName%0A%20%20%20%20%24data%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20Surname%20-Value%20%24user.Surname%0A%20%24data%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20Mail%20-Value%20%24user.Mail%0A%20%20%20%20%24data%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20JobTitle%20-Value%20%24user.JobTitle%0A%20%20%20%20%24data%20%7C%20Add-Member%20-MemberType%20NoteProperty%20-Name%20Manager%20-Value%20%24manager.DisplayName%20%0A%0A%20%20%20%20%24output%20%2B%3D%20%24data%0A%0A%7D%0A%0A%24output%20%7C%20Format-Table%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3BSave%20it%20in%20a%20.ps1%20file%20and%20try%20it%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3CP%3EI%20just%20follow%20%3CA%20href%3D%22https%3A%2F%2Fstackoverflow.com%2Fa%2F48778134%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ethis%3C%2FA%3E%20approach.%3C%2FP%3E%3CP%3ECheers%2C%3C%2FP%3E%3CP%3EFederico%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1040357%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20command%20to%20export%20user's%20manager%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1040357%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F138334%22%20target%3D%22_blank%22%3E%40Federico%20Porceddu%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20to%20connect%20to%26nbsp%3B%3CSPAN%3EAzure%20Active%20Directory%20PowerShell%20for%20Graph.%20but%20I%20am%20not%20able%20to%20get%20in.%20Maybe%20is%20because%20we%20use%20in%20our%20company%20MFA%20security.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EAre%20there%20any%20others%20commands%20%3F%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThanks.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EGianni%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1040649%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20command%20to%20export%20user's%20manager%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1040649%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F463212%22%20target%3D%22_blank%22%3E%40Gianni88%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ewhat%20do%20you%20mean%20with%20%22%3CSPAN%3Ebut%20I%20am%20not%20able%20to%20get%20in%22%20%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EAny%20errors%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ECheers%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EFederico%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1042322%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20command%20to%20export%20user's%20manager%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1042322%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F463212%22%20target%3D%22_blank%22%3E%40Gianni88%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3Eok%20it's%20easy%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20need%20to%20use%20just%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3EConnect-AzureAD%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3Einstead%20of%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3E%24AzureAdCred%20%3D%20Get-Credential%0AConnect-AzureAD%20-Credential%20%24AzureAdCred%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethe%20second%20part%20of%20the%20script%20it's%20the%20same%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3CP%3ECheers%2C%3C%2FP%3E%3CP%3EFederico%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1043573%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20command%20to%20export%20user's%20manager%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1043573%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Federico%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%20step%20by%20step%20we%20move%20forward%2C%20I%20am%20in%20now%20%3A)%3C%2Fimg%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20I%20run%20the%20ps1%20file%2C%20it%20does%20not%20display%20anything%20(look%20at%20the%20attachment).%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20I%20am%20doing%20wrong%20%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F159720i744484D32D8D8686%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22result1.jpg%22%20title%3D%22result1.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1043642%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20command%20to%20export%20user's%20manager%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1043642%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F463212%22%20target%3D%22_blank%22%3E%40Gianni88%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3Etry%20to%20run%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3E%26gt%3B%20%24users%20%3D%20Get-AzureADUser%20-All%20%24true%0A%26gt%3B%20%24users%0A%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3Eafter%20connect%20%3A)%3C%2Fimg%3E%3CBR%20%2F%3EAre%20there%20users%20in%20%24users%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%2C%3C%2FP%3E%3CP%3EFederico%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1043709%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20command%20to%20export%20user's%20manager%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1043709%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F138334%22%20target%3D%22_blank%22%3E%40Federico%20Porceddu%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%20Better%20and%20better%20now.%20However%2C%20I%20do%20not%20have%20the%20Manager%20name%20(see%20below)%20%3A%3C%2FP%3E%3CP%3EIt%20is%20possible%20to%20extract%20into%20a%20csv%20file%20%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGianni%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F159726i8B11BF08EDA7CF3C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22result2.jpg%22%20title%3D%22result2.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1043717%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20command%20to%20export%20user's%20manager%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1043717%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F463212%22%20target%3D%22_blank%22%3E%40Gianni88%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eit%20is%20normal%20you%20can't%20find%20the%20Manager%20field.%3C%2FP%3E%3CP%3EThe%20%3CEM%3Eforeach%3C%2FEM%3E%20make%20the%20work%20for%20you%2C%20expanding%20manager%20property%26nbsp%3B%3A)%3C%2Fimg%3E%3C%2FP%3E%3CP%3EPlease%2C%20debug%20your%20scripts%20in%20ISE%20or%20using%20output%20messages%20%3A)%3C%2Fimg%3E%3CBR%20%2F%3ECheers%2C%3C%2FP%3E%3CP%3EFederico%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1042139%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20command%20to%20export%20user's%20manager%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1042139%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Federico%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20we%20use%20MFA%20(Multa%20Factor%20Authentification)%2C%20I%20am%20not%20able%20to%20get%20into%20Powershell.%20I%20tried%20to%20follow%20this%20link%20(without%20success)%20%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fexchange%2Foffice-365-scc%2Fconnect-to-scc-powershell%2Fmfa-connect-to-scc-powershell%3Fview%3Dexchange-ps%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fexchange%2Foffice-365-scc%2Fconnect-to-scc-powershell%2Fmfa-connect-to-scc-powershell%3Fview%3Dexchange-ps%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20you%20know%20which%20command%20I%20need%20to%20run%20to%20connect%20to%20Powershell%20Azure%20(with%20MFA)%20%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGianni%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1043791%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20command%20to%20export%20user's%20manager%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1043791%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F138334%22%20target%3D%22_blank%22%3E%40Federico%20Porceddu%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20Federico%20for%20your%20help%20!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1043793%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20command%20to%20export%20user's%20manager%20name%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1043793%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F138334%22%20target%3D%22_blank%22%3E%40Federico%20Porceddu%3C%2FA%3E%26nbsp%3B%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFound%20this%20powershell%20command%20also%2C%20it%20can%20help%20%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGet-ADUser%20-Filter%20*%20-SearchBase%20'OU%3Dxxxx%2COU%3Dxxxxxx%2CDC%3Dxxx'%20-Properties%20Manager%2C%20Title%20%7C%3CBR%20%2F%3ESelect-Object%20-Property%20Name%2C%20Title%2C%20%40%7Blabel%3D'Manager'%3Bexpression%3D%7B%24_.manager%20-replace%20'%5ECN%3D%7C%2C.*%24'%7D%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20works%20perfectly%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Dear all,

 

I would like to know what is the powershell command to get this information : 

 

First Name

Last Name

Email address

JobTitle

Manager report Name

 

 

 

 

 

 

It is one week that I am struggling with this command and I do not succeed. 

 

Thank you in advance for your advice.

 

Regards.

 

Gianni

13 Replies

Hi @Gianni88 ,

in which context are you working? SharePoint online? Azure Active Directory?

Hi Federico,

Thank you for your reply.

I do have an Active Directory on permise synchronized to Azure. I hope it can helps you.

Gianni

Hi @Gianni88 

you can try using Azure Active Directory PowerShell for Graph.

 

  • first of all, install it following this guide ( Install-Module AzureAD )
  • Connect to Azure AD using
$AzureAdCred = Get-Credential
Connect-AzureAD -Credential $AzureAdCred

The result could be something like this 

Connect-AzureAD -Credential $AzureAdCred

$output = @()

$users = Get-AzureADUser -All $true

foreach ($user in $users) {
    $manager = Get-AzureADUserManager -ObjectId $user.ObjectId

    $data = New-Object -TypeName psobject

    $data | Add-Member -MemberType NoteProperty -Name Name -Value $user.GivenName
    $data | Add-Member -MemberType NoteProperty -Name Surname -Value $user.Surname
	$data | Add-Member -MemberType NoteProperty -Name Mail -Value $user.Mail
    $data | Add-Member -MemberType NoteProperty -Name JobTitle -Value $user.JobTitle
    $data | Add-Member -MemberType NoteProperty -Name Manager -Value $manager.DisplayName 

    $output += $data

}

$output | Format-Table

 Save it in a .ps1 file and try it :)

I just follow this approach.

Cheers,

Federico

@Federico Porceddu 

 

I tried to connect to Azure Active Directory PowerShell for Graph. but I am not able to get in. Maybe is because we use in our company MFA security.

 

Are there any others commands ?

 

Thanks.

 

Gianni

Hi @Gianni88 

what do you mean with "but I am not able to get in" ?

Any errors?

Cheers,

Federico 

Hi Federico,

 

As we use MFA (Multa Factor Authentification), I am not able to get into Powershell. I tried to follow this link (without success) : https://docs.microsoft.com/en-us/powershell/exchange/office-365-scc/connect-to-scc-powershell/mfa-co... 

 

Do you know which command I need to run to connect to Powershell Azure (with MFA) ? 

 

Thanks.

 

Gianni

Hi @Gianni88 ,

ok it's easy :)

 

You need to use just

Connect-AzureAD

instead of

$AzureAdCred = Get-Credential
Connect-AzureAD -Credential $AzureAdCred

 

the second part of the script it's the same :)

Cheers,

Federico

Hi Federico,

 

Thanks, step by step we move forward, I am in now :) 

 

When I run the ps1 file, it does not display anything (look at the attachment). 

 

What I am doing wrong ? 

 

Thanks.result1.jpg

Hi @Gianni88 ,

try to run 

> $users = Get-AzureADUser -All $true
> $users

after connect :)
Are there users in $users?

 

Cheers,

Federico

@Federico Porceddu 

 

Thanks, Better and better now. However, I do not have the Manager name (see below) :

It is possible to extract into a csv file ? 

 

Thanks.

 

Gianni

 

result2.jpg

best response confirmed by Gianni88 (Occasional Contributor)
Solution

Hi @Gianni88 

it is normal you can't find the Manager field.

The foreach make the work for you, expanding manager property :)

Please, debug your scripts in ISE or using output messages :)
Cheers,

Federico

@Federico Porceddu 

 

Thanks Federico for your help !

@Federico Porceddu :

 

Found this powershell command also, it can help : 

 

Get-ADUser -Filter * -SearchBase 'OU=xxxx,OU=xxxxxx,DC=xxx' -Properties Manager, Title |
Select-Object -Property Name, Title, @{label='Manager';expression={$_.manager -replace '^CN=|,.*$'}}

 

It works perfectly