Forum Discussion
Manflo1603
Nov 04, 2022Brass Contributor
script shared mailbox with license
I am contacting you because I need your help on a script I would like to be able to use a script to make it easier for me to export users who have a shared mailbox with a specific license (I would l...
- Nov 20, 2022
No problem at all! Manflo1603
Feel free to mark my response and an accepted solution if you feel that I helped out in solving your issues 🙂
If there is anything else I can help with just let me know! Have a great weekend
Kind regards
Oliwer
Manflo1603
Nov 08, 2022Brass Contributor
Rebonjour, quand je fais le script je n'ai pas de réponse sortie
Par contre si je lance le miens j'ai bien une sortie de réponse
oliwer_sundgren
Nov 08, 2022Steel Contributor
Hello again Manflo1603
Sorry I misstyped my first reply.
Change the IF statement to this and it should work
if ($infoUser.AssignedLicenses.Count -gt 0 -And $InfoUser.AssignedLicenses.SkuID -Like "cbdc14ab-d96c-4c30-b9f4-6ada7cdc1d46")
- Manflo1603Nov 09, 2022Brass Contributor
hello how are you ?
super ça fonctionne nickel par contre j'ai deux autres questions 🙂
comment avez vous trouver le SKU de la licence j'aimerais comprendre pour rechercher cette information la ?
et comment puis je le sortir en tableau csv ?
merci d'avance
- oliwer_sundgrenNov 13, 2022Steel Contributor
Hello again! Manflo1603
Great that it works for you 😄
On this site you can find all the licenses and their SKU numbers (Also called GUID in the list)
Product names and service plan identifiers for licensing - Azure AD - Microsoft Entra | Microsoft LearnAnd for the second question if you want to export this output to a CSV file you could add a PSCustomObject to structure your output in a table format and then export it to a CSV file.
I've copied your script below and added some modifications to it so you will get a PsCustomObject and then export that, all you need to to is change the variable called $FilePath to the filepath where you want to store the CSV file
Connect-ExchangeOnline Connect-AzureAD $FilePath = "C:\Users\Oliwer\Folder\Export.csv" $UPNSharedMailbox = Get-Mailbox -recipientTypeDetails SharedMailbox | Select userprincipalname $CSVReport = @() foreach ($UPN in $UPNSharedMailbox) { $SharedMailbox = $UPN.userprincipalname $Infouser = Get-AzureADUser -ObjectId $SharedMailbox if ($infoUser.AssignedLicenses.Count -gt 0 -And $InfoUser.AssignedLicenses.SkuID -Like "cbdc14ab-d96c-4c30-b9f4-6ada7cdc1d46") { $CSVReport += [pscustomobject][ordered]@{ User = $SharedMailbox IsLicensed = "Yes" } } } $CSVReport | Export-Csv -Path $FilePath -NoTypeInformation
Let me know if this helps or if you have any other questions 😄
Kind Regards
Oliwer Sundgren- Manflo1603Nov 15, 2022Brass ContributorBonjour @sundgren,
je vais le tester et voir ce que donne la sortie, merci beaucoup pour votre aide !