Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $skuttolicname = @{
- "ENTERPRISEPACK" = "E3";
- "STANDARDPACK" = "E1";
- "LITEPACK_P2" = "Business Premium";
- "SMB_BUSINESS_PREMIUM" = "Business Premium";
- "O365_BUSINESS_PREMIUM" = "Business Premium";
- "SMB_BUSINESS_ESSENTIALS" = "Business Essentials";
- "LITEPACK" = "Business Essentials"
- "O365_BUSINESS" = "Business";
- "SMB_BUSINESS" = "Business";
- "MCOSTANDARD" = "Skype 4 Business (2)";
- "EXCHANGESTANDARD" = "Exchange Online (1)";
- "EXCHANGEENTERPRISE" = "Exchange Online (2)";
- "EXCHANGEENTERPRISE_FACULTY" = "Exchange School";
- "OFFICESUBSCRIPTION_FACULTY" = "Office ProPlus School";
- "" = ""
- }
- function GetLicenseNameFromSku($licenseskuw)
- {
- $pos = $licenseskuw.IndexOf(":")
- $licenseskuw = $licenseskuw.Substring($pos+1)
- if ($skuttolicname.ContainsKey($licenseskuw) -ne $true)
- {
- return "Unknown"
- }
- return $skuttolicname[$licenseskuw]
- }
- $username = "partner.username@domain.tld"
- $password = "password" | ConvertTo-SecureString -AsPlainText -Force
- $credential = New-Object System.Management.Automation.PSCredential($username,$password)
- $filepath = "\\some\path\somewhere"
- if (Test-Path $filepath)
- {
- Remove-Item $filepath
- }
- $("Företag" + ";" + "Namn" + ";" + "Licens") | Out-File -Encoding UTF8 -Append -FilePath $filepath
- Connect-MsolService -Credential $credential
- foreach ($partnercontract in Get-MsolPartnerContract)
- {
- $namn = $partnercontract.Name
- foreach ($user in Get-MsolUser -TenantId $partnercontract.TenantId | Where-Object { $_.IsLicensed -eq $true })
- {
- $licenses = $user.Licenses
- $licensestr = ""
- foreach ($lic in $licenses)
- {
- $licensestr = $licensestr + $(GetLicenseNameFromSku($lic.AccountSkuId)) + " | "
- }
- if ($licensestr.Length -gt 3)
- {
- $licensestr = $licensestr.Substring(0, $licensestr.Length - 3)
- }
- $($namn + ";" + $user.DisplayName + ";" + $licensestr) | Out-File -Encoding UTF8 -Append -FilePath $filepath
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement