Last active
March 18, 2016 15:29
-
-
Save ciphertxt/615a9c9cc0351c7e3acb to your computer and use it in GitHub Desktop.
Retrieves a list of users with an ENTERPRISEPACK assignment and outputs the ProvisioningStatus of the Service Plans associated with the enterprise pack.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module MSOnline -EA 0 | |
$credential = Get-Credential | |
Connect-MsolService -Credential $credential | |
$accountSKU = Get-MsolAccountSku | ? { $_.AccountSKUID -like "*ENTERPRISEPACK" } | |
$users = Get-MsolUser -All | Where-Object { $_.isLicensed -eq "TRUE" } | Select-Object UserPrincipalName, DisplayName, Country, Department -ExpandProperty Licenses | ? { $_.AccountSKUID -eq $accountSKU.AccountSkuID } | |
$output = @() | |
foreach ($user in $users) { | |
$oUser = New-Object -TypeName PSObject | |
$oUser | Add-Member -MemberType NoteProperty -Name UserPrincipalName -Value $user.UserPrincipalName | |
$oUser | Add-Member -MemberType NoteProperty -Name DisplayName -Value $user.DisplayName | |
$oUser | Add-Member -MemberType NoteProperty -Name Country -Value $user.Country | |
$oUser | Add-Member -MemberType NoteProperty -Name Department -Value $user.Department | |
foreach ($status in $user.ServiceStatus) { | |
$planProp = $status.ServicePlan.ServiceName | |
$oUser | Add-Member -MemberType NoteProperty -Name $planProp -Value $status.ProvisioningStatus | |
} | |
$output += $oUser | |
} | |
$outputName = $accountSKU.AccountSkuId.Replace(":","") | |
$output | Export-Csv -NoTypeInformation -Path "$($outputName).csv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment