Open fant0zzi opened 1 year ago
Thank you for the explanation! Can we use the same script for .Net Core 6.0? Also can you please help us with the nudget packages that needs to be installed. I am getting the error "The getter method should be public, not void, static, and have one parameter of the type PSObject." when executing the script using .Net core 6. Can you please help
Hello again, I have somehow managed to resolve the error "The getter method should be public, not void, static, and have one parameter of the type PSObject.". But now I get a new error upon executing the powerhell.invoke() command -: "The term 'New-PartnerAccessToken' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again" Can you please help.
Hello, I have the same problem using this code with The term 'New-PartnerAccessToken' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, check that the path is correct and try again' Did you have a solution? Thank you in advance
I am looking to reproduce in c# this process in powershell
TenantID = "xxxxxxxxxxxxxxxxxxx" # Tenant $ApplicationID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # Application in Tenant "Partner Center" $ApplictionSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
$credential = New-Object PSCredential ($ApplicationID, (ConvertTo-SecureString $ApplictionSecret -AsPlainText -Force)) $token = New-PartnerAccessToken -ApplicationId $ApplicationID -Scopes 'https://api.partnercenter.microsoft.com/user_impersonation' -ServicePrincipal -Credential $credential -Tenant $TenantID -UseAuthorizationCode $token | clip
. Someone help me a little?
When the New-PartnerAccessToken command is executed in parallel for multiple tenants from C# code, one of the responses contains multiple tokens, while empty PSObjects are returned for the other tenants. There are no execution errors.
To demonstrate this behaviour, I have written a simple script (using .NET7) that runs multiple New-PartnerAccessToken commands simultaneously in separate runspaces. It's important to note that the results of the execution can vary - sometimes a single token is returned in the response for a tenant, sometimes multiple tokens are returned, one of which is issued for another tenant. However, the results for the other tenants are always empty. I have attached a screenshot where the results dict contains 2 tokens resolved for one tenant, while for other tenants empty results have been received.
Environment
PSVersion 5.1 PartnerCenter 3.0.10 Microsoft.PowerShell.SDK 7.3.3 Microsoft.IdentityModel.Token 6.27.0 The issue is reproducable on both .NET 4.8 and .NET 7