Skip to content

Instantly share code, notes, and snippets.

@vhusker
Last active April 8, 2018 10:39
Show Gist options
  • Save vhusker/32214c95e1e71ec3faff to your computer and use it in GitHub Desktop.
Save vhusker/32214c95e1e71ec3faff to your computer and use it in GitHub Desktop.
Function Get-PartnerMailboxes{
[cmdletbinding()]
Param(
[Parameter(Mandatory=$True)]
[PSCredential]$Credential = (Get-Credential),
[Parameter(Mandatory=$True)]
[String]$Path
)
Import-Module MSOnline
Connect-MsolService -Credential $Credential
$clients = (Get-MSOLPartnerContract)
$tenants = $clients.tenantid
ForEach($Tenant in $Tenants){
$Users = Get-MsolUser -TenantId $Tenant| Where-Object {$_.IsLicensed -eq $True}
$UPN = $Users[0].UserPrincipalName
$Domain = $UPN.Split('@')
$Properties = @{'Licensed Users' = $Users.Count;
'Domain' = $Domain[1];
}
$PropsObject = New-Object -TypeName PSObject -Property $Properties
$PropsObject | Export-CSV -Path $Path -NoTypeInformation -Append
}
}
Get-PartnerMailboxes -Path C:\Users\Jacob\Desktop\PartnerMailboxes.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment