Nov 20 2019 06:11 AM
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
Nov 22 2019 05:04 PM
Hi @Gianni88 ,
in which context are you working? SharePoint online? Azure Active Directory?
Nov 23 2019 01:11 AM
Nov 23 2019 03:59 AM
Hi @Gianni88
you can try using Azure Active Directory PowerShell for Graph.
$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
Nov 30 2019 08:40 AM
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
Nov 30 2019 12:52 PM
Dec 02 2019 05:44 AM
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
Dec 02 2019 07:41 AM
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
Dec 03 2019 12:54 AM
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.
Dec 03 2019 01:26 AM
Hi @Gianni88 ,
try to run
> $users = Get-AzureADUser -All $true
> $users
after connect 🙂
Are there users in $users?
Cheers,
Federico
Dec 03 2019 02:14 AM
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
Dec 03 2019 02:26 AM - edited Dec 03 2019 02:27 AM
SolutionHi @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
Dec 03 2019 03:39 AM
Dec 03 2019 03:41 AM
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
Dec 03 2019 02:26 AM - edited Dec 03 2019 02:27 AM
SolutionHi @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