Public/Curanet/M365/Get-CuranetM365TenantSubscriptions.ps1
function Get-CuranetM365TenantSubscriptions() { param( [Parameter(Mandatory)] [string] $CustomerId ) Connect-CuranetM365API -CustomerId $CustomerId $Response = Invoke-WebRequest -Method GET -Authentication Bearer -Token (ConvertTo-SecureString $Global:CuranetM365APIToken.access_token -AsPlainText -Force) -Uri "https://office365.curanet.dk/api/Subscriptions/" if($Response.StatusCode -eq 200) { $JsonResponse = $Response.Content | ConvertFrom-Json foreach($i in $JsonResponse.PSObject.Properties) { if($i.Name -eq "creationDate" -or $i.Name -eq "commitmendEndDate" -or $i.Name -eq "renewalDate" -or $i.Name -eq "invoicedUntil" -or $i.Name -eq "cancellationAllowedUntilDate") { $DateTime = $i.Value -as [DateTime] if($DateTime) { $i.value = $i.Value.ToLocalTime() } } } return $JsonResponse } else { throw "Failed to get M365 subscriptions" } } |