Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Cannot get tenant subscription list if tenant has an expired subsctiption. #394

Open
DavidMoore-intY opened this issue Mar 25, 2022 · 10 comments

Comments

@DavidMoore-intY
Copy link

Steps to reproduce

Run 'Get-PartnerCustomerSubscription' against a tenant with an expired subscription

Expected behavior

List of subscriptions on the tenant is returned

Actual behavior

Get-PartnerCustomerSubscription : Requested value 'Expired' was not found.
At line:1 char:2

  • Get-PartnerCustomerSubscription -CustomerId ________---____- ...
  •  + CategoryInfo          : CloseError: (:) [Get-PartnerCustomerSubscription], ArgumentException
     + FullyQualifiedErrorId : Microsoft.Store.PartnerCenter.PowerShell.Commands.GetPartnerCustomerSubscription
    
    

Diagnostic logs

Running with -debug shows data being returned from Microsoft as expected.
Logs not included as it is a live customer tenant.

Environment

PSVersion 5.1.18362.1801
PSEdition Desktop

ModuleType Version Name


Script 3.0.10 PartnerCenter

@aunCoreyGood
Copy link

Having this exact issue as well. Suspending the subscription doesn't seem to fix this and I'm unable to cancel the expired subscription.

@DavidMoore-intY
Copy link
Author

DavidMoore-intY commented May 5, 2022

@aunCoreyGood I've ended up implementing the calls I need myself as separate functions

Function Get-MSCustomerSubscriptions {

    [CmdletBinding()]
    Param (
        [Parameter(Mandatory = $true)]
        [GUID]$TenantID
    )

    $result = (Invoke-RestMethod -Method GET -URI "https://api.partnercenter.microsoft.com/v1/customers/$TenantID/subscriptions" -Authentication Bearer -Token Get-MSAccessToken)
    
    Return $Result.items

}

Get-MSAccessToken is specific to my environment, but once you've implemented a way to get a token all the rest is fairly easy.

@DavidMoore-intY
Copy link
Author

On a similar note, the BillingCycle 'Triennial' isn't supported by the powershell module so anything that involves getting details of a product that supports that billing type will fail.

@TheSTHDK
Copy link

Having the same issue. The Expired subscription is showing in the Debug output, but the module does not know how to handle the expired status it seems.
I will try your workaround David.

@mwasham
Copy link

mwasham commented Oct 28, 2022

Any chance this is going to get fixed soon?

@ezcodify
Copy link

ezcodify commented Dec 7, 2022

Any chance this is going to get fixed soon?

I sure hope so - I have this issue as well

@despian
Copy link

despian commented Feb 11, 2023

Also encountered this. David's workaround works well though. Thanks.

If anyone needs a token for unattended access:

$token = (New-PartnerAccessToken `
  -ApplicationId $pcClientId `
  -Credential $pcCreds `
  -Scopes "https://graph.windows.net/.default" `
  -ServicePrincipal `
  -Tenant $pcTenantId).AccessToken
[securestring]$ssToken = ConvertTo-SecureString $token -AsPlainText -Force

@ngailloux-softlanding
Copy link

I can't believe this is still an open issue almost two years on. We are also seeing this same issue if any subscriptions are in the "Disabled" state, or if the BillingCycle is "Triennial". This is causnig us to not be able to do a full subscription export via PowerShell.

@DavidMoore-intY
Copy link
Author

@ngailloux-softlanding Last release was 3 and a half years ago, I think it's pretty clear that this module has been abandoned now. Unfortuantely Microsoft's documentation still directs people to it in quite a few places.

I've ended up building a module with all the functionality we need myself, once you've set up the necessary stuff for authentication the majority of the calls are very straightforward to implement.

@mprentice22153
Copy link

As @DavidMoore-intY said, the PartnerCenter module is abandoned. It would be best to switch to using the APIs and modernizing your scripts. You will find more fields available to you and also not encounter the broken functionality described here and elsewhere. The New-PartnerAccessToken cmdlet was the last one I held onto from the old module but now have a replacement for that using APIs.

This is unfair of me to say: I would share with you what I have created but for now I'm too buried with projects to spend time cleaning up my code so I'm comfortable sharing it. Over a year ago I started with getting authentication working, then I've built my own module of customer functions to replace the old module. As necessary I add a new function and keep moving on. As @DavidMoore-intY said, most are straightforward to implement.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants