Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Import the MVPSModule
Import-Module LithnetMIISAutomation
# Install-Module PowerBIPS
Import-Module PowerBIPS
# Metaverse User Data Query
$queryfilter = @();
$queryfilter += New-MVQuery -Attribute assignedLicenses -Operator isPresent
# Execute query and get results
$results = Get-MVObject -Queries $queryfilter | Select-Object -Property Attributes | select -expand *
# Get a subset of the attributes into a new object
[int]$i=0
$userdetails = $results | foreach {
New-Object PSObject -prop @{
ObjectID = $results[$i].objectID.Values.valuestring;
UPN = $results[$i].userPrincipalName.values.valuestring;
GivenName = $results[$i].givenName.Values.valuestring;
Surname = $results[$i].sn.Values.valuestring;
DisplayName = $results[$i].displayName.Values.valuestring;
mail = $results[$i].mail.Values.valuestring;
AccountEnabled = $results[$i].accountEnabled.Values.valueboolean;
}
$i++
}
$userdetails.Count
# Get the users with provisioned licenses
[int]$i=0
$userprovisionedlicensedetails = $results | foreach {
foreach($provisionedlicense in $results[$i].provisionedPlans.values.valuestring)
{
New-Object PSObject -prop @{
ObjectID = $results[$i].objectID.Values.valuestring;
UPN = $results[$i].userPrincipalName.values.valuestring;
ProvisionedPlans = $provisionedlicense;
}
}
$i++
}
$userprovisionedlicensedetails.Count
# Get the users with assigned licenses
[int]$i=0
$userassignedlicensedetails = $results | foreach {
foreach($assignedlicense in $results[$i].assignedPlans.values.valuestring)
{
New-Object PSObject -prop @{
ObjectID = $results[$i].objectID.Values.valuestring;
UPN = $results[$i].userPrincipalName.values.valuestring;
AssignedPlans = $assignedlicense;
}
}
$i++
}
$userassignedlicensedetails.Count
# Tenant licenses
$queryfilterLicensePlans = @();
$queryfilterLicensePlans += New-MVQuery -Attribute skuId -Operator isPresent
$Plansresults = Get-MVObject -Queries $queryfilterLicensePlans | Select-Object -Property Attributes | select -expand *
[int]$i=0
$planlicensedetails = $Plansresults | foreach {
New-Object PSObject -prop @{
objectID = $Plansresults[$i].objectID.values.valuestring;
skuId = $Plansresults[$i].skuId.Values.valuestring;
skuPartNumber = $Plansresults[$i].skuPartNumber.Values.valuestring;
suspended = $Plansresults[$i].suspended.Values.valueinteger;
warning = $Plansresults[$i].warning.Values.valueinteger;
consumedUnits = $Plansresults[$i].consumedUnits.values.valueinteger;
enabled = $Plansresults[$i].enabled.values.valueinteger;
}
$i++
}
$planlicensedetails.Count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment