Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@darrenjrobinson
Created August 29, 2016 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrenjrobinson/4aa2bfaea23f85bedb899809dcc84a8d to your computer and use it in GitHub Desktop.
Save darrenjrobinson/4aa2bfaea23f85bedb899809dcc84a8d to your computer and use it in GitHub Desktop.
# 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