Advertisement
Guest User

Untitled

a guest
Jan 29th, 2016
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. $skuttolicname = @{
  2. "ENTERPRISEPACK" = "E3";
  3. "STANDARDPACK" = "E1";
  4. "LITEPACK_P2" = "Business Premium";
  5. "SMB_BUSINESS_PREMIUM" = "Business Premium";
  6. "O365_BUSINESS_PREMIUM" = "Business Premium";
  7. "SMB_BUSINESS_ESSENTIALS" = "Business Essentials";
  8. "LITEPACK" = "Business Essentials"
  9. "O365_BUSINESS" = "Business";
  10. "SMB_BUSINESS" = "Business";
  11. "MCOSTANDARD" = "Skype 4 Business (2)";
  12. "EXCHANGESTANDARD" = "Exchange Online (1)";
  13. "EXCHANGEENTERPRISE" = "Exchange Online (2)";
  14. "EXCHANGEENTERPRISE_FACULTY" = "Exchange School";
  15. "OFFICESUBSCRIPTION_FACULTY" = "Office ProPlus School";
  16. "" = ""
  17. }
  18.  
  19. function GetLicenseNameFromSku($licenseskuw)
  20. {
  21. $pos = $licenseskuw.IndexOf(":")
  22. $licenseskuw = $licenseskuw.Substring($pos+1)
  23.  
  24. if ($skuttolicname.ContainsKey($licenseskuw) -ne $true)
  25. {
  26. return "Unknown"
  27. }
  28.  
  29. return $skuttolicname[$licenseskuw]
  30. }
  31.  
  32. $username = "partner.username@domain.tld"
  33. $password = "password" | ConvertTo-SecureString -AsPlainText -Force
  34. $credential = New-Object System.Management.Automation.PSCredential($username,$password)
  35.  
  36. $filepath = "\\some\path\somewhere"
  37.  
  38. if (Test-Path $filepath)
  39. {
  40. Remove-Item $filepath
  41. }
  42.  
  43. $("Företag" + ";" + "Namn" + ";" + "Licens") | Out-File -Encoding UTF8 -Append -FilePath $filepath
  44.  
  45. Connect-MsolService -Credential $credential
  46.  
  47. foreach ($partnercontract in Get-MsolPartnerContract)
  48. {
  49. $namn = $partnercontract.Name
  50.  
  51. foreach ($user in Get-MsolUser -TenantId $partnercontract.TenantId | Where-Object { $_.IsLicensed -eq $true })
  52. {
  53. $licenses = $user.Licenses
  54. $licensestr = ""
  55.  
  56. foreach ($lic in $licenses)
  57. {
  58. $licensestr = $licensestr + $(GetLicenseNameFromSku($lic.AccountSkuId)) + " | "
  59. }
  60.  
  61. if ($licensestr.Length -gt 3)
  62. {
  63. $licensestr = $licensestr.Substring(0, $licensestr.Length - 3)
  64. }
  65.  
  66. $($namn + ";" + $user.DisplayName + ";" + $licensestr) | Out-File -Encoding UTF8 -Append -FilePath $filepath
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement