Office 365 Powershell - Export user to csv file
7,557
By default commands like Get-User
and Get-MSOLUser
only give you the first 200 objects. you have -ALL
next to the Get-MSOLUser
command but not next to the GET-USER
cmdlet. try using Get-USER -ALL
Hope This Works,
Mike
Related videos on Youtube
Author by
Yannick Poulin
Updated on September 18, 2022Comments
-
Yannick Poulin over 1 year
I took this script from that post : Office 365 Powershell but when I run it, I receive that error :
WARNING: More results are available. Please specify one of the All or MaxResults parameters.
Where do I need to add the maxresults parameters in order to make the export possible?
$lines = @() foreach($msolUser in (Get-MSOLUser -ALL | where {$_.isLicensed -eq $true})) { $UserInfo = Get-User -identity $msolUser.UserPrincipalName foreach($license in $msolUser.Licenses) { $lines += New-Object PsObject -Property @{ "Nom/Prenom"="$($UserInfo.DisplayName)"; "Societe"="$($UserInfo.Company)"; "AdressePrincipale"="$($UserInfo.UserPrincipalName)"; "Licences"="$($license.AccountSKUid)" } } } $lines | Export-CSV C:\out1.csv -Delimiter ";" -Encoding Unicode
-
Michael Brown almost 7 yearsHi Yannick, how far did you get with this?
-
Yannick Poulin almost 7 yearsIn order to work, you have to open session with azure AD and import session in exchange before running the script. The get-user command is only valid in exchange. out of that, the script work perfectly.
-