Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. # Import the MVPSModule
  2. Import-Module LithnetMIISAutomation
  3. # Install-Module PowerBIPS
  4. Import-Module PowerBIPS
  5.  
  6. # Metaverse User Data Query
  7. $queryfilter = @();
  8. $queryfilter += New-MVQuery -Attribute assignedLicenses -Operator isPresent
  9.  
  10. # Execute query and get results
  11. $results = Get-MVObject -Queries $queryfilter | Select-Object -Property Attributes | select -expand *
  12.  
  13. # Get a subset of the attributes into a new object
  14. [int]$i=0
  15. $userdetails = $results | foreach {
  16. New-Object PSObject -prop @{
  17. ObjectID = $results[$i].objectID.Values.valuestring;
  18. UPN = $results[$i].userPrincipalName.values.valuestring;
  19. GivenName = $results[$i].givenName.Values.valuestring;
  20. Surname = $results[$i].sn.Values.valuestring;
  21. DisplayName = $results[$i].displayName.Values.valuestring;
  22. mail = $results[$i].mail.Values.valuestring;
  23. AccountEnabled = $results[$i].accountEnabled.Values.valueboolean;
  24. }
  25. $i++
  26. }
  27. $userdetails.Count
  28.  
  29. # Get the users with provisioned licenses
  30. [int]$i=0
  31. $userprovisionedlicensedetails = $results | foreach {
  32. foreach($provisionedlicense in $results[$i].provisionedPlans.values.valuestring)
  33. {
  34. New-Object PSObject -prop @{
  35. ObjectID = $results[$i].objectID.Values.valuestring;
  36. UPN = $results[$i].userPrincipalName.values.valuestring;
  37. ProvisionedPlans = $provisionedlicense;
  38. }
  39. }
  40. $i++
  41. }
  42. $userprovisionedlicensedetails.Count
  43.  
  44. # Get the users with assigned licenses
  45. [int]$i=0
  46. $userassignedlicensedetails = $results | foreach {
  47. foreach($assignedlicense in $results[$i].assignedPlans.values.valuestring)
  48. {
  49. New-Object PSObject -prop @{
  50. ObjectID = $results[$i].objectID.Values.valuestring;
  51. UPN = $results[$i].userPrincipalName.values.valuestring;
  52. AssignedPlans = $assignedlicense;
  53. }
  54. }
  55. $i++
  56. }
  57.  
  58. $userassignedlicensedetails.Count
  59.  
  60. # Tenant licenses
  61. $queryfilterLicensePlans = @();
  62. $queryfilterLicensePlans += New-MVQuery -Attribute skuId -Operator isPresent
  63.  
  64. $Plansresults = Get-MVObject -Queries $queryfilterLicensePlans | Select-Object -Property Attributes | select -expand *
  65.  
  66. [int]$i=0
  67. $planlicensedetails = $Plansresults | foreach {
  68. New-Object PSObject -prop @{
  69. objectID = $Plansresults[$i].objectID.values.valuestring;
  70. skuId = $Plansresults[$i].skuId.Values.valuestring;
  71. skuPartNumber = $Plansresults[$i].skuPartNumber.Values.valuestring;
  72. suspended = $Plansresults[$i].suspended.Values.valueinteger;
  73. warning = $Plansresults[$i].warning.Values.valueinteger;
  74. consumedUnits = $Plansresults[$i].consumedUnits.values.valueinteger;
  75. enabled = $Plansresults[$i].enabled.values.valueinteger;
  76. }
  77. $i++
  78. }
  79. $planlicensedetails.Count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement