diff --git a/.gitignore b/.gitignore index a244abf..25e07e8 100644 --- a/.gitignore +++ b/.gitignore @@ -334,4 +334,10 @@ ASALocalRun/ !.vscode/settings.json !.vscode/tasks.json !.vscode/launch.json -!.vscode/extensions.json \ No newline at end of file +!.vscode/extensions.json +!tests/Reset-PCTests.ps1 +!tests/Test-PCCmdlets.ps1 +tests/Get-Markdown.ps1 +tests/Get-HelpByMarkdown.ps1 +tests/Reset-PCTestsLOCAL.ps1 +CmdletHelp3/* diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b4224de --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,31 @@ +{ + "cSpell.enabledLanguageIds": [ + "asciidoc", + "c", + "cpp", + "csharp", + "css", + "go", + "handlebars", + "html", + "jade", + "javascript", + "javascriptreact", + "json", + "latex", + "less", + "markdown", + "php", + "plaintext", + "powershell", + "pub", + "python", + "restructuredtext", + "rust", + "scss", + "text", + "typescript", + "typescriptreact", + "yml" + ] +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index fceb91b..2563e35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,28 +1,46 @@ # Partner Center PowerShell Module Changelog -## 0.9.0.21 (2018-05-22) +## 0.10.0.0 (2018-06-13) ### Features -* Removed telemetry functions -* Added non-plural cmdlets names to comply with PowerShell standards - * Get-PCAuditRecord - * Get-PCCustomerLicenseDeployment - * Get-PCCustomerLicenseUsage - * Get-PCCustomerRelationship - * Get-PCIndirectReseller - * Get-PCLicenseUsage - * Get-PCLicenseDeployment - * Get-PCManagedSerice - * Get-PCResellerCustomer - * Get-PCSRTopic - * Get-PCSubscribedSKU +* Added an application id to send as part of the REST request to identify the application traffic. +* Enabled Get-PCUsage to return more than 1000 usage records. ### Bug Fixes -* Addressed an issue with the New-PCCustomer cmdlet that was preventing customers currently. -* Addressed an issue where Get-PCOfferCategoriesByMarket did not require the countryId, however the API does require this. +* Removed inoperable export of Set-PCGraphUserPassword +* Made the CountryId parameter mandatory for the Get-PCAddressRulesByMarket, otherwise an error was thrown. +* Fixed an issue where Set-PCLegalBusinessProfile could not update the primary contact information. +* Fixed an issue where Set-PCSupportProfile could not set information, if any of the default properties were missing. + +* Added validation for the -Currency and -Region parameters on Get-PCAzureRatecard +* Added regex validation for the -StartDate and -EndDate parameters of Get-PCAuditRecord +* Added regex validation for the -CountryId parameter for all cmdlets. ### Breaking Changes -* No breaking changes with this release \ No newline at end of file +* Removed the Get-PCUsage2 cmdlet, replaced by Get-PCUsage functionality. +* Renamed -start_time, -end_time, -show_details parameters to -StartTime, -EndTime, and -ShowDetail respectively for the following cmdlets: + * Get-PCUsage +* Renamed the -Size parameter to -ResultSize on the following cmdlets: + * Get-PCUsage +* Removed the All parameter from the following cmdlets: + * Get-PCCustomer + * Get-PCSR + * Get-PCSubscription + * Get-PCCustomerUser +* Removed the following cmdlets, instead use the new cmdlet name: + * Get-PCCustomerLicensesDeployment use Get-PCCustomerLicenseDeployment + * Get-PCCustomerLicensesUsage use Get-PCCustomerLicenseUsage + * Get-PCInvoiceLineItems use Get-PCInvoiceLineItem + * Get-PCResellerCustomers use Get-PCResellerCustomer + * Get-PCAzureResourceMonthlyUsageRecords use Get-PCAzureResourceMonthlyUsageRecord + * Get-PCCustomerRelationships use Get-PCCustomerRelationship + * Get-PCIndirectResellers use Get-PCIndirectReseller + * Get-PCLicensesUsage use Get-PCLicenseUsage + * Get-PCLicensesDeployment use Get-PCLicenseDeployment + * Get-PCAuditRecords use Get-PCAuditRecord + * Get-PCSubscribedSKUs use Get-PCSubscribedSKU +* Modified the -AutoRenewEnabled parameter for Set-PCSubscription to be -AutoRenew +* Get-PCCustomerRole, Remove-PCCustomerUser, Set-PCCustomerUser now require the user id to be passed instead of a PowerShell object containing all of the user information. The parameter was also renamed from -User to -UserId to better reflect this change. \ No newline at end of file diff --git a/CmdletHelp/Add-PCAuthentication.md b/CmdletHelp/Add-PCAuthentication.md index f499bdc..d5c013d 100644 --- a/CmdletHelp/Add-PCAuthentication.md +++ b/CmdletHelp/Add-PCAuthentication.md @@ -1,18 +1,101 @@ -# Add-PCAuthentication # +# Add-PCAuthentication -## Set a global token for the script session - user authentication ## +Authenticates the current session with the Partner Center API. + +## SYNTAX ```powershell - $cred = Get-Credential - Add-PCAuthentication -cspappID '' -cspDomain '' -credential $cred +Add-PCAuthentication -CspAppId -CspDomain -Credential [] + +Add-PCAuthentication -CspAppId -CspDomain -CspClientSecret [] ``` -## Set a global token for the script session - app authentication ## +## DESCRIPTION -```powershell - $clientSecret = '' - $clientSecretSecure = $clientSecret | ConvertTo-SecureString -AsPlainText -Force - Add-PCAuthentication -cspappID '' -cspDomain '' -cspClientSecret $clientSecretSecure +The Add-PCAuthentication cmdlet sets up authentication for the Partner Center API. Authenticate with either App authentication or App+User authentication to use other cmdlets in this module. + +## PARAMETERS + +### -CspAppId <String> + +Specifies a application Id generated for the Partner Center account. The application id must match the authentication type chosen. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -CspDomain <String> + +Specifies the Partner Center tenant (onmicrosoft.com) domain. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -CspClientSecret <SecureString> + +Specifies an application secret key generated from the Partner Center portal. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false ``` +### -Credential <PSCredential> + +Specifies the user account credentials to use to perform this task. To specify this parameter, you can type a user name, such as User1 or Domain01\User01 or you can specify a PSCredential object. If you specify a user name for this parameter, the cmdlet prompts for a password. +You can also create a PSCredential object by using a script or by using the Get-Credential cmdlet. You can then set the Credential parameter to the PSCredential object. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +Some cmdlets require App+User authentication. If you are working with invoices or users, you should use App+User authentication. + +$clientSecret = '' +$clientSecretSecure = $clientSecret | ConvertTo-SecureString -AsPlainText -Force +$cred = Get-Credential + +## EXAMPLES + You can obtain the Web App ID and the Client Secret from either Partner Center UI or Azure Active Directory + +### EXAMPLE 1 + +Set a global token for the script session - App+User authentication + +```powershell +PS C:\>$cred = Get-Credential +PS C:\>Add-PCAuthentication -CspAppId '' -CspDomain '' -Credential $cred +``` + +### EXAMPLE 2 + +Set a global token for the script session - App authentication + +```powershell +PS C:\>$clientSecret = '' +PS C:\>$clientSecretSecure = $clientSecret | ConvertTo-SecureString -AsPlainText -Force +PS C:\>Add-PCAuthentication -CspAppId '' -CspDomain '' -CspClientSecret $clientSecretSecure +``` diff --git a/CmdletHelp/Add-PCCustomerRoleMember.md b/CmdletHelp/Add-PCCustomerRoleMember.md index 086455c..c01effd 100644 --- a/CmdletHelp/Add-PCCustomerRoleMember.md +++ b/CmdletHelp/Add-PCCustomerRoleMember.md @@ -1,27 +1,99 @@ -# Add-PCCustomerRoleMember # +# Add-PCCustomerRoleMember -## Specify a customer ## +Adds a customer user account. + +## SYNTAX + +```powershell +Add-PCCustomerRoleMember [[-TenantId] ] [-RoleId] [-CustomerRoleMember] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Add-PCCustomerRoleMember cmdlet adds a customer user account into a role. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant for which to add the role member. + +``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -RoleId <String> + +Specifies the role id for which to add the member. + +``` +Required? true +Position? 2 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -CustomerRoleMember <PSObject> + +Specifies the member to add to the role. + +``` +Required? true +Position? 3 +Default value +Accept pipeline input? true (ByValue, ByPropertyName) +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies a security token for authenticating and executing the cmdlet. + +``` +Required? false +Position? 4 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## OUTPUTS + +System.Object + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Specify a customer tenant ```powershell - $customer = Get-PCCustomer -tenantid '' + $customer = Get-PCCustomer -TenantId '' ``` -## Get a role ## +Get a role ```powershell - $role = Get-PCCustomerRole -tenantid $customer.id | Where-Object name -Contains '' + $role = Get-PCCustomerRole -TenantId $customer.id | Where-Object name -Contains '' ``` -## Get a User ## +Get a User ```powershell - $user = Get-PCCustomerUser -tenantid $customer.id -userid '' + $user = Get-PCCustomerUser -TenantId $customer.id -UserId '' ``` -## Add a User to a Role ## +Add the user to a Role ```powershell $customerRoleMember = [DirectoryRoleMember]::new() $customerRoleMember.id = $user.id - Add-PCCustomerRoleMember -tenantid $customer.id -roleid $role.id -customerrolemember $customerRoleMember + Add-PCCustomerRoleMember -TenantId $customer.id -RoleId $role.id -CustomerRoleMember $customerRoleMember ``` diff --git a/CmdletHelp/Get-PCAddressRulesByMarket.md b/CmdletHelp/Get-PCAddressRulesByMarket.md index 36d872d..221c616 100644 --- a/CmdletHelp/Get-PCAddressRulesByMarket.md +++ b/CmdletHelp/Get-PCAddressRulesByMarket.md @@ -1,7 +1,57 @@ -# Get-PCAddressRulesByMarket # +# Get-PCAddressRulesByMarket -## Get all address rules for countryid ## +Retrieves a list of address rules for a specified market. + +## SYNTAX + +```powershell +Get-PCAddressRulesByMarket [-CountryId] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCAddressRulesByMarket returns a list of rules for the specified market. + +## PARAMETERS + +### -CountryId <String> + +Specifies a two-character ISO 2 country code. + +``` +Required? true +Position? 1 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token you have created with your Partner Center credentials. + +``` +Required? false +Position? 2 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +You need to have authenticated before running this cmdlet. + +## EXAMPLES + +### EXAMPLE 1 + +Return the address rules for the US. ```powershell - Get-PCAddressRulesByMarket -countryid '' +PS C:\>Get-PCAddressRulesByMarket -CountryId US ``` diff --git a/CmdletHelp/Get-PCAuditRecord.md b/CmdletHelp/Get-PCAuditRecord.md index 57aae7c..25aee06 100644 --- a/CmdletHelp/Get-PCAuditRecord.md +++ b/CmdletHelp/Get-PCAuditRecord.md @@ -1,19 +1,79 @@ -# Get-PCAuditRecord # +# Get-PCAuditRecord -## Get audit logs starting from a specific date ## +Returns audit records for the specified date range. + +## SYNTAX + +```powershell +Get-PCAuditRecord [-StartDate] [[-EndDate] ] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCAuditRecord cmdlet. + +## PARAMETERS + +### -StartDate <String> + +The date from which you will start retrieving data. Must be formated yyyy-mm-dd. + +``` +Required? true +Position? 1 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -EndDate <String> + +The date from which you will stop retrieving data. Must be formated yyyy-mm-dd. + +``` +Required? false +Position? 2 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 3 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +#### Get audit logs starting from a specific date ```powershell - Get-PCAuditRecord -startDate '2017-04-12' + Get-PCAuditRecord -StartDate '2017-04-12' ``` -## Get audit logs between two dates ## +#### Get audit logs between two dates ```powershell - Gett-PCAuditRecord -startDate '2017-04-12' -endDate '2017-04-13' + Get-PCAuditRecord -StartDate '2017-04-12' -EndDate '2017-04-13' ``` -## Get audit logs of a specific operationType between two dates ## +#### Get audit logs of a specific operationType between two dates ```powershell - Get-PCAuditRecord -startDate '2017-04-12' -endDate '2017-04-13' | ? operationType -EQ 'delete_customer_user' + Get-PCAuditRecord -StartDate '2017-04-12' -EndDate '2017-04-13' | ? operationType -EQ 'delete_customer_user' ``` diff --git a/CmdletHelp/Get-PCAzureRateCard.md b/CmdletHelp/Get-PCAzureRateCard.md index 81b751a..4abd2d3 100644 --- a/CmdletHelp/Get-PCAzureRateCard.md +++ b/CmdletHelp/Get-PCAzureRateCard.md @@ -1,16 +1,69 @@ -# Get-PCAzureRateCard # +# Get-PCAzureRateCard -## Get Azure rate card (meters) for default context ## +Retrieves the Azure services rate card for the specified region. + +## SYNTAX ```powershell - Get-PCAzureRateCard +Get-PCAzureRateCard [[-Currency] ] [[-Region] ] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCAzureRateCard returns a list of Azure rates for the specified region. + +## PARAMETERS + +### -Currency <String> + +Specifies a three-character ISO currency code. + +``` +Required? false +Position? 1 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Region <String> + +Specifies a two-character ISO 2 country code. + +``` +Required? false +Position? 2 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + ``` +Required? false +Position? 3 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS -- **currency** Optional three letter ISO code for the currency in which the resource rates will be provided (e.g. "EUR"). The default is the currency associated with the market in the partner profile. -- **region** Optional two-letter ISO country/region code that indicates the market where the offer is purchased (e.g. "FR"). The default is the country/region code set in the partner profile. +## NOTES -## Get Azure rate card for specific currency and region ## +You need to have a authentication Credential already established before running this cmdlet. The region and the currency must match to return a result. + +## EXAMPLES + +### EXAMPLE 1 ```powershell - Get-PCAzureRateCard -currency '' -region '' +PS C:\>Get-PCAzureRateCard -region US -currency USD + +Returns the Azure rate card for the specified region and currency. ``` diff --git a/CmdletHelp/Get-PCAzureResourceMonthlyUsageRecord.md b/CmdletHelp/Get-PCAzureResourceMonthlyUsageRecord.md new file mode 100644 index 0000000..a4afb08 Binary files /dev/null and b/CmdletHelp/Get-PCAzureResourceMonthlyUsageRecord.md differ diff --git a/CmdletHelp/Get-PCBillingProfile.md b/CmdletHelp/Get-PCBillingProfile.md index 6b0dff6..fd25b6f 100644 --- a/CmdletHelp/Get-PCBillingProfile.md +++ b/CmdletHelp/Get-PCBillingProfile.md @@ -1,7 +1,41 @@ -# Get-PCBillingProfile # +# Get-PCBillingProfile -## Get Partner Billing Profile ## +Returns the billing profile for the current partner. + +## SYNTAX + +```powershell +Get-PCBillingProfile [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCBillingProfile cmdlet returns the billing profile for the current partner tenant. + +## PARAMETERS + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 1 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 ```powershell - Get-PCBillingProfile +PS C:\>Get-PCBillingProfile ``` diff --git a/CmdletHelp/Get-PCCustomer.md b/CmdletHelp/Get-PCCustomer.md index dfb2dc5..ecd8a96 100644 --- a/CmdletHelp/Get-PCCustomer.md +++ b/CmdletHelp/Get-PCCustomer.md @@ -1,19 +1,99 @@ -# Get-PCCustomer # +# Get-PCCustomer -## Get all customers ## +Returns a list of customers or a specific customer. + +## SYNTAX ```powershell - Get-PCCustomer -all +Get-PCCustomer [-TenantId ] [-SaToken ] [] + +Get-PCCustomer -StartsWith [-ResultSize ] [-SaToken ] [] +``` + +## DESCRIPTION + +The Get-PCCustomer cmdlet retrieves a list of customers, or a specific customer based on the input. + +## PARAMETERS + +### -TenantId <String> + +The tenant Id assigned to the customer you want to retrieve. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false ``` -## Get a customer by ID ## +### -StartsWith <String> + +Specifies a filter for the customer names returned. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -ResultSize <Int32> + +Specifies the maximum number of results to return. The default value is 200. + +``` +Required? false +Position? named +Default value 200 +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token you have created with your Partner Center credentials. + +``` +Required? false +Position? named +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +You need to have a authentication credential already established before running this cmdlet. + +## EXAMPLES + +### EXAMPLE 1 + +Return a list of customers for a partner. ```powershell - $customer = Get-PCCustomer -tenantid '' +PS C:\>Get-PCCustomer ``` -## Get customers by company name ## +### EXAMPLE 2 + +Return a customer by specifying an Id + +```powershell + $customer = Get-PCCustomer -TenantId '' +``` + +### EXAMPLE 3 + +Return a customer by specifying part of the company name ```powershell - Get-PCCustomer -startswith '' + Get-PCCustomer -StartsWith '' ``` diff --git a/CmdletHelp/Get-PCCustomerBillingProfile.md b/CmdletHelp/Get-PCCustomerBillingProfile.md index e066ab0..22ce87b 100644 --- a/CmdletHelp/Get-PCCustomerBillingProfile.md +++ b/CmdletHelp/Get-PCCustomerBillingProfile.md @@ -1,13 +1,53 @@ -# Get-PCCustomerBillingProfile # +# Get-PCCustomerBillingProfile -## Get a customer ## +Returns the specified customer's billing profile. + +## SYNTAX ```powershell - $customer = Get-PCCustomer -tenantid '' +Get-PCCustomerBillingProfile [[-TenantId] ] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCCustomerBillingProfile cmdlet returns the specified customer's billing profile. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. +``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false ``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. +``` +Required? false +Position? 2 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 -## Get customer billing profile ## +Get customer billing profile for the specified tenant. ```powershell - Get-PCCustomerBillingProfile -tenantid $customer.id + Get-PCCustomerBillingProfile -TenantId ``` diff --git a/CmdletHelp/Get-PCCustomerCompanyProfile.md b/CmdletHelp/Get-PCCustomerCompanyProfile.md index 571cdf5..c3b64dc 100644 --- a/CmdletHelp/Get-PCCustomerCompanyProfile.md +++ b/CmdletHelp/Get-PCCustomerCompanyProfile.md @@ -1,13 +1,59 @@ -# Get-PCCustomerCompanyProfile # +# Get-PCCustomerCompanyProfile -## Specify a customer ## +Returns the specified customer company profile. + +## SYNTAX + +```powershell +Get-PCCustomerCompanyProfile [[-TenantId] ] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCCustomerCompanyProfile cmdlet retrieves the specified customer company profile. + +## PARAMETERS + +### -TenantId <String> + +Specifies a tenant id to scope this cmdlet. +``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. +``` +Required? false +Position? 2 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Specify a customer ```powershell - $customer = Get-PCCustomer -tenantid '' + $customer = Get-PCCustomer -TenantId '' ``` -## Get customer company profile ## +Get customer company profile ```powershell - Get-PCCustomerCompanyProfile -tenantid $customer.id + Get-PCCustomerCompanyProfile -TenantId $customer.id ``` diff --git a/CmdletHelp/Get-PCCustomerLicenseDeployment.md b/CmdletHelp/Get-PCCustomerLicenseDeployment.md index d37ffe2..19ad97f 100644 --- a/CmdletHelp/Get-PCCustomerLicenseDeployment.md +++ b/CmdletHelp/Get-PCCustomerLicenseDeployment.md @@ -1,15 +1,69 @@ -# Get-PCCustomerLicenseDeployment # +# Get-PCCustomerLicenseDeployment + +Returns a list of licenses deployed by a partner for a specific tenant. + +## SYNTAX + +```powershell +Get-PCCustomerLicenseDeployment [[-TenantId] ] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCCustomerLicenseDeployment cmdlet retrieves a list of licenses deployed by a partner for a specific tenant. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant id. +``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. +``` +Required? false +Position? 2 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES This cmdlet requires App+User authentication -## Specify a customer ## +## EXAMPLES + +### EXAMPLE 1 + +Retrieve a list of deployed liceses for the specified tenant. + +```powershell +PS C:\>Get-PCCustomerLicenseDeployment -TenantId 97037612-799c-4fa6-8c40-68be72c6b83c +``` + +### EXAMPLE 2 + +Select a customer tenant ```powershell - $customer = Get-PCCustomer -tenantid '' + $customer = Get-PCCustomer -TenantId '' ``` -## Get customer licenses deployment information ## +Get customer license deployment information ```powershell - Get-PCCustomerLicenseDeployment -tenantid $customer.id + Get-PCCustomerLicenseDeployment -TenantId $customer.id ``` diff --git a/CmdletHelp/Get-PCCustomerLicenseUsage.md b/CmdletHelp/Get-PCCustomerLicenseUsage.md index c8e1c2b..8d40565 100644 --- a/CmdletHelp/Get-PCCustomerLicenseUsage.md +++ b/CmdletHelp/Get-PCCustomerLicenseUsage.md @@ -1,15 +1,57 @@ -# Get-PCCustomerLicenseUsage # +# Get-PCCustomerLicenseUsage -This cmdlet requires App+User authentication +Returns a list of licenses deployed and assigned by a partner for a specified tenant. -## Specify a customer ## +## SYNTAX ```powershell - $customer = Get-PCCustomer -tenantid '' +Get-PCCustomerLicenseUsage [[-TenantId] ] [[-SaToken] ] [] ``` -## Get customer license usage information ## +## DESCRIPTION + +The Get-PCCustomerLicenseUsage cmdlet retrieves a list of licenses deployed and assigned by a partner for a specified tenant. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant id. + +``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 2 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +This cmdlet requires App+User authentication. + +## EXAMPLES + +### EXAMPLE 1 + +Retrieve a list of assigned licenses for the specified tenant ```powershell - Get-PCCustomerLicenseUsage -tenantid $customer.id +PS C:\>Get-PCCustomerLicenseDeployment -TenantId '97037612-799c-4fa6-8c40-68be72c6b83c' ``` diff --git a/CmdletHelp/Get-PCCustomerLicensesDeployment.md b/CmdletHelp/Get-PCCustomerLicensesDeployment.md index eebb11c..dd087e3 100644 --- a/CmdletHelp/Get-PCCustomerLicensesDeployment.md +++ b/CmdletHelp/Get-PCCustomerLicensesDeployment.md @@ -5,11 +5,11 @@ ## Specify a customer ## ```powershell - $customer = Get-PCCustomer -tenantid '' + $customer = Get-PCCustomer -TenantId '' ``` ## Get customer licenses deployment information ## ```powershell - Get-PCCustomerLicensesDeployment -tenantid $customer.id + Get-PCCustomerLicensesDeployment -TenantId $customer.id ``` diff --git a/CmdletHelp/Get-PCCustomerLicensesUsage.md b/CmdletHelp/Get-PCCustomerLicensesUsage.md index bf43acb..ae5af14 100644 --- a/CmdletHelp/Get-PCCustomerLicensesUsage.md +++ b/CmdletHelp/Get-PCCustomerLicensesUsage.md @@ -5,11 +5,11 @@ ## Specify a customer ## ```powershell - $customer = Get-PCCustomer -tenantid '' + $customer = Get-PCCustomer -TenantId '' ``` ## Get customer licenses usage information ## ```powershell - Get-PCCustomerLicensesUsage -tenantid $customer.id + Get-PCCustomerLicensesUsage -TenantId $customer.id ``` diff --git a/CmdletHelp/Get-PCCustomerRelationship.md b/CmdletHelp/Get-PCCustomerRelationship.md index cadfe7b..117721e 100644 --- a/CmdletHelp/Get-PCCustomerRelationship.md +++ b/CmdletHelp/Get-PCCustomerRelationship.md @@ -1,13 +1,69 @@ -# Get-PCCustomerRelationship (indirect model only) # +# Get-PCCustomerRelationship -## Specify a customer ## +Returns the type of relationship the specified tenant has with the current partner. + +## SYNTAX + +```powershell +Get-PCCustomerRelationship [[-TenantId] ] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCCustomerRelationship cmdlet returns the relationship the specified customer has with the current partner. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + +``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 2 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +This cmdlet can only be used in an indirect model. + +## EXAMPLES + +### EXAMPLE 1 + +```powershell +PS C:\>Get-PCCustomerRelationship -TenantId 97037612-799c-4fa6-8c40-68be72c6b83c +``` + +### EXAMPLE 2 + +Specify a customer tenant. ```powershell - $customer = Get-PCCustomer -tenantid '' + $customer = Get-PCCustomer -TenantId '' ``` -## Get all customer subscriptions ## +Return the customer relationship. ```powershell - Get-PCCustomerRelationship -tenantid $customer.id + Get-PCCustomerRelationship -TenantId $customer.id ``` diff --git a/CmdletHelp/Get-PCCustomerRelationships.md b/CmdletHelp/Get-PCCustomerRelationships.md index 15b79a0..a5b5820 100644 --- a/CmdletHelp/Get-PCCustomerRelationships.md +++ b/CmdletHelp/Get-PCCustomerRelationships.md @@ -5,11 +5,11 @@ ## Specify a customer ## ```powershell - $customer = Get-PCCustomer -tenantid '' + $customer = Get-PCCustomer -TenantId '' ``` ## Get all customer subscriptions ## ```powershell - Get-PCCustomerRelationships -tenantid $customer.id + Get-PCCustomerRelationships -TenantId $customer.id ``` diff --git a/CmdletHelp/Get-PCCustomerRole.md b/CmdletHelp/Get-PCCustomerRole.md index 67f65e3..59063e5 100644 --- a/CmdletHelp/Get-PCCustomerRole.md +++ b/CmdletHelp/Get-PCCustomerRole.md @@ -1,13 +1,53 @@ -# Get-PCCustomerRole # +# Get-PCCustomerRole -## Specify a customer ## +Returns a list of customer roles for the specified tenant. + +## SYNTAX ```powershell - $customer = Get-PCCustomer -tenantid '' +Get-PCCustomerRole [[-TenantId] ] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCCustomerRole cmdlet returns a list of customer roles created for the specified tenant. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant id for which to return the customer roles. + +``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false ``` -## Get customer roles ## +### -SaToken <String> + +Specifies a security token for authenticating and executing the cmdlet. + +``` +Required? false +Position? 2 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 ```powershell - Get-PCCustomerRole -tenantid $customer.id +PS C:\>Get-PCCustomerRole -TenantId 45916f92-e9c3-4ed2-b8c2-d87aa129905f ``` diff --git a/CmdletHelp/Get-PCCustomerRoleMember.md b/CmdletHelp/Get-PCCustomerRoleMember.md index 6225934..64c61dc 100644 --- a/CmdletHelp/Get-PCCustomerRoleMember.md +++ b/CmdletHelp/Get-PCCustomerRoleMember.md @@ -1,19 +1,85 @@ -# Get-PCCustomerRoleMember # +# Get-PCCustomerRoleMember -## Specify a customer ## +Returns a list of members for the specified role. + +## SYNTAX + +```powershell +Get-PCCustomerRoleMember [-RoleId] [[-TenantId] ] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCCustomerRoleMember cmdlet returns a list of members for the specified role. + +## PARAMETERS + +### -RoleId <String> + +Specifies the role id. + +``` +Required? true +Position? 1 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + +``` +Required? false +Position? 2 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies a security token for authenticating and executing the cmdlet. + +``` +Required? false +Position? 3 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +```powershell +PS C:\>Get-PCCustomerRoleMember +``` + +### EXAMPLE 2 + +Specify a customer ```powershell - $customer = Get-PCCustomer -tenantid '' + $customer = Get-PCCustomer -TenantId '97037612-799c-4fa6-8c40-68be72c6b83c' ``` -## Get customer role ## +Get customer role ```powershell - $role = Get-PCCustomerRole -tenantid $customer.id | Where-Object Name -EQ '' + $role = Get-PCCustomerRole -TenantId $customer.id | Where-Object Name -EQ '' ``` -## Get customer user roles ## +Get customer user roles ```powershell - Get-PCCustomerRoleMember -tenantid $customer.id -roleid $role.id + Get-PCCustomerRoleMember -TenantId $customer.id -RoleId $role.id ``` diff --git a/CmdletHelp/Get-PCCustomerServiceCostSummary.md b/CmdletHelp/Get-PCCustomerServiceCostSummary.md index a01709e..3a86193 100644 --- a/CmdletHelp/Get-PCCustomerServiceCostSummary.md +++ b/CmdletHelp/Get-PCCustomerServiceCostSummary.md @@ -1,15 +1,72 @@ -# Get-PCCustomerServiceCostSummary # +# Get-PCCustomerServiceCostSummary -## Select a customer ## +Returns a cost summary for the specified billing period. + +## SYNTAX ```powershell - Select-PCCustomer -tenantid '' +Get-PCCustomerServiceCostSummary [-BillingPeriod] [[-TenantId] ] [[-SaToken] ] [] ``` -## Get customer Service Cost Summary ## +## DESCRIPTION + +The Get-PCCustomerServiceCostSummary returns a cost summary for the specified billing period. + +## PARAMETERS + +### -BillingPeriod <String> + +Specifies the billing period +``` +Required? true +Position? 1 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. +``` +Required? false +Position? 2 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. +``` +Required? false +Position? 3 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +Other BillingPeriod types may be available in a future release. + +## EXAMPLES + +### EXAMPLE 1 ```powershell - Get-PCCustomerServiceCostSummary -BillingPeriod MostRecent +PS C:\>Get-PCCustomerServiceCostSummary ``` - > Other BillingPeriod type will be available in a future release +### EXAMPLE 2 + +Get customer service cost summary + +```powershell + Get-PCCustomerServiceCostSummary -BillingPeriod MostRecent +``` diff --git a/CmdletHelp/Get-PCCustomerUsageSummary.md b/CmdletHelp/Get-PCCustomerUsageSummary.md index 9ba1fbf..615489c 100644 --- a/CmdletHelp/Get-PCCustomerUsageSummary.md +++ b/CmdletHelp/Get-PCCustomerUsageSummary.md @@ -1,13 +1,55 @@ -# Get-PCCustomerUsageSummary # +# Get-PCCustomerUsageSummary -## Select a customer ## +Returns aa summary of usage for the specified tenant. + +## SYNTAX ```powershell - Select-PCCustomer -tenantid '' +Get-PCCustomerUsageSummary [[-TenantId] ] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCCustomerUsageSummary cmdlet returns a summary of usage for the specified tenant. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + ``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token created with your Partner Center credentials. + +``` +Required? false +Position? 2 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 -## Get usage summary for all of a customer's subscriptions ## +Get the usage summary for all subscritions for the specified tenant id. ```powershell - Get-PCCustomerUsageSummary -tenantid $customer.id +PS C:\>Get-PCCustomerUsageSummary -TenantId 45916f92-e9c3-4ed2-b8c2-d87aa129905f ``` diff --git a/CmdletHelp/Get-PCCustomerUser.md b/CmdletHelp/Get-PCCustomerUser.md index a69e584..48be51a 100644 --- a/CmdletHelp/Get-PCCustomerUser.md +++ b/CmdletHelp/Get-PCCustomerUser.md @@ -1,25 +1,131 @@ -# Get-PCCustomerUser # +# Get-PCCustomerUser -## Get all customer users ## +Returns a list of all customer users or a specified user for the tenant. + +## SYNTAX + +```powershell +Get-PCCustomerUser [-TenantId ] [-SaToken ] [] + +Get-PCCustomerUser [-TenantId ] -Deleted [-ResultSize ] [-SaToken ] [] + +Get-PCCustomerUser [-TenantId ] -UserId [-Licenses] [-SaToken ] [] +``` + +## DESCRIPTION + +The Get-PCCustomerUser cmdlet returns either all users or a specified user from the tenant. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + +``` +Required? false +Position? named +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -UserId <String> + +Specifies the user id. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Licenses <SwitchParameter> + +Specifies whether to return the licenses assigned to the specified user. + +``` +Required? false +Position? named +Default value False +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Deleted <SwitchParameter> + +Specifies whether to return deleted users. + +``` +Required? true +Position? named +Default value False +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -ResultSize <Int32> + +Specifies the maximum number of results to return. The default value is 200. + +``` +Required? false +Position? named +Default value 200 +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? named +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Get all users for the specified tenant. ```powershell - Get-PCCustomerUser -tenantid $customer.id -all +PS C:\>Get-PCCustomerUser -TenantId 45916f92-e9c3-4ed2-b8c2-d87aa129905f ``` -## Get customer user ## +### EXAMPLE 2 + +Get a customer user ```powershell - $user = Get-PCCustomerUser -tenantid $customer.id -userid '' +PS C:\>$user = Get-PCCustomerUser -TenantId 45916f92-e9c3-4ed2-b8c2-d87aa129905f -userid 'e2e56b09-aac5-4685-947d-29e735ee7ed7' ``` -## Get customer user assigned licenses ## +### EXAMPLE 3 + +Get a list of user assigned licenses for the specified user id. ```powershell - Get-PCCustomerUser -tenantid $customer.id -userid $user.id -licenses +PS C:\>Get-PCCustomerUser -TenantId 45916f92-e9c3-4ed2-b8c2-d87aa129905f -UserId 'e2e56b09-aac5-4685-947d-29e735ee7ed7' -Licenses ``` -## Get customer deleted users ## +### EXAMPLE 4 + +Get a list of deleted users for the tenant ```powershell - Get-PCCustomerUser -tenantid $customer.id -deleted +PS C:\>Get-PCCustomerUser -TenantId 45916f92-e9c3-4ed2-b8c2-d87aa129905f -Deleted ``` diff --git a/CmdletHelp/Get-PCCustomerUserRole.md b/CmdletHelp/Get-PCCustomerUserRole.md index 5d9a944..75e1f8e 100644 --- a/CmdletHelp/Get-PCCustomerUserRole.md +++ b/CmdletHelp/Get-PCCustomerUserRole.md @@ -1,19 +1,75 @@ -# Get-PCCustomerUserRole # +# Get-PCCustomerUserRole -## Select a customer ## +Returns a list of customer user roles for the specified tenant. + +## SYNTAX ```powershell - Select-PCCustomer -tenantid '' +Get-PCCustomerUserRole [[-TenantId] ] [[-UserId] ] [[-SaToken] ] [] ``` -## Get customer user ## +## DESCRIPTION + +The Get-PCCustomerUserRoles cmdlet returns a list of roles for a specified tenant or user. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant is used for scoping this cmdlet. + +``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -UserId <String> + +Specifies the user id for which to retrieve the roles. + +``` +Required? false +Position? 2 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 3 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Get a list of all roles for the specified tenant. ```powershell - $user = Get-PCCustomerUser -tenantid $customer.id -userid '' +PS C:\>Get-PCCustomerUserRole -TenantId a7bc20f7-6041-4165-8bef-59d0e7e8d67b ``` -## Get customer user roles ## +### EXAMPLE 2 + +Get a list of all the roles for the specified tenant id and user id. ```powershell - Get-PCCustomerUserRole -tenantid $customer.id -user $user +PS C:\>Get-PCCustomerUserRole -TenantId a7bc20f7-6041-4165-8bef-59d0e7e8d67b -UserId e2e56b09-aac5-4685-947d-29e735ee7ed7 ``` diff --git a/CmdletHelp/Get-PCDomainAvailability.md b/CmdletHelp/Get-PCDomainAvailability.md index d365c27..904adb9 100644 --- a/CmdletHelp/Get-PCDomainAvailability.md +++ b/CmdletHelp/Get-PCDomainAvailability.md @@ -1,9 +1,55 @@ -# Get-PCDomainAvailability # +# Get-PCDomainAvailability -## Check if domain is available to use on new customer ## +Tests to see if the specified onmicrosoft.com is available to be used for a new tenant. + +## SYNTAX + +```powershell +Get-PCDomainAvailability [-Domain] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCDomainAvailability cmdlet tests to see if the specified tenant domain (onmicrosoft.com) is available to create a new tenant. + +## PARAMETERS + +### -Domain <String> + +Specifies an onmicrosoft.com domain to check as to whether is available for use for a new tenant. + +``` +Required? true +Position? 1 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies a security token for authenticating and executing the cmdlet. + +``` +Required? false +Position? 2 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Test to see if contoso.onmicrosoft.com is available for a new tenant. ```powershell - $domainname = '' - $domain = $domainname+'.onmicrosoft.com' - Get-PCDomainAvailability -domain $domain +PS C:\>Get-PCDomainAvailabilty -Domain contoso.onmicrosoft.com ``` diff --git a/CmdletHelp/Get-PCIndirectReseller.md b/CmdletHelp/Get-PCIndirectReseller.md index aca29ad..5be5a0b 100644 --- a/CmdletHelp/Get-PCIndirectReseller.md +++ b/CmdletHelp/Get-PCIndirectReseller.md @@ -1,7 +1,43 @@ -# Get-PCIndirectReseller (indirect model only) # +# Get-PCIndirectReseller (indirect model only) -## Get all indirect resellers ## +Returns a list of indirect resellers. This only works for a partner that is an indirect provider. + +## SYNTAX + +```powershell +Get-PCIndirectReseller [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCIndirectReseller cmdlet returns a list of indirect resellers. + +## PARAMETERS + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 1 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +This cmdlet is only intended to work for the indirect model. + +## EXAMPLES + +### EXAMPLE 1 ```powershell - Get-PCIndirectReseller +PS C:\>Get-PCIndirectReseller ``` diff --git a/CmdletHelp/Get-PCInvoice.md b/CmdletHelp/Get-PCInvoice.md index ee64841..800e61e 100644 --- a/CmdletHelp/Get-PCInvoice.md +++ b/CmdletHelp/Get-PCInvoice.md @@ -1,19 +1,85 @@ -# Get-PCInvoice # +# Get-PCInvoice -## Get current payable amount ## +Returns all invoices or the specified invoice. + +## SYNTAX ```powershell - Get-PCInvoice -summary +Get-PCInvoice [[-InvoiceId] ] [-Summary] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCInvoice cmdlet retrieves either a specific invoice or a list of invoices. This cmdlet requires App+User authentication. + +## PARAMETERS + +### -InvoiceId <String> + +Specifies an invoice id to return. + +``` +Required? false +Position? 1 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Summary <SwitchParameter> + +Specifies whether to retrieve a summary of the invoice. + +``` +Required? false +Position? named +Default value False +Accept pipeline input? false +Accept wildcard characters? false ``` -## Get all invoices ## +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 2 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +This cmdlet requires App+User authentication. + +## EXAMPLES + +### EXAMPLE 1 + +Return all invoices. ```powershell - Get-PCInvoice -all +PS C:\>Get-PCInvoice ``` -## Get an invoice ## +### EXAMPLE 2 + +Return the specified invoice + +```powershell +PS C:\>$invoice = Get-PCInvoice -InvoiceId D030001IZ6 +``` + +### EXAMPLE 3 + +Return a summary of the specified invoice ```powershell - $invoice = Get-PCInvoice -invoiceid '' +PS C:\>$invoice = Get-PCInvoice -InvoiceId D030001IZ6 -Summary ``` diff --git a/CmdletHelp/Get-PCInvoiceLineItem.md b/CmdletHelp/Get-PCInvoiceLineItem.md index 5bcc999..58dbb70 100644 --- a/CmdletHelp/Get-PCInvoiceLineItem.md +++ b/CmdletHelp/Get-PCInvoiceLineItem.md @@ -1,13 +1,103 @@ -# Get-PCInvoiceLineItem # +# Get-PCInvoiceLineItem -## Get an invoice ## +Returns a specified invoice line item. This requires App+User authentication. + +## SYNTAX ```powershell - $invoice = Get-PCInvoice -invoiceid '' +Get-PCInvoiceLineItem [-InvoiceId] [-BillingProvider] [-InvoiceLineItemType] [[-ResultSize] ] [[-Offset] ] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCInvoiceLineItem cmdlet. + +## PARAMETERS + +### -InvoiceId <String> + +Specifies the invoice id to retrieve. + +``` +Required? true +Position? 1 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -BillingProvider <String> + +Specifies either Azure or Office. + +``` +Required? true +Position? 2 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -InvoiceLineItemType <String> + +Specifies either BillingLineItems for invoiced licence-based services or UsageLineItems for invoiced usage-based services. + ``` +Required? true +Position? 3 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -ResultSize <Int32> + +Specifies the maximum number of results to return. The default value is 200. + +``` +Required? false +Position? 4 +Default value 200 +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Offset <Int32> + +Specifies an offset + +``` +Required? false +Position? 5 +Default value 0 +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 6 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 -## Get an invoice line item ## +Retrieve a list of Azure usage from invoice D030001IZ6. ```powershell - Get-PCInvoiceLineItem -invoiceid $invoice.id -billingprovider '' -invoicelineitemtype '' +PS C:\>Get-PCInvoiceLineItem -InvoceId D030001IZ6 -BillingProvider Azure -InvoiceLineItemType UsageLineItems ``` diff --git a/CmdletHelp/Get-PCInvoiceLineItems.md b/CmdletHelp/Get-PCInvoiceLineItems.md index 8ccfc13..ecf3383 100644 --- a/CmdletHelp/Get-PCInvoiceLineItems.md +++ b/CmdletHelp/Get-PCInvoiceLineItems.md @@ -1,15 +1,17 @@ # Get-PCInvoiceLineItems # +This cmdlet requires App+User authentication. + ## Deprecated: Use Get-PCInvoiceLineItem instead ## ## Get an invoice ## ```powershell - $invoice = Get-PCInvoice -invoiceid '' + $invoice = Get-PCInvoice -invoiceId '' ``` ## Get an invoice line item ## ```powershell - Get-PCInvoiceLineItems -invoiceid $invoice.id -billingprovider '' -invoicelineitemtype '' + Get-PCInvoiceLineItems -invoiceId $invoice.id -billingProvider '' -invoicelineitemtype '' ``` diff --git a/CmdletHelp/Get-PCLegalBusinessProfile.md b/CmdletHelp/Get-PCLegalBusinessProfile.md index 302fd50..b24281d 100644 --- a/CmdletHelp/Get-PCLegalBusinessProfile.md +++ b/CmdletHelp/Get-PCLegalBusinessProfile.md @@ -1,7 +1,41 @@ -# Get-PCLegalBusinessProfile # +# Get-PCLegalBusinessProfile -## Get Partner Legal Business Profile ## +Returns the legal business profile for the partner. + +## SYNTAX + +```powershell +Get-PCLegalBusinessProfile [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCLegalBusinessProfile cmdlet retrieves the partner's legal business profile. + +## PARAMETERS + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 1 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 ```powershell - Get-PCLegalBusinessProfile +PS C:\>Get-PCLegalBusinessProfile ``` diff --git a/CmdletHelp/Get-PCLicenseDeployment.md b/CmdletHelp/Get-PCLicenseDeployment.md index ee6b687..ca59944 100644 --- a/CmdletHelp/Get-PCLicenseDeployment.md +++ b/CmdletHelp/Get-PCLicenseDeployment.md @@ -1,7 +1,45 @@ -# Get-PCLicenseDeployment # +# Get-PCLicenseDeployment -## Get partner license deployment information ## +Returns a list of licenses for the authenticated partner. + +## SYNTAX + +```powershell +Get-PCLicenseDeployment [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCLicenseDeployment cmdlet retrieves a list of licenses for the authenticated partner. + +## PARAMETERS + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 1 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +You need to have a credential before running this cmdlet. + +## EXAMPLES + +### EXAMPLE 1 + +Return a list of assigned licenses for the authenticated partner. ```powershell - Get-PCLicenseDeployment +PS C:\>Get-PCLicenseDeployment ``` diff --git a/CmdletHelp/Get-PCLicenseUsage.md b/CmdletHelp/Get-PCLicenseUsage.md index 3ac29cf..4bb4168 100644 --- a/CmdletHelp/Get-PCLicenseUsage.md +++ b/CmdletHelp/Get-PCLicenseUsage.md @@ -1,7 +1,45 @@ -# Get-PCLicenseUsage # +# Get-PCLicenseUsage -## Get partner license usage information ## +Retrieves a list of licenses being used for the partner account. + +## SYNTAX + +```powershell +Get-PCLicenseUsage [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCLicenseUsage cmdlet retrieves a list of licenses assigned for the authenticated partner. + +## PARAMETERS + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 1 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +You need to have a authentication Credential already established before running this cmdlet. + +## EXAMPLES + +### EXAMPLE 1 + +Return a list of assigned licenses for the authenticated partner. ```powershell - Get-PCLicenseUsage +PS C:\>Get-PCLicenseUsage ``` diff --git a/CmdletHelp/Get-PCManagedService.md b/CmdletHelp/Get-PCManagedService.md index 84251eb..7a2c3c8 100644 --- a/CmdletHelp/Get-PCManagedService.md +++ b/CmdletHelp/Get-PCManagedService.md @@ -1,13 +1,55 @@ -# Get-PCManagedService # +# Get-PCManagedService -## Select a customer ## +Returns a list of managed services + +## SYNTAX ```powershell - Select-PCCustomer -tenantid '' +Get-PCManagedService [[-TenantId] ] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCManagedService + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + ``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 2 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 -## Get all managed services for specified customer ## +Return a list of managed services for the specified tenant. ```powershell - Get-PCManagedService -tenantid $customer.id +PS C:\>Get-PCManagedService -TenantId 97037612-799c-4fa6-8c40-68be72c6b83c ``` diff --git a/CmdletHelp/Get-PCManagedServices.md b/CmdletHelp/Get-PCManagedServices.md index 7509e7c..d11f3d5 100644 --- a/CmdletHelp/Get-PCManagedServices.md +++ b/CmdletHelp/Get-PCManagedServices.md @@ -5,11 +5,11 @@ ## Select a customer ## ```powershell - Select-PCCustomer -tenantid '' + Select-PCCustomer -TenantId '' ``` ## Get all managed services for customer ## ```powershell - Get-PCManagedServices -tenantid $customer.id + Get-PCManagedServices -TenantId $customer.id ``` diff --git a/CmdletHelp/Get-PCMpnProfile.md b/CmdletHelp/Get-PCMpnProfile.md index 14d8eea..fdb1862 100644 --- a/CmdletHelp/Get-PCMpnProfile.md +++ b/CmdletHelp/Get-PCMpnProfile.md @@ -1,13 +1,55 @@ -# Get-PCMpnProfile # +# Get-PCMpnProfile -## Get Partner MPN Profile ## +Returns the Mpn profile for the authenticated partner. + +## SYNTAX ```powershell - Get-PCMpnProfile +Get-PCMpnProfile [[-MpnId] ] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCMpnProfile cmdlet returns the Mpn profile for the authenticated partner or the specified tenant. + +## PARAMETERS + +### -MpnId <String> + +Specifies the MPN id used to scope this cmdlet. + ``` +Required? false +Position? 1 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 2 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 -## Get a Partner MPN Profile by MPNID ## +Return the Mpn profile for the current partner. ```powershell - Get-PCMpnProfile -mpnid +PS C:\>Get-PCMpnProfile ``` diff --git a/CmdletHelp/Get-PCOffer.md b/CmdletHelp/Get-PCOffer.md index 59a5f1b..1d38a4f 100644 --- a/CmdletHelp/Get-PCOffer.md +++ b/CmdletHelp/Get-PCOffer.md @@ -1,25 +1,115 @@ -# Get-PCOffer # +# Get-PCOffer -## Get all offer details for countryId ## +Returns a list of offers based on the specified country id. + +## SYNTAX ```powershell - Get-PCOffer -countryId '' +Get-PCOffer [-CountryId] [[-OfferId] ] [[-LocaleId] ] [-AddOns] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCOffer cmdlet retrieves a list of offers based on the specified country id + +## PARAMETERS + +### -CountryId <String> + +Specifies a two letter country id + ``` +Required? true +Position? 1 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -OfferId <String> -## Get a specific offer ## +Specifies the offer id to return. + +``` +Required? false +Position? 2 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -LocaleId <String> + +Specifies a locale as the language and country code. For example, English in the United States is en-us + +``` +Required? false +Position? 3 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -AddOns <SwitchParameter> + +Specifies add on skus + +``` +Required? false +Position? named +Default value False +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token you have created with your Partner Center credentials. + +``` +Required? false +Position? 4 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Get all offer details for the US Country Id ```powershell - Get-PCOffer -countryId '' -offerId '' +PS C:\>Get-PCOffer ``` -## Get all offer details for countryId and localeId ## +### EXAMPLE 2 + +Get a specific offer using the offer id and country. ```powershell - Get-PCOffer -countryId '' -localeId '' + Get-PCOffer -CountryId 'US' ``` -## Get addons for a specific offer ## +### EXAMPLE 3 + +Get all offer details using the Country Id and Locale Id. + +```powershell + Get-PCOffer -CountryId 'US' -localeId 'en-us' +``` + +### EXAMPLES 4 + +Get add ons for the specified offer id. ```powershell - Get-PCOffer -countryId '' -offerId '' -addOns + Get-PCOffer -CountryId 'US' -OfferId '8AA7E78B-B265-4AC6-ADA0-14900A8A3F94' -addOns ``` diff --git a/CmdletHelp/Get-PCOfferCategoriesByMarket.md b/CmdletHelp/Get-PCOfferCategoriesByMarket.md index 8322c41..01964f8 100644 --- a/CmdletHelp/Get-PCOfferCategoriesByMarket.md +++ b/CmdletHelp/Get-PCOfferCategoriesByMarket.md @@ -1,7 +1,53 @@ -# Get-PCOfferCategoriesByMarket # +# Get-PCOfferCategoriesByMarket -## Get all Offers Categories for countryid ## +Returns a list of offer categories based on the country id specified. + +## SYNTAX + +```powershell +Get-PCOfferCategoriesByMarket [[-CountryId] ] [-SaToken] [] +``` + +## DESCRIPTION + +The Get-PCOfferCategoriesByMarket cmdlet returns a list of offer categories based on the country id specified. + +## PARAMETERS + +### -CountryId <Object> + +Specifies a two-character ISO 2 country code. + +``` +Required? false +Position? 1 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token you created with your Partner Center credentials. + +``` +Required? true +Position? 2 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 ```powershell - Get-PCOfferCategoriesByMarket -countryid '' +PS C:\>Get-PCOfferCategoriesByMarket -CountryId US ``` diff --git a/CmdletHelp/Get-PCOrder.md b/CmdletHelp/Get-PCOrder.md index fa166ad..141a060 100644 --- a/CmdletHelp/Get-PCOrder.md +++ b/CmdletHelp/Get-PCOrder.md @@ -1,19 +1,75 @@ -# Get-PCOrder # +# Get-PCOrder -## Select a customer ## +Returns a list of orders or a specified order. + +## SYNTAX ```powershell - Select-PCCustomer -tenantid '' +Get-PCOrder [[-TenantId] ] [[-OrderId] ] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCOrder cmdlet returns a list of orders for the specified tenant. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + +``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -OrderId <String> + +Specifies the order id for which to return information. + +``` +Required? false +Position? 2 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 3 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false ``` -## Get customer orders ## +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Return all orders for the specified customer tenant. ```powershell - Get-PCOrder -tenantid $customer.id + Get-PCOrder -TenantId 3c762ceb-b839-4b4a-85d8-0e7304c89f62 ``` -## Get a customer order ## +### EXAMPLE 2 + +Get the specified customer order ```powershell - Get-PCOrder -tenantid $customer.id -orderid '' + Get-PCOrder -TenantId -TenantId '3c762ceb-b839-4b4a-85d8-0e7304c89f62' -OrderId '1168c0f1-f0ed-4f9a-9e8c-1dcac072cba8' ``` diff --git a/CmdletHelp/Get-PCOrganizationProfile.md b/CmdletHelp/Get-PCOrganizationProfile.md index 5f52a2d..b3ea043 100644 --- a/CmdletHelp/Get-PCOrganizationProfile.md +++ b/CmdletHelp/Get-PCOrganizationProfile.md @@ -1,7 +1,41 @@ -# Get-PCOrganizationProfile # +# Get-PCOrganizationProfile -## Get Partner Organization Profile ## +Returns the partner's organization profile. + +## SYNTAX + +```powershell +Get-PCOrganizationProfile [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCOrganizationProfile cmdlet retrieves the partner's organization profile. + +## PARAMETERS + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 1 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 ```powershell - Get-PCOrganizationProfile +PS C:\>Get-PCOrganizationProfile ``` diff --git a/CmdletHelp/Get-PCResellerCustomer.md b/CmdletHelp/Get-PCResellerCustomer.md index 865ef02..facc3d8 100644 --- a/CmdletHelp/Get-PCResellerCustomer.md +++ b/CmdletHelp/Get-PCResellerCustomer.md @@ -1,7 +1,67 @@ -# Get-PCResellerCustomer (indirect model only) # +# Get-PCResellerCustomer -## Get all indirect resellers ## +Returns a list of reseller customers for the specified indirect provider. + +## SYNTAX ```powershell - Get-PCResellerCustomer -resellerId '' +Get-PCResellerCustomer -ResellerId [-ResultSize ] [-SaToken ] [] +``` + +## DESCRIPTION + +The Get-PCResllerCustomer cmdlet returns a list of reseller customers or a speficied reseller for the current indirect provider. + +## PARAMETERS + +### -ResellerId <String> + +Specifies the reseller id for which to return customers. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -ResultSize <Int32> + +Specifies the maximum number of results to return. The default value is 200. + +``` +Required? false +Position? named +Default value 200 +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? named +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +```powershell +PS C:\>Get-PCResellerCustomer -ResellerId '86f61a80-23de-4071-ba9f-249254da7e95' + +Return a list of customers for the specified reseller id ``` diff --git a/CmdletHelp/Get-PCSR.md b/CmdletHelp/Get-PCSR.md index c018f5e..0ade3e2 100644 --- a/CmdletHelp/Get-PCSR.md +++ b/CmdletHelp/Get-PCSR.md @@ -1,19 +1,87 @@ -# Get-PCSR # +# Get-PCSR -## Get all service requests ## +Returns a list of service requests or a specified service request. + +## SYNTAX + +```powershell +Get-PCSR [-TenantId ] [-SaToken ] [] + +Get-PCSR [-ServiceRequestId ] [-SaToken ] [] +``` + +## DESCRIPTION + +The Get-PCSR cmdlet retrieves a list of service requests or a specified service request. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -ServiceRequestId <String> + +Specifies a service request id. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? named +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +The -All parameter has been removed in this version. + +## EXAMPLES + +### EXAMPLE 1 + +Get all service requests. ```powershell - Get-PCSR -all +PS C:\>Get-PCSR ``` -## Get a specific service request ## +### EXAMPLE 2 + +Get a specific service request ```powershell - Get-PCSR -srid '' + Get-PCSR -ServiceRequestId '' ``` -## Get all customer service requests ## +### EXAMPLE 3 + +Get all customer service requests for the specified tenant id. ```powershell - Get-PCSR -tenantid '' + Get-PCSR -TenantId 'e974093c-2a52-4ebd-994e-b3e7e0f90cf2' ``` diff --git a/CmdletHelp/Get-PCSRTopic.md b/CmdletHelp/Get-PCSRTopic.md index 322f1e6..7dcf6df 100644 --- a/CmdletHelp/Get-PCSRTopic.md +++ b/CmdletHelp/Get-PCSRTopic.md @@ -1,9 +1,41 @@ -# Get-PCSRTopic # +# Get-PCSRTopic -This cmdlet requires App+User authentication +Returns a list of service request topics. -## Get all topics available for Service Requests ## +## SYNTAX ```powershell - Get-PCSRTopic +Get-PCSRTopic [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCSRTopic cmdlet retrieves a list of service request topics. + +## PARAMETERS + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 1 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +```powershell +PS C:\>Get-PCSRTopic ``` diff --git a/CmdletHelp/Get-PCSRTopics.md b/CmdletHelp/Get-PCSRTopics.md index f76e655..b77f2cf 100644 --- a/CmdletHelp/Get-PCSRTopics.md +++ b/CmdletHelp/Get-PCSRTopics.md @@ -1,5 +1,7 @@ # Get-PCSRTopics # +This cmdlet requires App+User authentication. + ## Deprecated: Use Get-PCSRTopic instead ## ## Get all topics available for Service Requests ## diff --git a/CmdletHelp/Get-PCSpendingBudget.md b/CmdletHelp/Get-PCSpendingBudget.md new file mode 100644 index 0000000..4ea9916 Binary files /dev/null and b/CmdletHelp/Get-PCSpendingBudget.md differ diff --git a/CmdletHelp/Get-PCSubscribedSKU.md b/CmdletHelp/Get-PCSubscribedSKU.md index 974b761..5e9be65 100644 --- a/CmdletHelp/Get-PCSubscribedSKU.md +++ b/CmdletHelp/Get-PCSubscribedSKU.md @@ -1,13 +1,55 @@ -# Get-PCSubscribedSKU # +# Get-PCSubscribedSKU -## Specify a customer ## +Returns a list of subscribed SKUs for the specified tenant. + +## SYNTAX ```powershell - $customer = Get-PCCustomer -tenantid '' +Get-PCSubscribedSKU [[-TenantId] ] [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-SusbscribedSKU cmdlet retrieves a list of subscribed SKUs. + +## PARAMETERS + +### -TenantId <String> + +The tenant Id assigned to the customer you want to retrieve. + ``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 2 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 -## Get a list of available licenses ## +Return the subscribed SKUs for the specified Tenant Id ```powershell - Get-PCSubscribedSKU -tenantid $customer.id +PS C:\>Get-SubscribedSKU -TenantId '97037612-799c-4fa6-8c40-68be72c6b83c' ``` diff --git a/CmdletHelp/Get-PCSubscribedSKUs.md b/CmdletHelp/Get-PCSubscribedSKUs.md index 685b8a7..8237db6 100644 --- a/CmdletHelp/Get-PCSubscribedSKUs.md +++ b/CmdletHelp/Get-PCSubscribedSKUs.md @@ -5,11 +5,11 @@ ## Specify a customer ## ```powershell - $customer = Get-PCCustomer -tenantid '' + $customer = Get-PCCustomer -TenantId '' ``` ## Get a list of available licenses ## ```powershell - Get-PCSubscribedSKUs -tenantid $customer.id + Get-PCSubscribedSKUs -TenantId $customer.id ``` diff --git a/CmdletHelp/Get-PCSubscription.md b/CmdletHelp/Get-PCSubscription.md index c2add5b..9d87ed6 100644 --- a/CmdletHelp/Get-PCSubscription.md +++ b/CmdletHelp/Get-PCSubscription.md @@ -1,31 +1,143 @@ -# Get-PCSubscription # +# Get-PCSubscription -## Get a customer ## +Returns a list of subscriptions for the specified tenant. + +## SYNTAX ```powershell - $customer = Get-PCCustomer -tenantid '' +Get-PCSubscription [-TenantId ] [-SaToken ] [-SubscriptionId ] [-AddOns] [] + +Get-PCSubscription [-TenantId ] [-SaToken ] -PartnerId [-ResultSize ] [] + +Get-PCSubscription [-TenantId ] [-SaToken ] [-OrderId ] [] ``` -## Get all customer subscriptions ## +## DESCRIPTION + +The Get-PCSubscription cmdlet returns a list of subscriptions for a specified customer tenant or MPN partner id. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. The tenant must be specified either using this parameter or by using the Select-PCCustomer cmdlet. + +``` +Required? false +Position? named +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? named +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SubscriptionId <String> + +Specifies a subscription id for which to return detailed information. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -AddOns <SwitchParameter> + +Specifies whether you want to return any addons for the subscription. + +``` +Required? false +Position? named +Default value False +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -PartnerId <String> + +Specifies the Mpn partner id for which to list the subscriptions. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -ResultSize <Int32> + +Specifies the maximum number of results to return. The default value is 200. + +``` +Required? false +Position? named +Default value 200 +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -OrderId <String> + +Specifies an order id to for which to return a list of subscriptions. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Return a list of all subscriptions for the specified partner id ```powershell - Get-PCSubscription -tenantid $customer.id -all +PS C:\>Get-PCSubscription -PartnerId '46662300' ``` -## Get a customer subscription ## +### EXAMPLE 2 + +Return information about the specified subscription. ```powershell - Get-PCSubscription -tenantid $customer.id -subscriptionid '' +PS C:\>Get-PCSubscription -TenantId 99ed2a33-e3ea-34df-bade-30997e2413e5 -SubscriptionId 335c4cad-b235-4a31-8273-e73da43e7817 ``` -## Get all customer subscriptions from an order ## +### EXAMPLE 3 + +Return a list of subscriptions from an order. ```powershell - Get-PCSubscription -tenantid $customer.id -orderid '' +PS C:\>Get-PCSubscription -TenantId 99ed2a33-e3ea-34df-bade-30997e2413e5 -OrderId 335c4cad-b235-4a31-8273-e73da43e7817 ``` -## Get all customer subscriptions from a reseller (available only for Distributor CSP Account) ## +### EXAMPLE 4 + +Return a list of customer subscriptions from a reseller (Only available in an Indirect Provider tenant) ```powershell - Get-PCSubscription -tenantid $customer.id -partnerid '' +PS C:\>Get-PCSubscription -TenantId 99ed2a33-e3ea-34df-bade-30997e2413e5 -PartnerId '46662300' ``` diff --git a/CmdletHelp/Get-PCSubscriptionMonthlyUsageRecords.md b/CmdletHelp/Get-PCSubscriptionMonthlyUsageRecords.md index b844132..1284709 100644 --- a/CmdletHelp/Get-PCSubscriptionMonthlyUsageRecords.md +++ b/CmdletHelp/Get-PCSubscriptionMonthlyUsageRecords.md @@ -3,11 +3,11 @@ ## Get a customer ## ```powershell - $customer = Get-PCCustomer -tenantid '' + $customer = Get-PCCustomer -TenantId '' ``` ## Get usage data for subscriptions ## ```powershell - Get-PCSubscriptionMonthlyUsageRecords -tenantid $customer.id + Get-PCSubscriptionMonthlyUsageRecords -TenantId $customer.id ``` diff --git a/CmdletHelp/Get-PCSupportProfile.md b/CmdletHelp/Get-PCSupportProfile.md index d8add24..45419a2 100644 --- a/CmdletHelp/Get-PCSupportProfile.md +++ b/CmdletHelp/Get-PCSupportProfile.md @@ -1,7 +1,41 @@ -# Get-PCSupportProfile # +# Get-PCSupportProfile -## Get Partner Support Profile ## +Return the partner's support profile. + +## SYNTAX + +```powershell +Get-PCSupportProfile [[-SaToken] ] [] +``` + +## DESCRIPTION + +The Get-PCSupportProfile cmdlet returns the partner's support profile. + +## PARAMETERS + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 1 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 ```powershell - Get-PCSupportProfile +PS C:\>Get-PCSupportProfile ``` diff --git a/CmdletHelp/Get-PCUsage.md b/CmdletHelp/Get-PCUsage.md index a4c4404..c7f538e 100644 --- a/CmdletHelp/Get-PCUsage.md +++ b/CmdletHelp/Get-PCUsage.md @@ -1,19 +1,127 @@ -# Get-PCUsage # +# Get-PCUsage -## Get a customer ## +Retrieve a collection of usage records for the specified date range. Usage records are only available for the last 90 days. + +## SYNTAX ```powershell - Select-PCCustomer -tenantid '' +Get-PCUsage -SubscriptionId -StartTime -EndTime [-Granularity ] [-ShowDetail ] [-ResultSize ] [-TenantId ] [-SaToken ] [] ``` -## Get a subscription ## +## DESCRIPTION -```powershell - Get-PCSubscription -all +The Get-PCUsage cmdlet returns the usage records specified by the start and end times. + +## PARAMETERS + +### -SubscriptionId <String> + +Specifies a subscription if for which to return usage information. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -StartTime <String> + +Specifies the start time for which to retrieve usage information. Usage is only available for the last 90 days, therefore this value cannot be more than 90 days from the current date. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false ``` -## Gets the utilization records of a customer's Azure subscription for a specified period ## +### -EndTime <String> + +Specifies the end time for which to retrieve usage information. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Granularity <String> + +Specifies the granularity of the data to return. Valid values are: daily or hourly. The default value is daily. + +``` +Required? false +Position? named +Default value daily +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -ShowDetail <Boolean> + +Default this is set to $true. If set to $true, the utilization records will be split by the resource instance levels. If set to false, the utilization records will be aggregated on the resource level. + +``` +Required? false +Position? named +Default value True +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -ResultSize <Int32> + +Specifies the maximum number of results to return. The default value and the maximum value is 1000. To retrieve more than 1000 records you must use the continuation link. + +``` +Required? false +Position? named +Default value 1000 +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + +``` +Required? false +Position? named +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies a authentication token you have created with your Partner Center credentials. + +``` +Required? false +Position? named +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Return up to 2000 hourly usage records for the specified date range. ```powershell - Get-PCUsage -subscriptionid $subscription.id -start_time "01-12-1999 00:00:00" -end_time "12-31-1999 00:00:00" -granularity {daily | hourly}-show_details -size +PS C:\>Get-PCUsage -TenantId 2a14b164-f983-4048-92e1-4f9591b87445 -SubscriptionId b027a4b3-5487-413b-aa48-ec8733c874d6 -StartTime '06-12-2018 00:00:00' -EndTime '06-31-2018 23:59:59' -Granularity hourly -ResultSize 2000 ``` diff --git a/CmdletHelp/Get-PCUsage2.md b/CmdletHelp/Get-PCUsage2.md deleted file mode 100644 index dab472a..0000000 --- a/CmdletHelp/Get-PCUsage2.md +++ /dev/null @@ -1,26 +0,0 @@ -# Get-PCUsage # - -## Get a customer ## - -```powershell - Select-PCCustomer -tenantid '' -``` - -## Get a subscription ## - -```powershell - Get-PCSubscription -all -``` - -## Gets first page of utilization records of a customer's Azure subscription for a specified period ## - -```powershell - $usageData = Get-PCUsage2 -subscriptionid $subscription.id -start_time "01-12-1999 00:00:00" -end_time "31-12-1999 00:00:00" -granularity {daily | hourly}-show_details -size -``` - -## Gets the next page of utilization records of a customer's Azure subscription for a specified period ## - -```powershell - # Check the Links data includes a 'next' member - $usageData = Get-PCUsage2 -continuationLink $usageData.Links -``` diff --git a/CmdletHelp/New-PCAddress.md b/CmdletHelp/New-PCAddress.md new file mode 100644 index 0000000..c85708d Binary files /dev/null and b/CmdletHelp/New-PCAddress.md differ diff --git a/CmdletHelp/New-PCCustomer.md b/CmdletHelp/New-PCCustomer.md index af9616b..7c468e9 100644 --- a/CmdletHelp/New-PCCustomer.md +++ b/CmdletHelp/New-PCCustomer.md @@ -1,13 +1,240 @@ -# New-PCCustomer # +# New-PCCustomer -## Create a new customer ## +Creates a new customer. + +## SYNTAX ```powershell - $newDefaultAddress = New-PCCustomerDefaultAddress -Country '' -Region '' -City '' -State '' -AddressLine1 '' -PostalCode '' -FirstName '' -LastName '' -PhoneNumber '' +New-PCCustomer -Email -Culture -Language -CompanyName -Country -Region -City -State -AddressLine1 -PostalCode -FirstName -LastName -PhoneNumber -Domain [-SaToken ] [] + +New-PCCustomer -BillingProfile -CompanyProfile [-SaToken ] [] +``` + +## DESCRIPTION + +The New-PCCustomer cmdlet creates a new customer for the current partner. + +## PARAMETERS + +### -Email <String> + +Specifies the contact email address for the new customer. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Culture <String> + +Specifies the culture for the new customer as an three letter ISO 3 country code. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Language <String> + +Specifies the default language for the new customer. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -CompanyName <String> + +Specifies the company name for the new customer. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Country <String> + +Specifies the country name for the new customer. The country must be valid for the current partner. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Region <String> + +Specifies the region for the new customer. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` - $newBillingProfile = New-PCCustomerBillingProfile -FirstName '' -LastName '' -Email '' -Culture '' -Language '' -CompanyName '' -DefaultAddress $newDefaultAddress +### -City <String> - $newCompanyProfile = New-PCCustomerCompanyProfile -Domain '.onmicrosoft.com' +Specifies the city address for the new customer. - $newCustomer = New-PCCustomer -BillingProfile $newBillingProfile -CompanyProfile $newCompanyProfile +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -State <String> + +Specifies the state address for the new customer. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -AddressLine1 <String> + +Specifies the first line of the address for the new customer. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -PostalCode <String> + +Specifies the postal code, if needed, for the new customer. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -FirstName <String> + +Specifies the the new customer's contact's first name. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -LastName <String> + +Specifies the the new customer's contact's last name. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -PhoneNumber <String> + +Specifies the the new customer's contact's phone number. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Domain <String> + +Specifies the onmicrosoft.com for the new customer tenant. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -BillingProfile <BillingProfile> + +Specifies the billing profile. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -CompanyProfile <CompanyProfile> + +Specifies a company profile. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? named +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Create a new customer. + +```powershell +$newDefaultAddress = New-PCCustomerDefaultAddress -Country '' -Region '' -City '' -State '' -AddressLine1 '' -PostalCode '' -FirstName '' -LastName '' -PhoneNumber '' +$newBillingProfile = New-PCCustomerBillingProfile -FirstName '' -LastName '' -Email '' -Culture '' -Language '' -CompanyName '' -DefaultAddress $newDefaultAddress +$newCompanyProfile = New-PCCustomerCompanyProfile -Domain '.onmicrosoft.com' +$newCustomer = New-PCCustomer -BillingProfile $newBillingProfile -CompanyProfile $newCompanyProfile ``` diff --git a/CmdletHelp/New-PCCustomerBillingProfile.md b/CmdletHelp/New-PCCustomerBillingProfile.md new file mode 100644 index 0000000..2bab5bb Binary files /dev/null and b/CmdletHelp/New-PCCustomerBillingProfile.md differ diff --git a/CmdletHelp/New-PCCustomerCompanyProfile.md b/CmdletHelp/New-PCCustomerCompanyProfile.md new file mode 100644 index 0000000..d7583d8 Binary files /dev/null and b/CmdletHelp/New-PCCustomerCompanyProfile.md differ diff --git a/CmdletHelp/New-PCCustomerDefaultAddress.md b/CmdletHelp/New-PCCustomerDefaultAddress.md new file mode 100644 index 0000000..691f0f2 Binary files /dev/null and b/CmdletHelp/New-PCCustomerDefaultAddress.md differ diff --git a/CmdletHelp/New-PCCustomerUser.md b/CmdletHelp/New-PCCustomerUser.md index 05496e9..6876834 100644 --- a/CmdletHelp/New-PCCustomerUser.md +++ b/CmdletHelp/New-PCCustomerUser.md @@ -1,16 +1,137 @@ -# New-PCCustomerUser # +# New-PCCustomerUser -## Get a customer ## +Creates a new user in the specified customer Azure Active Directory tenant. + +## SYNTAX ```powershell - $customer = Get-PCCustomer -tenantid '' +New-PCCustomerUser [-TenantId ] -UsageLocation -UserPrincipalName -FirstName -LastName -DisplayName -Password -ForceChangePassword [-SaToken ] [] ``` -## Create a customer user ## +## DESCRIPTION -```powershell - $password = '' - $passwordSecure = $password | ConvertTo-SecureString -AsPlainText -Force +The New-PCCustomerUser cmdlet creates a new user in the tenant Azure Active Directory. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + +``` +Required? false +Position? named +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -UsageLocation <String> + +Specifies the location the user will be used. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -UserPrincipalName <String> + +Specifies the user name including the domain for the new user. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -FirstName <String> + +Specifies the first name of the new users. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -LastName <String> + +Specifies the last name for the new user. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -DisplayName <String> + +Specifies the display name for the new user. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Password <SecureString> - New-PCCustomerUser -tenantid $customer.id -usageLocation '' -userPrincipalName '' -firstName '' -lastName '' -displayName '' -forceChangePassword $true -password $passwordSecure +Specifies a secure string to be assigned as the password for the new user. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -ForceChangePassword <Boolean> + +Specifies whether the new user must change their password during the first logon. + +``` +Required? true +Position? named +Default value False +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? named +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +```powershell +PS C:\>New-PCCustomerUser -TenantId 45916f92-e9c3-4ed2-b8c2-d87aa129905f -UsageLocation US -userPrincipalName 'joe@contoso.onmicrosoft.com' -FirstName 'Joe' -LastName 'Smith' -DisplayName 'Joe Smith' -ForceChangePassword $true -Password $PasswordSecure ``` diff --git a/CmdletHelp/New-PCOrder.md b/CmdletHelp/New-PCOrder.md index 27907b3..18e54c3 100644 --- a/CmdletHelp/New-PCOrder.md +++ b/CmdletHelp/New-PCOrder.md @@ -1,46 +1,197 @@ -# New-PCOrder # +# New-PCOrder -## Select a customer ## +Creates a new order. + +## SYNTAX + +```powershell +New-PCOrder [-TenantId ] -OrderId [-LineItems ] [-SaToken ] [] + +New-PCOrder [-TenantId ] -LineItems [-SaToken ] [] + +New-PCOrder [-TenantId ] -OfferId -Quantity [-FriendlyName ] [-PartnerIdOnRecord ] [-SaToken ] [] +``` + +## DESCRIPTION + +The New-PCOrder cmdlet creates a new order. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + +``` +Required? false +Position? named +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -OrderId <String> + +Specifies the order id if this is an add on order. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -LineItems <Array> + +Specifies line items to include in the order + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -OfferId <String> + +Specifies the offer id guid for the ordered items. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Quantity <UInt16> + +Specifies the number of licenses for a license-based subscription or instances for an Azure reservation. + +``` +Required? true +Position? named +Default value 0 +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -FriendlyName <String> + +Specifies a friendly name for the subscription defined by the partner to help disambiguate. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -PartnerIdOnRecord <String> + +When an indirect provider places an order on behalf of an indirect reseller, populate this field with the MPN ID of the indirect reseller only (never the ID of the indirect provider). This ensures proper accounting for incentives. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? named +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +#### Order a new subscription + +Select a customer ```powershell - $customer = Get-PCCustomer -tenantid '' +PS C:\>$customer = Get-PCCustomer -TenantId '' ``` -## Order a new subscription ## +Get an offer id ```powershell - # Get offer - $offer = Get-PCOffer -countryid '' -offerid '' + $offer = Get-PCOffer -CountryId '' -OfferId '' +``` + +Create the OrderLineItem - # Create the OrderLineItem +```powershell $lineItems = @() $lineItems += [OrderLineItem]::new() $lineItems[0].LineItemNumber = 0 $lineItems[0].FriendlyName = '' $lineItems[0].OfferId = $offer.id $lineItems[0].Quantity = +```` + +Send order - # Send order - New-PCOrder -tenantid $customer.id -LineItems $lineItems +```powershell +New-PCOrder -TenantId $customer.id -LineItems $lineItems ``` -## Order an Addon to a subscription ## +### EXAMPLE 2 + +Order an Addon to an existing subscription + +Get subscription ```powershell - # Get subscription - $subscription = Get-PCSubscription -tenantid $customer.id -subscriptionid '' + $subscription = Get-PCSubscription -TenantId $customer.id -subscriptionid '' +``` + +Get list of addons available for the subscription offer + +```powershell + $addons = Get-PCOffer -CountryId '' -OfferId $subscription.OfferId -addons +``` + +Get addon offer + +```powershell + $addon = Get-PCOffer -CountryId 'US' -OfferId '' +``` + +Get subscription order - # Get list of addons available for the subscription offer - $addons = Get-PCOffer -countryid '' -offerid $subscription.offerId -addons +```powershell + $order = Get-PCOrder -TenantId $customer.id -OrderId $subscription.OrderId +``` - # Get addon offer - $addon = Get-PCOffer -countryid 'US' -offerid '' +Get the next OrderLineItem number - # Get subscription order - $order = Get-PCOrder -tenantid $customer.id -orderid $subscription.orderId - # Get the next OrderLineItem number +```powershell $newLineItemNumber = $order.lineItems.Count - # Create the addon OrderLineItem +``` + +Create the addon OrderLineItem + +```powershell $lineItems = @() $lineItems += [OrderLineItem]::new() $lineItems[0].LineItemNumber = 0 @@ -48,7 +199,10 @@ $lineItems[0].OfferId = $addon.id $lineItems[0].ParentSubscriptionId = $subscription.id $lineItems[0].Quantity = +``` - # Send order - New-PCOrder -tenantid $customer.id -orderid $order.id -LineItems $lineItems +Send order + +```powershell + New-PCOrder -TenantId $customer.id -OrderId $order.id -LineItems $lineItems ``` diff --git a/CmdletHelp/New-PCRelationshipRequest.md b/CmdletHelp/New-PCRelationshipRequest.md index d3c23e6..89af2cc 100644 --- a/CmdletHelp/New-PCRelationshipRequest.md +++ b/CmdletHelp/New-PCRelationshipRequest.md @@ -1,7 +1,43 @@ -# New-PCRelationshipRequest # +# New-PCRelationshipRequest -## Get invitation URL to send to customer ## +Returns the request text to send to the end customer administrator to initiate a relationship with the partner. + +## SYNTAX + +```powershell +New-PCRelationshipRequest [[-SaToken] ] [] +``` + +## DESCRIPTION + +The New-PCRelationshipRequest cmdlet. + +## PARAMETERS + +### -SaToken <String> + +Specifies a security token for authenticating and executing the cmdlet. + +``` +Required? false +Position? 1 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 ```powershell - $inviteURL = (New-PCRelationshipRequest).url +PS C:\>$inviteUrl = (New-PCRelationshipRequest).Url + +Get an invitation Url to send to a new customer. ``` diff --git a/CmdletHelp/New-PCSAToken.md b/CmdletHelp/New-PCSAToken.md index b4062cf..f3f75b5 100644 --- a/CmdletHelp/New-PCSAToken.md +++ b/CmdletHelp/New-PCSAToken.md @@ -1,18 +1,108 @@ -# New-PCSAToken # +# New-PCSaToken -## Set a specific token for a command/function - user authentication ## +Creates an access token for the Partner Center API. + +## SYNTAX ```powershell - $cred = Get-Credential +New-PCSaToken -CspAppId -CspDomain -Credential [] + + + +New-PCSaToken -CspAppId -CspDomain -CspClientSecret [] +``` + +## DESCRIPTION + +The New-PCSaToken cmdlet returns a token used the access Partner Center resources. + +## PARAMETERS + +### -CspAppId <String> + +Specifies a application Id generated for the Partner Center account. The application id must match the authentication type chosen. - New-PCSAToken -cspappID '' -cspDomain '' -credential $cred ``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -CspDomain <String> + +Specifies the Partner Center tenant (onmicrosoft.com) domain. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -CspClientSecret <SecureString> + +Specifies an application secret key generated from the Partner Center portal. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Credential <PSCredential> + +Specifies the user account credentials to use to perform this task. To specify this parameter, you can type a user name, such as User1 or Domain01\User01 or you can specify a PSCredential object. If you specify a user name for this parameter, the cmdlet prompts for a password. +You can also create a PSCredential object by using a script or by using the Get-Credential cmdlet. You can then set the Credential parameter to the PSCredential object. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +$cred = Get-Credential +clientSecret = 'NQSm6Wjsd7PcDeP5JD6arEWMF3UghEpWmphGrshxzsQ=' +$ClientSecretSecure = $clientSecret | ConvertTo-SecureString -AsPlainText -Force + +## EXAMPLES + +### EXAMPLE 1 + +Creates a new token using the specified information. + +```powershell +PS C:\>$sat = New-PCSaToken -CspAppId 97037612-799c-4fa6-8c40-68be72c6b83c -CspDomain contoso.onmicrosoft.com -CspClientSecret $ClientSecretSecure -Credential $cred +``` + +### EXAMPLE 2 + +Set a specific token for a command/function - user authentication ## + +```powershell + $cred = Get-Credential + New-PCSaToken -CspAppId '' -CspDomain '' -Credential $cred +``` + +### EXAMPLE 3 -## Set a specific token for a command/function - app authentication ## +Set a specific token for a command/function - app authentication ## ```powershell $clientSecret = '' $clientSecretSecure = $clientSecret | ConvertTo-SecureString -AsPlainText -Force - New-PCSAToken -cspappID '' -cspDomain '' -cspClientSecret $clientSecretSecure + New-PCSaToken -CspAppId '' -CspDomain '' -CspClientSecret $clientSecretSecure ``` diff --git a/CmdletHelp/New-PCSR.md b/CmdletHelp/New-PCSR.md index 62193cb..bae8ce8 100644 --- a/CmdletHelp/New-PCSR.md +++ b/CmdletHelp/New-PCSR.md @@ -1,24 +1,164 @@ -# New-PCSR # +# New-PCSR -## Get support topic for the request ## +Creates a new service request. + +## SYNTAX + +```powershell +New-PCSR -ServiceRequest [-AgentLocale ] [-SaToken ] [] + + + +New-PCSR -Title -Description -Severity -SupportTopicID [-ServiceRequestContact ] [-ServiceRequestNote ] [-AgentLocale ] [-SaToken ] [] +``` + +## DESCRIPTION + +The New-PCSR cmdlet creates a new service request. + +## PARAMETERS + +### -ServiceRequest <ServiceRequest> + +Specifies the service request object variable created that defines the service request to open. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Title <String> + +Specifies the title of the service request. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Description <String> + +Specifies details of the the service request. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Severity <String> + +Specifies the severity of request. Valid entries are: minimal, moderate, or critical. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SupportTopicID <String> + +Specifies the Id of the support topic that should be associated with the new service request. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -ServiceRequestContact <ServiceRequestContact> + +Specifies an object that defines the contact for the new service request. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -ServiceRequestNote <ServiceRequestNote> + +Specifies a note to add to the new service request. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -AgentLocale <String> + +Specifies the two letter ISO code for the language and country. For example United States English would be en-us. + +``` +Required? false +Position? named +Default value en-US +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? named +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Create a new service request. + +Get support topic for the request ```powershell $supportTopic = Get-PCSRTopics | Where-Object name -Contains '' ``` -## New Service Requests - Sample ## +Complete request creation ```powershell New-PCSR -title '' -description '' -severity '' -supportTopicID '' ``` -## New Service Requests - Sample 2 ## +### EXAMPLE 2 + +Create a new service request by specifying the information manually. ```powershell $serviceRequestContact = [ServiceRequestContact]::new() $serviceRequestContact.FirstName = '' $serviceRequestContact.LastName = '' - $serviceRequestContact.Email = '' + $serviceRequestContact.Email = '' $serviceRequestContact.PhoneNumber = '' $supportTopic = Get-PCSRTopics | Where-Object name -Contains '' @@ -28,7 +168,7 @@ $serviceRequest = [ServiceRequest]::new() $serviceRequest.Title = '' - $serviceRequest.Description = '<description>' + $serviceRequest.SYNOPSIS \n \n .DESCRIPTION = '<description>' $serviceRequest.Severity = '<Minimal | Moderate | Critical>' $serviceRequest.supportTopicID = $supportTopic.id $serviceRequest.PrimaryContact = $serviceRequestContact diff --git a/CmdletHelp/Remove-PCCustomer.md b/CmdletHelp/Remove-PCCustomer.md index fa7f897..18c58e9 100644 --- a/CmdletHelp/Remove-PCCustomer.md +++ b/CmdletHelp/Remove-PCCustomer.md @@ -1,13 +1,53 @@ -# Remove-PCCustomer # +# Remove-PCCustomer -## Specify a customer ## +Removes a customer from the Partner Center integration sandbox. + +## SYNTAX ```powershell - $customer = Get-PCCustomer -tenantid '<tenant id GUID>' +Remove-PCCustomer [[-TenantId] <Object>] [[-SaToken] <String>] [<CommonParameters>] +``` + +## DESCRIPTION + +The Remove-PCCCustomer cmdlet removes a customer from the integration sandbox. + +## PARAMETERS + +### -TenantId <Object> + +Specifies the tenant used for scoping this cmdlet. + +``` +Required? false +Position? 1 +Default value +Accept pipeline input? false +Accept wildcard characters? false ``` -## Delete a customer (integration sandbox only) ## +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 2 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 ```powershell - Remove-PCCustomer -tenantid $customer.id +PS C:\>Remove-PCCustomer -TenantId 97037612-799c-4fa6-8c40-68be72c6b83c ``` diff --git a/CmdletHelp/Remove-PCCustomerRoleMember.md b/CmdletHelp/Remove-PCCustomerRoleMember.md index 7585cd3..ffe1018 100644 --- a/CmdletHelp/Remove-PCCustomerRoleMember.md +++ b/CmdletHelp/Remove-PCCustomerRoleMember.md @@ -1,25 +1,99 @@ -# Remove-PCCustomerRoleMember # +# Remove-PCCustomerRoleMember -## Get a customer ## +Removes the specified user id from the specified role id. + +## SYNTAX + +```powershell +Remove-PCCustomerRoleMember [[-TenantId] <String>] [-RoleId] <String> [-UserId] <String> [[-SaToken] <String>] [<CommonParameters>] +``` + +## DESCRIPTION + +The Remove-PCCustomerRoleMember cmdlet removes the specified user from the specified role. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + +``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -RoleId <String> + +Specifies the role guid for which to remove the user. + +``` +Required? true +Position? 2 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -UserId <String> + +Specifies the user id to remove from the role. + +``` +Required? true +Position? 3 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies a security token for authenticating and executing the cmdlet. + +``` +Required? false +Position? 4 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Remove a user from a specified role. + +Get a customer named Wingtip Toys ```powershell - $customer = Get-PCCustomer -tenantid '<tenant id GUID>' + $customer = Get-PCCustomer | Where-Object {$_.CompanyProfile.CompanyName -eq 'Wingtip Toys'} ``` -## Get a role ## +Get a role named ```powershell - $role = Get-PCDirectoryRoles -tenantid $customer.id | Where-Object name -Contains '<role name>' + $role = Get-PCCustomerRole -TenantId $customer.id | Where-Object {$_.Name -eq 'Helpdesk Administrator'} ``` -## Get a User ## +Get a User ```powershell - $user = Get-PCCustomerUser -tenantid $customer.id -userid '<user id guid>' + $user = Get-PCCustomerUser -TenantId $customer.id | Where-Object {$_.userPrincipalName -eq 'John@wingtiptoyscsptest.onmicrosoft.com'} ``` -## Remove a User from a Role ## +Remove a user from a role ```powershell - Remove-PCCustomerRoleMember -tenantid $customer.id -roleid $role.id -userid $user.id + Remove-PCCustomerRoleMember -TenantId $customer.id -RoleId $role.id -UserId $user.id ``` diff --git a/CmdletHelp/Remove-PCCustomerUser.md b/CmdletHelp/Remove-PCCustomerUser.md index c2b9755..8db4024 100644 --- a/CmdletHelp/Remove-PCCustomerUser.md +++ b/CmdletHelp/Remove-PCCustomerUser.md @@ -1,19 +1,73 @@ -# Remove-PCCustomerUser # +# Remove-PCCustomerUser -## Get a customer ## +Deletes a user from the customer's tenant. + +## SYNTAX ```powershell - $customer = Get-PCCustomer -tenantid '<tenant id GUID>' +Remove-PCCustomerUser [[-TenantId] <String>] [-UserId] <String> [[-SaToken] <String>] [<CommonParameters>] +``` + +## DESCRIPTION + +The Remove-PCCustomerUser cmdlet removes the specified user from the customer tenant. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + +``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -UserId <String> + +Specifies the user id to remove. + +``` +Required? true +Position? 2 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + ``` +Required? false +Position? 3 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 -## Get customer user ## +Retrieve the user id for the customer user you want to delete ```powershell - $user = Get-PCCustomerUser -tenantid $customer.id -userid '<user id>' +PS C:\>$user = Get-PCCustomerUser -TenantId db8ea5b4-a69b-45f3-abd3-dca19e87c536 | Where-Object {$_.userPrincipalName -eq 'John@wingtiptoyscsptest.onmicrosoft.com'} ``` -## Delete a customer user ## +Delete the specified customer user ```powershell - Remove-PCCustomerUser -tenantid $customer.id -user $user + Remove-PCCustomerUser -TenantId $customer.id -UserId $user.id ``` diff --git a/CmdletHelp/Restore-PCCustomerUser.md b/CmdletHelp/Restore-PCCustomerUser.md index dacdec2..26ecdbf 100644 --- a/CmdletHelp/Restore-PCCustomerUser.md +++ b/CmdletHelp/Restore-PCCustomerUser.md @@ -1,19 +1,73 @@ -# Restore-PCCustomerUser # +# Restore-PCCustomerUser -## Get a customer ## +Restores a deleted customer user. + +## SYNTAX ```powershell - $customer = Get-PCCustomer -tenantid '<tenant id GUID>' +Restore-PCCustomerUser [[-TenantId] <String>] [-UserId] <String> [[-SaToken] <String>] [<CommonParameters>] +``` + +## DESCRIPTION + +The Restore-PCCustomerUser cmdlet restores a deleted customer user. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + +``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -UserId <String> + +Specifies the user id to restore. + +``` +Required? true +Position? 2 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + ``` +Required? false +Position? 3 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 -## Get customer deleted users ## +Find the deleted account. ```powershell - $user = Get-PCCustomerUser -tenantid $customer.id -deleted | ? id -EQ '<user id>' +PS C:\>$user = Get-PCCustomerUser -Deleted -TenantId db8ea5b4-a69b-45f3-abd3-dca19e87c536 | Where-Object {$_.userPrincipalName -eq 'John@wingtiptoyscsptest.onmicrosoft.com'} ``` -## Restore a customer deleted user ## +Restore the deleted user account ```powershell - Restore-PCCustomerUser -tenantid $customer.id -user $user + Restore-PCCustomerUser -TenantId $customer.id -UserId $User.Id ``` diff --git a/CmdletHelp/Select-PCCustomer.md b/CmdletHelp/Select-PCCustomer.md new file mode 100644 index 0000000..1ad9f53 --- /dev/null +++ b/CmdletHelp/Select-PCCustomer.md @@ -0,0 +1,53 @@ +# Select-PCCustomer + +Selects a customer to be used in other cmdlets. + +## SYNTAX + +```powershell +Select-PCCustomer -TenantId <String> [-SaToken <String>] [<CommonParameters>] +``` + +## DESCRIPTION + +The Select-PCCustomer cmdlet selects a customer tenant specified by the tenant id. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? named +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +```powershell +PS C:\>Select-PCCustomer -TenantId 97037612-799c-4fa6-8c40-68be72c6b83c +``` diff --git a/CmdletHelp/Set-PCBillingProfile.md b/CmdletHelp/Set-PCBillingProfile.md index 59cd9a0..e9f917d 100644 --- a/CmdletHelp/Set-PCBillingProfile.md +++ b/CmdletHelp/Set-PCBillingProfile.md @@ -1,7 +1,149 @@ -# Set-PCBillingProfile # +# Set-PCBillingProfile -## Set Partner Billing Profile ## +Updates a partner's billing profile. + +## SYNTAX + +```powershell +Set-PCBillingProfile [[-Country] <String>] [[-AddressLine1] <String>] [[-AddressLine2] <String>] [[-City] <String>] [[-State] <String>] [[-PostalCode] <String>] [[-FirstName] <String>] [[-LastName] <String>] [[-PhoneNumber] <String>] [[-SaToken] <String>] [<CommonParameters>] +``` + +## DESCRIPTION + +The Set-PCBillingProfile cmdlet updates the partner's billing profile. + +## PARAMETERS + +### -Country <String> + +Specifies the billing contact's country two letter ISO code. + +``` +Required? false +Position? 1 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -AddressLine1 <String> + +Specifies the first address line for the billing contact. + +``` +Required? false +Position? 2 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -AddressLine2 <String> + +Specifies the second address line for the billing contact. + +``` +Required? false +Position? 3 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -City <String> + +Specifies the billing contact's city. + +``` +Required? false +Position? 4 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -State <String> + +Specifies the billing contact's state. + +``` +Required? false +Position? 5 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -PostalCode <String> + +Specifies the billing contact's postal code. + +``` +Required? false +Position? 6 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -FirstName <String> + +Specifies the billing contact's first name. + +``` +Required? false +Position? 7 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -LastName <String> + +Specifies the billing contact's last name. + +``` +Required? false +Position? 8 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -PhoneNumber <String> + +Specifies the billing contact's phone number. + +``` +Required? false +Position? 9 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 10 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 ```powershell - Set-PCBillingProfile -firstname '<first name>' -lastname '<last name>' -phonenumber '<phone number>' -AddressLine1 '<address 1>' -AddressLine2 '<address 2>' +Set-PCBillingProfile -FirstName '<first name>' -LastName '<last name>' -PhoneNumber '<phone number>' -AddressLine1 '<address 1>' -AddressLine2 '<address 2>' ``` diff --git a/CmdletHelp/Set-PCCustomerBillingProfile.md b/CmdletHelp/Set-PCCustomerBillingProfile.md index e4d6524..c07961e 100644 --- a/CmdletHelp/Set-PCCustomerBillingProfile.md +++ b/CmdletHelp/Set-PCCustomerBillingProfile.md @@ -1,22 +1,83 @@ -# Set-PCCustomerBillingProfile # +# Set-PCCustomerBillingProfile -## Specify a customer ## +Updates the specified customer's billing profile. The cmdlet accepts an updated billing profile object to determine the updates to be made. Use either Get-PCCustomerBillingProfile or New-PCCustomerBillingProfile cmdlet to create the updated customer billing profile object. + +## SYNTAX + +```powershell +Set-PCCustomerBillingProfile [[-TenantId] <String>] [-BillingProfile] <PSObject> [[-SaToken] <String>] [<CommonParameters>] +``` + +## DESCRIPTION + +The Set-PCCustomerBillingProfile cmdlet updates a customer's billing profile. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + +``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -BillingProfile <PSObject> + +Specifies a variable that includes the billing profile. + +``` +Required? true +Position? 2 +Default value +Accept pipeline input? true (ByValue, ByPropertyName) +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 3 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Update the current customer billing profile. + +Get the current customer billing profile. ```powershell - $customer = Get-PCCustomer -tenantid '<tenant id GUID>' +PS C:\>$customerBillingProfile = Get-PCCustomerBillingProfile -TenantId db8ea5b4-a69b-45f3-abd3-dca19e87c536 ``` -## Get customer Billing Profile ## +Update name and email address on the customer billing profile. ```powershell - $customerBillingProfile = Get-PCCustomerBillingProfile -tenantid $customer.id + $customerBillingProfile.FirstName = 'Joan' + $customerBillingProfile.LastName = 'Sullivan' + $customerBillingProfile.Email = 'joan@wingtiptoyscsptest.onmicrosoft.com' ``` -## Set customer Billing Profile ## +Complete update for the customer's billing profile ```powershell - $customerBillingProfile.firstName = '<first name>' - $customerBillingProfile.lastName = '<last name>' - $customerBillingProfile.email = '<email>' - Set-PCCustomerBillingProfile -tenantid $customer.id -billingprofile $customerBillingProfile + Set-PCCustomerBillingProfile -TenantId db8ea5b4-a69b-45f3-abd3-dca19e87c536 -BillingProfile $customerBillingProfile ``` diff --git a/CmdletHelp/Set-PCCustomerUser.md b/CmdletHelp/Set-PCCustomerUser.md index af19151..98e472d 100644 --- a/CmdletHelp/Set-PCCustomerUser.md +++ b/CmdletHelp/Set-PCCustomerUser.md @@ -1,28 +1,175 @@ -# Set-PCCustomerUser # +# Set-PCCustomerUser -## Get a customer ## +Updates the specified customer user account. + +## SYNTAX + +```powershell +Set-PCCustomerUser [-TenantId <String>] -UserId <String> [-FirstName <String>] [-LastName <String>] [-UserPrincipalName <String>] [-Location <String>] [-Password <SecureString>] [-ForceChangePassword <Boolean>] [-SaToken <String>] [<CommonParameters>] +``` + +## DESCRIPTION + +The Set-PCustomerUser cmdlet modifies a customer user account. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + +``` +Required? false +Position? named +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -UserId <String> + +Specifies the user id to modify. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -FirstName <String> + +Specifies the modified first name for the user. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -LastName <String> + +Specifies the modified last name for the user. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -UserPrincipalName <String> + +Specifies a modified user name including the domain name. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Location <String> + +Specifies a modified location for the user. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Password <SecureString> + +Specifies an updated password as a secure string to set for the user. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -ForceChangePassword <Boolean> + +Specifies whether the user will need to change their password the next time they sign in. + +``` +Required? false +Position? named +Default value False +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? named +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Update a customer user's last name +Find the tenant information about the customer named Wingtip Toys ```powershell - $customer = Get-PCCustomer -tenantid '<tenant id GUID>' +PS C:\>$customer = Get-PCCustomer | Where-Object {$_.CompanyProfile.CompanyName -eq 'Wingtip Toys'} ``` -## Get customer user ## +Find the user with the joan@wingtiptoyscsptest.onmicrosoft.com ```powershell - $user = Get-PCCustomerUser -tenantid $customer.id -userid '<user id>' +PS C:\>$user = Get-PCCustomerUser -TenantId $customer.id | Where-Object {$_.userPrincipalName -eq 'joan@wingtiptoyscsptest.onmicrosoft.com'} ``` -## Update a customer user ## +Modify the user's last name ```powershell - Set-PCCustomerUser -tenantid $customer.id -user $user -userPrincipalName '<new UPN>' +PS C:\>Set-PCCustomerUser -TenantId $customer.id -userId $user.id -LastName 'Sullivan' ``` -## Reset a customer user password ## +### EXAMPLE 2 + +Reset a customer user's password +Find the tenant information about the customer named Wingtip Toys + +```powershell +PS C:\>$customer = Get-PCCustomer | Where-Object {$_.CompanyProfile.CompanyName -eq 'Wingtip Toys'} +``` + +Find the user with the joan@wingtiptoyscsptest.onmicrosoft.com ```powershell - $password = '<password>' - $passwordSecure = $password | ConvertTo-SecureString -AsPlainText -Force +PS C:\>$user = Get-PCCustomerUser -TenantId $customer.id | Where-Object {$_.userPrincipalName -eq 'joan@wingtiptoyscsptest.onmicrosoft.com'} +``` - Set-PCCustomerUser -tenantid $customer.id -user $user -password $passwordSecure -forceChangePassword $true/$false +Set the password for the user account and require the user to change the password during the next sign on. + +```powershell +PS C:\>$password = '<password>' +PS C:\>$passwordSecure = $password | ConvertTo-SecureString -AsPlainText -Force +PS C:\>Set-PCCustomerUser -TenantId $customer.id -UserId $user.Id -Password $passwordSecure -ForceChangePassword $true ``` diff --git a/CmdletHelp/Set-PCLegalBusinessProfile.md b/CmdletHelp/Set-PCLegalBusinessProfile.md index 81d3fa6..4d20a21 100644 --- a/CmdletHelp/Set-PCLegalBusinessProfile.md +++ b/CmdletHelp/Set-PCLegalBusinessProfile.md @@ -1,7 +1,163 @@ -# Set-PCLegalBusinessProfile # +# Set-PCLegalBusinessProfile -## Set Partner Legal Business Profile ## +Updates the partner's legal business profile. + +## SYNTAX + +```powershell +Set-PCLegalBusinessProfile [[-Country] <String>] [[-AddressLine1] <String>] [[-AddressLine2] <String>] [[-City] <String>] [[-State] <String>] [[-PostalCode] <String>] [[-PrimaryContactFirstName] <String>] [[-PrimaryContactLastName] <String>] [[-PrimaryContactPhoneNumber] <String>] [[-PrimaryContactEmail] <String>] [[-SaToken] <String>] [<CommonParameters>] +``` + +## DESCRIPTION + +The Set-PCLegalBusinessProfile cmdlet updates the partner's legal business profile. + +## PARAMETERS + +### -Country <String> + +Specifies an updated two letter ISO country code for the legal business profile. + +``` +Required? false +Position? 1 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -AddressLine1 <String> + +Specifies an updated street address for the legal business profile. + +``` +Required? false +Position? 2 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -AddressLine2 <String> + +Specifies an updated second address line for the legal business profile. + +``` +Required? false +Position? 3 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -City <String> + +Specifies an updated city name for the legal business profile. + +``` +Required? false +Position? 4 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -State <String> + +Specifies an updated city name for the legal business profile. + +``` +Required? false +Position? 5 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -PostalCode <String> + +Specifies an updated postal code for the legal business profile. + +``` +Required? false +Position? 6 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -PrimaryContactFirstName <String> + +Specifies an updated first name for the primary legal business contact. + +``` +Required? false +Position? 7 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -PrimaryContactLastName <String> + +Specifies an updated last name for the primary legal business contact. + +``` +Required? false +Position? 8 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -PrimaryContactPhoneNumber <String> + +Specifies an updated phone number for the primary legal business contact. + +``` +Required? false +Position? 9 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -PrimaryContactEmail <String> + +Specifies an updated e-mail address for the primary legal business contact. + +``` +Required? false +Position? 10 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 11 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Update the legal business profile to use John Smith with the email address of john@contoso.com. ```powershell - Set-PCLegalBusinessProfile -addressLine1 '<address 1>' -AddressLine2 '<address 2>' -primarycontactfirstname '<first name>' -primarycontactlastname '<last name>' -primarycontactphonenumber '<phone number>' -primarycontactemail '<email>' +PS C:\>Set-PCLegalBusinessProfile -PrimaryContactFirstName 'John' -PrimaryContactLastName 'Smith' -PrimaryContactEmail 'john@contoso.com' ``` diff --git a/CmdletHelp/Set-PCOrganizationProfile.md b/CmdletHelp/Set-PCOrganizationProfile.md index b1da176..0021221 100644 --- a/CmdletHelp/Set-PCOrganizationProfile.md +++ b/CmdletHelp/Set-PCOrganizationProfile.md @@ -1,7 +1,187 @@ -# Set-PCOrganizationProfile # +# Set-PCOrganizationProfile -## Set Partner Organization Profile ## +Updates the partner's organization profile. + +## SYNTAX + +```powershell +Set-PCOrganizationProfile [[-CompanyName] <String>] [[-Country] <String>] [[-AddressLine1] <String>] [[-AddressLine2] <String>] [[-City] <String>] [[-State] <String>] [[-PostalCode] <String>] [[-FirstName] <String>] [[-LastName] <String>] [[-PhoneNumber] <String>] [[-Email] <String>] [[-Language] <String>] [[-SaToken] <String>] [<CommonParameters>] +``` + +## DESCRIPTION + +The Set-PCOrganizationProfile cmdlet sets information on a partner's organizational profile. + +## PARAMETERS + +### -CompanyName <String> + +Specifies an updated company name for the partner's organizational profile. + +``` +Required? false +Position? 1 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Country <String> + +Specifies an updated two letter ISO code for the partner's organizational profile. + +``` +Required? false +Position? 2 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -AddressLine1 <String> + +Specifies the first address line for the partner's organizational profile. + +``` +Required? false +Position? 3 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -AddressLine2 <String> + +Specifies the second address line for the partner's organizational profile. + +``` +Required? false +Position? 4 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -City <String> + +Specifies the second city for the partner's organizational profile. + +``` +Required? false +Position? 5 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -State <String> + +Specifies the state for the partner's organizational profile. + +``` +Required? false +Position? 6 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -PostalCode <String> + +Specifies the postal code for the partner's organizational profile. + +``` +Required? false +Position? 7 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -FirstName <String> + +Specifies the first name of the company contact for the partner's organizational profile. + +``` +Required? false +Position? 8 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -LastName <String> + +Specifies the last name of the company contact for the partner's organizational profile. + +``` +Required? false +Position? 9 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -PhoneNumber <String> + +Specifies the phone number of the company contact for the partner's organizational profile. + +``` +Required? false +Position? 10 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Email <String> + +Specifies the email address for the company contact. + +``` +Required? false +Position? 11 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Language <String> + +Specifies the two letter ISO code for the language. + +``` +Required? false +Position? 12 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 13 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Sets John Smith with the email address of john@contoso.com as the contact on the partner's organizational profile. ```powershell - Set-PCOrganizationProfile -firstname '<first name>' -lastname '<last name>' -phonenumber '<phone number>' +PS C:\>Set-PCOrganizationProfile -FirstName 'John' -LastName 'Smith' -Email 'john@contoso.com' ``` diff --git a/CmdletHelp/Set-PCSR.md b/CmdletHelp/Set-PCSR.md index edcf965..9527ed9 100644 --- a/CmdletHelp/Set-PCSR.md +++ b/CmdletHelp/Set-PCSR.md @@ -1,25 +1,113 @@ -# Set-PCSR # +# Set-PCSR -## Get Service Request ## +Updates a service request. + +## SYNTAX ```powershell - $serviceRequest = Get-PCSR -serviceRequestId '<service request id guid>' +Set-PCSR -ServiceRequest <PSObject> [-Status <String>] [-Title <String>] [-Description <String>] [-AddNote <String>] [-SaToken <String>] [<CommonParameters>] ``` -## Set Service Requests status ## +## DESCRIPTION -```powershell - $serviceRequest | Set-PCSR -status '< open | closed >' +The Set-PCSR cmdlet updates a service request.. + +## PARAMETERS + +### -ServiceRequest <PSObject> + +Specifies the updated service request object used to update the service request. + +``` +Required? true +Position? named +Default value +Accept pipeline input? true (ByValue, ByPropertyName) +Accept wildcard characters? false +``` + +### -Status <String> + +Specifies whether the service request is open or closed. Valid values are: open and closed. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Title <String> + +Specifies the updated service request title. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Description <String> + +Specifies the updated service request description. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -AddNote <String> + +Specifies a note to add to the service request. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false ``` -or +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? named +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Set all open service request for the specified tenant to closed. ```powershell - Set-PCSR -serviceRequest $serviceRequest -status '< open | closed >' +PS C:\>$sr = Get-PCServiceRequest -TenantId 'e974093c-2a52-4ebd-994e-b3e7e0f90cf2' | Where-Object {$_.Status -eq 'open'} +PS C:\>Set-PCSR -ServiceRequest $sr -Status 'closed' ``` -## Add note to Service Requests ## +### EXAMPLE 2 + +Add a note to an existing service request. ```powershell - Set-PCSR -serviceRequest $serviceRequest -addnote '<note text>' +PS C:\>$sr = Get-PCServiceRequest -ServiceRequestId '615112491169010' +PS C:\>Set-PCSR -ServiceRequest $sr -AddNote 'After further testing, the problem is still occurring.' ``` diff --git a/CmdletHelp/Set-PCSpendingBudget.md b/CmdletHelp/Set-PCSpendingBudget.md new file mode 100644 index 0000000..05d81ca Binary files /dev/null and b/CmdletHelp/Set-PCSpendingBudget.md differ diff --git a/CmdletHelp/Set-PCSubscription.md b/CmdletHelp/Set-PCSubscription.md index fb3c355..3f5f9de 100644 --- a/CmdletHelp/Set-PCSubscription.md +++ b/CmdletHelp/Set-PCSubscription.md @@ -1,43 +1,211 @@ -# Set-PCSubscription # +# Set-PCSubscription -## Get a customer ## +Modifies an existing subscription. + +## SYNTAX ```powershell - $customer = Get-PCCustomer -tenantid '<tenant id GUID>' +Set-PCSubscription [[-TenantId] <String>] [-Subscription] <PSObject> [[-Status] <String>] [[-FriendlyName] <String>] [[-AutoRenew] <String>] [[-Quantity] <Int32>] [[-SaToken] <String>] [<CommonParameters>] +``` + +## DESCRIPTION + +The Set-PCSubscription cmdlet modifies an existing subscription. + +## PARAMETERS + +### -TenantId <String> + +Specifies the tenant used for scoping this cmdlet. + +``` +Required? false +Position? 1 +Default value $GlobalCustomerId +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Subscription <PSObject> + +Specifies the subscription object that identifies the subscription you will modified. This object can be retrieved using the Get-PCSubscription cmdlet. + +``` +Required? true +Position? 2 +Default value +Accept pipeline input? true (ByValue, ByPropertyName) +Accept wildcard characters? false +``` + +### -Status <String> + +Specifies the status for the subscription. Valid values are: none, active, suspended, and deleted. + +``` +Required? false +Position? 3 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -FriendlyName <String> + +Specifies a friendly name for the subscription. + +``` +Required? false +Position? 4 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -AutoRenew <String> + +Specifies as to whether the subscription will auto renew. This is only valid on license-based subscriptions. Valid inputs are: enabled, disabled. This parameter used to be -AutoRenewEnabled in earlier releases. + +``` +Required? false +Position? 5 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Quantity <Int32> + +Specifies the number of licenses included in the subscription. This is valid only on license-based subscriptions. + ``` +Required? false +Position? 6 +Default value 0 +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 7 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES -## Get a customer subscription ## +### EXAMPLE 1 + +Update subscription friendly name + +Find the tenant information about the customer named Wingtip Toys +```powershell +PS C:\>$customer = Get-PCCustomer | Where-Object {$_.CompanyProfile.CompanyName -eq 'Wingtip Toys'} +``` + +Find the the customer subscription ```powershell - $subscription = Get-PCSubscription -tenantid $customer.id -subscriptionid '<subscription id GUID>' +PS C:\>$subscription = Get-PCSubscription -TenantId $customer.id | Where-Object {$_.FriendlyName -eq 'old friendly name'} ``` -## Update subscription friendly name ## +Update the subscription with a new friendly name + +```powershell +PS C:\>$subscription | Set-PCSubscription -TenantId $customer.id -FriendlyName 'New friendly name' +``` + +### EXAMPLE 2 + +Update subscription seats (license based only) + +Find the tenant information about the customer named Wingtip Toys ```powershell - $subscription | Set-PCSubscription -tenantid $customer.id -friendlyName '<friendly name>' +PS C:\>$customer = Get-PCCustomer | Where-Object {$_.CompanyProfile.CompanyName -eq 'Wingtip Toys'} ``` -## Update subscription seats (license based only) ## +Find the the customer subscription + +```powershell +PS C:\>$subscription = Get-PCSubscription -TenantId $customer.id | Where-Object {$_.FriendlyName -eq 'Office 365 Enterprise E1'} +``` + +Update the license quantity for the specified subscription + +```powershell +PS C:\>$subscription | Set-PCSubscription -TenantId $customer.id -quantity 100 +``` + +### EXAMPLE 3 + +Change the subscription auto renewal + +Find the tenant information about the customer named Wingtip Toys ```powershell - $subscription | Set-PCSubscription -tenantid $customer.id -quantity <seats number> +PS C:\>$customer = Get-PCCustomer | Where-Object {$_.CompanyProfile.CompanyName -eq 'Wingtip Toys'} ``` -## Change subscription auto renewal ## +Find the the customer subscription ```powershell - $subscription | Set-PCSubscription -tenantid $customer.id -AutoRenewEnabled disabled +PS C:\>$subscription = Get-PCSubscription -TenantId $customer.id | Where-Object {$_.FriendlyName -eq 'Office 365 Enterprise E1'} ``` -## Suspend a subscription ## +Modify the AutoRenew option for the subscription + +```powershell +PS C:\>$subscription | Set-PCSubscription -TenantId $customer.id -AutoRenew disabled +``` + +### EXAMPLE 4 + +Suspend a subscription + +Find the tenant information about the customer named Wingtip Toys + +```powershell +PS C:\>$customer = Get-PCCustomer | Where-Object {$_.CompanyProfile.CompanyName -eq 'Wingtip Toys'} +``` + +Find the the customer subscription + +```powershell +PS C:\>$subscription = Get-PCSubscription -TenantId $customer.id | Where-Object {$_.FriendlyName -eq 'Office 365 Enterprise E1'} +``` + +Suspend the subscription + +```powershell +PS C:\>$subscription | Set-PCSubscription -TenantId $customer.id -Status suspended +``` + +### EXAMPLE 5 + +Activate a subscription + +Find the tenant information about the customer named Wingtip Toys ```powershell - $subscription | Set-PCSubscription -tenantid $customer.id -status suspended +PS C:\>$customer = Get-PCCustomer | Where-Object {$_.CompanyProfile.CompanyName -eq 'Wingtip Toys'} ``` -## Activate a subscription ## +Find the the customer subscription ```powershell - $subscription | Set-PCSubscription -tenantid $customer.id -status active +PS C:\>$subscription = Get-PCSubscription -TenantId $customer.id | Where-Object {$_.FriendlyName -eq 'Office 365 Enterprise E1'} +$subscription | Set-PCSubscription -TenantId $customer.id -Status active ``` diff --git a/CmdletHelp/Set-PCSupportProfile.md b/CmdletHelp/Set-PCSupportProfile.md index 5fe5460..5d61906 100644 --- a/CmdletHelp/Set-PCSupportProfile.md +++ b/CmdletHelp/Set-PCSupportProfile.md @@ -1,7 +1,79 @@ -# Set-PCSupportProfile # +# Set-PCSupportProfile -## Set Partner Support Profile ## +Modifies the partner's support profile. + +## SYNTAX + +```powershell +Set-PCSupportProfile [[-Website] <String>] [[-Email] <String>] [[-Phone] <String>] [[-SaToken] <String>] [<CommonParameters>] +``` + +## DESCRIPTION + +The Set-PCSupportProfile cmdlet update the partner's support profile. + +## PARAMETERS + +### -Website <String> + +Specifies an updated support website for the partner. Do not include 'http://', specify just the DNS name of the site. + +``` +Required? false +Position? 1 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Email <String> + +Specifies an updated support email address for the partner. + +``` +Required? false +Position? 2 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -Phone <String> + +Specifies an updated support phone number for the partner. + +``` +Required? false +Position? 3 +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an authentication token with your Partner Center credentials. + +``` +Required? false +Position? 4 +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Updates the support website to be support.contoso.com. ```powershell - Set-PCSupportProfile -website '<url>' -email '<email>' -phone '<phone number>' +PS C:\>Set-PCSupportProfile -Website 'support.contoso.com' ``` diff --git a/CmdletHelp/Test-PCAddress.md b/CmdletHelp/Test-PCAddress.md index b7c1685..57a428d 100644 --- a/CmdletHelp/Test-PCAddress.md +++ b/CmdletHelp/Test-PCAddress.md @@ -1,15 +1,138 @@ -# Test-PCAddress # +# Test-PCAddress -## Test the country rules for an address ## +Validates the provided address information to determine if it meets the Partner Center validation rules. + +## SYNTAX ```powershell - $address = New-PCAddress -AddressLine1 '<string>' -AddressLine2 '<string>' -City '<string>' -State '<string>' -PostalCode '<string>' -country 'two digits country code' -region '<string>' +Test-PCAddress -Address <DefaultAddress> [-SaToken <String>] [<CommonParameters>] + +Test-PCAddress -AddressLine1 <String> [-AddressLine2 <String>] -City <String> -State <String> -PostalCode <String> -Country <String> [-SaToken <String>] [<CommonParameters>] +``` + +## DESCRIPTION + +The Test-PCAddress cmdlet validates the provided the address information as to whether it conforms to the Partner Center address rules. + +## PARAMETERS + +### -Address <DefaultAddress> + +Specifies a variable object that includes all of the address information. This object can be created by using the New-PCAddress cmdlet. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -AddressLine1 <String> + +Specifies the first address line. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -AddressLine2 <String> + +Specifies the second address line. + +``` +Required? false +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -City <String> + +Specifies the city. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -State <String> - Test-PCAddress -Address <DefaultAddress> +Specifies the state. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -PostalCode <String> + +Specifies the postal code. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false ``` -or +### -Country <String> + +Specifies a two letter ISO code to define the country. + +``` +Required? true +Position? named +Default value +Accept pipeline input? false +Accept wildcard characters? false +``` + +### -SaToken <String> + +Specifies an partner center access token. + +``` +Required? false +Position? named +Default value $GlobalToken +Accept pipeline input? false +Accept wildcard characters? false +``` + +## INPUTS + +## OUTPUTS + +## NOTES + +## EXAMPLES + +### EXAMPLE 1 + +Validate an address by passing an object variable named $add that was created using the New-PCAddress cmdlet. + +```powershell +PS C:\>$address = New-PCAddress -AddressLine1 '<string>' -AddressLine2 '<string>' -City '<string>' -State '<string>' -PostalCode '<string>' -Country 'two digits Country code' -region '<string>' +PS C:\>Test-PCAddress -Address $add +``` + +### EXAMPLE 2 + +Validate an address by passing the address information to the cmdlet. ```powershell - Test-PCAddress -AddressLine1 '<string>' -AddressLine2 '<string>' -City '<string>' -State '<string>' -PostalCode '<string>' -country 'two digits country code' -region '<string>' +PS C:\>Test-PCAddress -AddressLine1 '1 Microsoft Way' -City 'Redmond' -State 'WA' -Country 'US' -PostalCode '95802' ``` diff --git a/PartnerCenterModule/.vscode/settings.json b/PartnerCenterModule/.vscode/settings.json new file mode 100644 index 0000000..2e00e68 --- /dev/null +++ b/PartnerCenterModule/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "cSpell.words": [ + "get", + "pcsr" + ] +} \ No newline at end of file diff --git a/PartnerCenterModule/PartnerCenterAnalytics.psm1 b/PartnerCenterModule/PartnerCenterAnalytics.psm1 index be13cce..c2bbdc8 100644 --- a/PartnerCenterModule/PartnerCenterAnalytics.psm1 +++ b/PartnerCenterModule/PartnerCenterAnalytics.psm1 @@ -1,6 +1,6 @@ Set-StrictMode -Version latest <# - © 2017 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. + © 2018 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. This sample code is provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, @@ -12,150 +12,158 @@ $here = Split-Path -Parent $MyInvocation.MyCommand.Path . "$here\commons.ps1" -function Get-PCLicensesDeployment -{ - [CmdletBinding()] - Param( - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken - ) - _testTokenContext($satoken) +<# +.SYNOPSIS +Retrieves a list of licenses for the authenticated partner. - Write-Warning " Get-PCLicensesDeployment is deprecated and will not be available in future releases, use Get-PCLicenseDeployment instead." +.DESCRIPTION +The Get-PCLicenseDeployment cmdlet retrieves a list of licenses for the authenticated partner. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. - $url = "https://api.partnercenter.microsoft.com/v1/analytics/licenses/deployment" - $headers = @{Authorization="Bearer $satoken"} +.EXAMPLE +Get-PCLicenseDeployment - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj = @() + $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "PartnerLicensesDeploymentInsights") -} +Return a list of assigned licenses for the authenticated partner. + +.NOTES +You need to have a authentication Credential already established before running this cmdlet. -# Add non-plural noun version of cmdlet. Get-PCLicensesDeployment will be removed in future releases. +#> function Get-PCLicenseDeployment { [CmdletBinding()] Param( - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $url = "https://api.partnercenter.microsoft.com/v1/analytics/licenses/deployment" - $headers = @{Authorization="Bearer $satoken"} + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj = @() + $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "PartnerLicensesDeploymentInsights") } -function Get-PCLicensesUsage -{ - [CmdletBinding()] - Param( - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken - ) - _testTokenContext($satoken) +<# +.SYNOPSIS +Retrieves a list of licenses being used for the partner account. - Write-Warning " Get-PCLicensesUsage is deprecated and will not be available in future releases, use Get-PCLicenseUsage instead." - - $url = "https://api.partnercenter.microsoft.com/v1/analytics/licenses/usage" - $headers = @{Authorization="Bearer $satoken"} +.DESCRIPTION +The Get-PCLicenseUsage cmdlet retrieves a list of licenses assigned for the authenticated partner. - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj = @() + $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "PartnerLicensesUsageInsights") -} +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. + +.EXAMPLE +Get-PCLicenseUsage -# Add non-plural noun version of cmdlet. Get-PCLicenseUsage cmdlet will be removed in future releases. +Return a list of assigned licenses for the authenticated partner. + +.NOTES +You need to have a authentication Credential already established before running this cmdlet. + +#> function Get-PCLicenseUsage { [CmdletBinding()] Param( - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $url = "https://api.partnercenter.microsoft.com/v1/analytics/licenses/usage" - $headers = @{Authorization="Bearer $satoken"} + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj = @() + $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "PartnerLicensesUsageInsights") } +<# +.SYNOPSIS +Returns a list of licenses deploy by a partner for the specified tenant. -function Get-PCCustomerLicensesDeployment -{ - [CmdletBinding()] - Param( - [Parameter(Mandatory = $false)][String]$tenantid = $GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken - ) - _testTokenContext($satoken) - _testTenantContext ($tenantid) +.DESCRIPTION +The Get-PCCustomerLicenseDeployment cmdlet retrieves a list of licenses deployed by a partner for a specific tenant. - Write-Warning " Get-PCCustomerLicensesDeployment is deprecated and will not be available in future releases, use Get-PCCustomerLicenseDeployment instead." +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/analytics/licenses/deployment" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} +.PARAMETER TenantId +Specifies the tenant id. - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj = @() + $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "CustomerLicensesDeploymentInsights") -} +.EXAMPLE +Get-PCCustomerLicenseDeployment -TenantId 97037612-799c-4fa6-8c40-68be72c6b83c + +Retrieve a list of deployed licenses for the specified tenant. -# Add non-plural noun version of cmdlet. Get-PCCustomerLicensesDeployment will be removed in future releases. +.NOTES +This cmdlet requires App + User authentication. +#> function Get-PCCustomerLicenseDeployment { [CmdletBinding()] Param( - [Parameter(Mandatory = $false)][String]$tenantid = $GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) + + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/analytics/licenses/deployment" -f $TenantId - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/analytics/licenses/deployment" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj = @() + $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "CustomerLicensesDeploymentInsights") } -function Get-PCCustomerLicensesUsage -{ - [CmdletBinding()] - Param( - [Parameter(Mandatory = $false)][String]$tenantid = $GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken - ) - _testTokenContext($satoken) - _testTenantContext ($tenantid) +<# +.SYNOPSIS +Returns a list of licenses deployed and assigned by a partner for a specific tenant. - Write-Warning " Get-PCCustomerLicensesUsage is deprecated and will not be available in future releases, use Get-PCCustomerLicenseUsage instead." - - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/analytics/licenses/usage" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} +.DESCRIPTION +The Get-PCCustomerLicenseUsage cmdlet retrieves a list of licenses deployed and assigned by a partner for a specific tenant. - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj = @() + $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "CustomerLicensesUsageInsights") -} +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. + +.PARAMETER TenantId +Specifies the tenant id. + +.EXAMPLE +Get-PCCustomerLicenseDeployment -TenantId 97037612-799c-4fa6-8c40-68be72c6b83c -# Add non-plural noun version of cmdlet. Get-PCCustomerLicensesUsage will be removed in future releases. +Retrieve a list of assigned licenses for the specified tenant + +#> function Get-PCCustomerLicenseUsage { [CmdletBinding()] Param( - [Parameter(Mandatory = $false)][String]$tenantid = $GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) + + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/analytics/licenses/usage" -f $TenantId - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/analytics/licenses/usage" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj = @() + $response.Substring(1) | ConvertFrom-Json diff --git a/PartnerCenterModule/PartnerCenterAuthentication.psm1 b/PartnerCenterModule/PartnerCenterAuthentication.psm1 index fc741f7..6ab9fe5 100644 --- a/PartnerCenterModule/PartnerCenterAuthentication.psm1 +++ b/PartnerCenterModule/PartnerCenterAuthentication.psm1 @@ -1,6 +1,6 @@ Set-StrictMode -Version latest <# - © 2017 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. + © 2018 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. This sample code is provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, @@ -12,154 +12,237 @@ $here = Split-Path -Parent $MyInvocation.MyCommand.Path . "$here\commons.ps1" -function Get-GraphAADTokenByUser -{ +function Get-GraphAADTokenByUser { [CmdletBinding()] - param ($resource, $domain, $clientid, [PSCredential]$credential) - - $username = $credential.GetNetworkCredential().userName - $password = $credential.GetNetworkCredential().Password - - $url = "https://login.windows.net/{0}/oauth2/token" -f $domain - $body = "grant_type=password&" - $body = $body + "resource=$resource&" - $body = $body + "client_id=$clientid&" - $body = $body + "username=$username&" - $body = $body + "password=$password&" + param ( + $Resource, + $Domain, + $ClientId, + [PSCredential]$Credential + ) + + $username = $Credential.GetNetworkCredential().userName + $password = $Credential.GetNetworkCredential().Password + + $url = "https://login.windows.net/{0}/oauth2/token" -f $Domain + $body = "grant_type=password&" + $body = $body + "resource=$Resource&" + $body = $body + "client_id=$ClientId&" + $body = $body + "username=$Username&" + $body = $body + "password=$Password&" $body = $body + "scope=openid" $response = Invoke-RestMethod -Uri $url -ContentType "application/x-www-form-urlencoded" -Body $body -method "POST" #-Debug -Verbose -Headers $headers return $response.access_token } -function Get-GraphAADTokenByApp -{ +function Get-GraphAADTokenByApp { [CmdletBinding()] - param ($resource, $domain, $clientid, $clientsecret) - $url = "https://login.windows.net/{0}/oauth2/token" -f $domain - $body = "grant_type=client_credentials&" - $body = $body + "resource=$resource&" - $body = $body + "client_id=$clientid&" - $tmp_clientsecret = _unsecureString -string $clientsecret - # we need to escape the secret because it may contain special chars - $tmp_clientsecret = [uri]::EscapeDataString($tmp_clientsecret) - $body = $body + "client_secret=$tmp_clientsecret" + param ( + $Resource, + $Domain, + $ClientId, + $ClientSecret + ) + $url = "https://login.windows.net/{0}/oauth2/token" -f $Domain + $body = "grant_type=client_Credentials&" + $body = $body + "resource=$Resource&" + $body = $body + "client_id=$ClientId&" + $tmp_ClientSecret = _unsecureString -string $ClientSecret + + # Need to escape the secret because it may contain special chars + $tmp_ClientSecret = [uri]::EscapeDataString($tmp_ClientSecret) + $body = $body + "client_secret=$tmp_ClientSecret" $response = Invoke-RestMethod -Uri $url -ContentType "application/x-www-form-urlencoded" -Body $body -method "POST" #-Debug -Verbose -Headers $headers - return $response.access_token + return $response.access_token } -function Add-PCAuthentication -{ +<# +.SYNOPSIS +Authenticates the current session with the Partner Center API. + +.DESCRIPTION +The Add-PCAuthentication cmdlet sets up authentication for the Partner Center API. Authenticate with either App authentication or App+User authentication to use other cmdlets in this module. + +.PARAMETER CspAppId +Specifies a application Id generated for the Partner Center account. The application id must match the authentication type chosen. + +.PARAMETER CspDomain +Specifies the Partner Center tenant (onmicrosoft.com) domain. + +.PARAMETER CspClientSecret +Specifies an application secret key generated from the Partner Center portal. + +.PARAMETER Credential +Specifies the user account credentials to use to perform this task. To specify this parameter, you can type a user name, such as User1 or Domain01\User01 or you can specify a PSCredential object. If you specify a user name for this parameter, the cmdlet prompts for a password. +You can also create a PSCredential object by using a script or by using the Get-Credential cmdlet. You can then set the Credential parameter to the PSCredential object. + +.EXAMPLE +$cred = Get-Credential +Add-PCAuthentication -CspAppId '<native app id Guid>' -CspDomain '<csp partner domain>' -Credential $cred + +Set a global token for the script session - App+User authentication + +.EXAMPLE +$clientSecret = '<key code secret>' +$clientSecretSecure = $clientSecret | ConvertTo-SecureString -AsPlainText -Force +Add-PCAuthentication -CspAppId '<web app id Guid>' -CspDomain '<csp partner domain>' -CspClientSecret $clientSecretSecure + +Set a global token for the script session - App authentication +.NOTES +Some cmdlets require App+User authentication. If you are working with invoices or users, you should use App+User authentication. + +$clientSecret = '<key code secret>' +$clientSecretSecure = $clientSecret | ConvertTo-SecureString -AsPlainText -Force +$cred = Get-Credential + +#> +function Add-PCAuthentication { [CmdletBinding()] - param ([Parameter(Mandatory=$True,ParameterSetName='app')][Parameter(Mandatory=$True,ParameterSetName='user')][string] $cspAppID, - [Parameter(Mandatory=$True,ParameterSetName='app')][Parameter(Mandatory=$True,ParameterSetName='user')][string] $cspDomain, - [Parameter(Mandatory=$True,ParameterSetName='app' )][SecureString]$cspClientSecret, - [Parameter(Mandatory=$True,ParameterSetName='user')][PSCredential]$credential + param ([Parameter(Mandatory = $True, ParameterSetName = 'app')][Parameter(Mandatory = $True, ParameterSetName = 'user')][string] $CspAppId, + [Parameter(Mandatory = $True, ParameterSetName = 'app')][Parameter(Mandatory = $True, ParameterSetName = 'user')][string] $CspDomain, + [Parameter(Mandatory = $True, ParameterSetName = 'app' )][SecureString]$CspClientSecret, + [Parameter(Mandatory = $True, ParameterSetName = 'user')][PSCredential]$Credential ) - function Private:Add-AuthenticationByUser ($cspAppID,$cspDomain,[PSCredential]$credential) - { - $resource = 'https://api.partnercenter.microsoft.com' - $AADToken = Get-GraphAADTokenByUser -resource $resource -domain $cspDomain -clientid $cspAppID -credential $credential - $cspUsername = $credential.UserName + function Private:Add-AuthenticationByUser ($CspAppId, $CspDomain, [PSCredential]$Credential) { + $Resource = 'https://api.partnercenter.microsoft.com' + $AadToken = Get-GraphAADTokenByUser -Resource $Resource -Domain $CspDomain -ClientId $CspAppId -Credential $Credential + $CspUserName = $Credential.UserName # Get SA token try { - $SAToken = Get-SAToken -aadtoken $AADToken -global $true - $token = @{"Resource" = $resource ; "Domain" = $cspDomain; "ClientId" = $cspAppID; "Username" = $cspUsername} + $SaToken = Get-SAToken -AadToken $AADToken -global $true + $token = @{"Resource" = $Resource ; "Domain" = $CspDomain; "ClientId" = $CspAppId; "Username" = $CspUserName} return $token } - catch - { + catch { $ErrorMessage = $_.Exception.Message "Cannot retrieve the token: $ErrorMessage" } } - function Private:Add-AuthenticationBySecret ($cspAppID,$cspDomain,$cspClientSecret) - { + function Private:Add-AuthenticationBySecret ($CspAppId, $CspDomain, $CspClientSecret) { $resource = 'https://graph.windows.net' - $AADToken = Get-GraphAADTokenByApp -resource $resource -domain $cspDomain -clientid $cspAppID -clientsecret $cspClientSecret + $AADToken = Get-GraphAADTokenByApp -Resource $resource -Domain $CspDomain -ClientId $CspAppId -ClientSecret $CspClientSecret # Get SA token try { - $SAToken = Get-SAToken -aadtoken $AADToken -global $true - $token = @{"Resource" = $resource ; "Domain" = $cspDomain; "ClientId" = $cspAppID} + $SaToken = Get-SAToken -AadToken $AADToken -Global $true + $token = @{"Resource" = $resource ; "Domain" = $CspDomain; "ClientId" = $CspAppId} return $token } - catch - { + catch { $ErrorMessage = $_.Exception.Message "Cannot retrieve the token: $ErrorMessage" } } - switch ($PsCmdlet.ParameterSetName) - { - "user" { $result = Add-AuthenticationByUser -cspAppID $cspAppID -cspDomain $cspDomain -credential $credential } - "app" { $result = Add-AuthenticationBySecret -cspAppID $cspAppID -cspDomain $cspDomain -cspClientSecret $cspClientSecret } + switch ($PsCmdlet.ParameterSetName) { + "user" { $result = Add-AuthenticationByUser -CspAppId $CspAppId -CspDomain $CspDomain -Credential $Credential } + "app" { $result = Add-AuthenticationBySecret -CspAppId $CspAppId -CspDomain $CspDomain -CspClientSecret $CspClientSecret } } return $result } -function New-PCSAToken -{ +<# +.SYNOPSIS +Creates an access token for the Partner Center API. + +.DESCRIPTION +The New-PCSaToken cmdlet returns a token used the access Partner Center resources. + +.PARAMETER CspAppId +Specifies a application Id generated for the Partner Center account. The application id must match the authentication type chosen. + +.PARAMETER CspDomain +Specifies the Partner Center tenant (onmicrosoft.com) domain. + +.PARAMETER CspClientSecret +Specifies an application secret key generated from the Partner Center portal. + +.PARAMETER Credential +Specifies the user account credentials to use to perform this task. To specify this parameter, you can type a user name, such as User1 or Domain01\User01 or you can specify a PSCredential object. If you specify a user name for this parameter, the cmdlet prompts for a password. +You can also create a PSCredential object by using a script or by using the Get-Credential cmdlet. You can then set the Credential parameter to the PSCredential object. + +.EXAMPLE +Creates a new token using the specified information. +$sat = New-PCSaToken -CspAppId 97037612-799c-4fa6-8c40-68be72c6b83c -CspDomain contoso.onmicrosoft.com -CspClientSecret $ClientSecretSecure -Credential $cred + +.EXAMPLE +Set a specific token for a command/function - user authentication ## +$cred = Get-Credential +New-PCSaToken -CspAppId '<native app id GUID>' -CspDomain '<csp partner domain>' -Credential $cred + +.EXAMPLE +Set a specific token for a command/function - app authentication ## + +$clientSecret = '<key code secret>' +$clientSecretSecure = $clientSecret | ConvertTo-SecureString -AsPlainText -Force +New-PCSaToken -CspAppId '<native app id GUID>' -CspDomain '<csp partner domain>' -CspClientSecret $clientSecretSecure + +.NOTES +$cred = Get-Credential +clientSecret = 'NQSm6Wjsd7PcDeP5JD6arEWMF3UghEpWmphGrshxzsQ=' +$ClientSecretSecure = $clientSecret | ConvertTo-SecureString -AsPlainText -Force + +#> +function New-PCSaToken { [CmdletBinding()] - param ([Parameter(Mandatory=$True,ParameterSetName='app')][Parameter(Mandatory=$True,ParameterSetName='user')][string] $cspAppID, - [Parameter(Mandatory=$True,ParameterSetName='app')][Parameter(Mandatory=$True,ParameterSetName='user')][string] $cspDomain, - [Parameter(Mandatory=$True,ParameterSetName='app' )][SecureString]$cspClientSecret, - [Parameter(Mandatory=$True,ParameterSetName='user')][PSCredential]$credential + param ([Parameter(Mandatory = $True, ParameterSetName = 'app')][Parameter(Mandatory = $True, ParameterSetName = 'user')][string] $CspAppId, + [Parameter(Mandatory = $True, ParameterSetName = 'app')][Parameter(Mandatory = $True, ParameterSetName = 'user')][string] $CspDomain, + [Parameter(Mandatory = $True, ParameterSetName = 'app' )][SecureString]$CspClientSecret, + [Parameter(Mandatory = $True, ParameterSetName = 'user')][PSCredential]$Credential ) - function Private:Add-AuthenticationByUser ($cspAppID,$cspDomain,[PSCredential]$credential) - { + function Private:Add-AuthenticationByUser ($CspAppId, $CspDomain, [PSCredential]$Credential) { $resource = 'https://api.partnercenter.microsoft.com' - $AADToken = Get-GraphAADTokenByUser -resource $resource -domain $cspDomain -clientid $cspAppID -credential $credential - $cspUsername = $credential.UserName + $AADToken = Get-GraphAADTokenByUser -Resource $resource -Domain $CspDomain -ClientId $CspAppId -Credential $Credential + $CspUserName = $Credential.UserName # Get SA token try { - $SAToken = Get-SAToken -aadtoken $AADToken -global $false - $token = @{"Resource" = $resource ; "Domain" = $cspDomain; "ClientId" = $cspAppID; "Username" = $cspUsername} - $objToReturn = @($SAToken,$token) + $SAToken = Get-SAToken -AadToken $AADToken -Global $false + $token = @{"Resource" = $resource ; "Domain" = $CspDomain; "ClientId" = $CspAppId; "Username" = $CspUserName} + $objToReturn = @($SAToken, $token) return $objToReturn } - catch - { + catch { $ErrorMessage = $_.Exception.Message "Cannot retrieve the token: $ErrorMessage" } } - function Private:Add-AuthenticationBySecret ($cspAppID,$cspDomain,$cspClientSecret) - { + function Private:Add-AuthenticationBySecret ($CspAppId, $CspDomain, $CspClientSecret) { $resource = 'https://graph.windows.net' - $AADToken = Get-GraphAADTokenByApp -resource $resource -domain $cspDomain -clientid $cspAppID -clientsecret $cspClientSecret + $AADToken = Get-GraphAADTokenByApp -Resource $resource -Domain $CspDomain -ClientId $CspAppId -ClientSecret $CspClientSecret # Get SA token try { - $SAToken = Get-SAToken -aadtoken $AADToken -global $false - $token = @{"Resource" = $resource ; "Domain" = $cspDomain; "ClientId" = $cspAppID} - $objToReturn = @($SAToken,$token) + $SAToken = Get-SAToken -AadToken $AADToken -Global $false + $token = @{"Resource" = $resource ; "Domain" = $CspDomain; "ClientId" = $CspAppId} + $objToReturn = @($SAToken, $token) return $objToReturn } - catch - { + catch { $ErrorMessage = $_.Exception.Message "Cannot retrieve the token: $ErrorMessage" } } - switch ($PsCmdlet.ParameterSetName) - { - "user" { $result_arr = Add-AuthenticationByUser -cspAppID $cspAppID -cspDomain $cspDomain -credential $credential - $result = $result_arr[0]} - "app" { $result_arr = Add-AuthenticationBySecret -cspAppID $cspAppID -cspDomain $cspDomain -cspClientSecret $cspClientSecret - $result = $result_arr[0]} + switch ($PsCmdlet.ParameterSetName) { + "user" { + $result_arr = Add-AuthenticationByUser -CspAppId $CspAppId -CspDomain $CspDomain -Credential $Credential + $result = $result_arr[0] + } + "app" { + $result_arr = Add-AuthenticationBySecret -CspAppId $CspAppId -CspDomain $CspDomain -CspClientSecret $CspClientSecret + $result = $result_arr[0] + } } return $result diff --git a/PartnerCenterModule/PartnerCenterCustomer.psm1 b/PartnerCenterModule/PartnerCenterCustomer.psm1 index 9d7a518..fb0a045 100644 --- a/PartnerCenterModule/PartnerCenterCustomer.psm1 +++ b/PartnerCenterModule/PartnerCenterCustomer.psm1 @@ -1,6 +1,6 @@ Set-StrictMode -Version latest <# - © 2017 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. + © 2018 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. This sample code is provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, @@ -12,192 +12,303 @@ $here = Split-Path -Parent $MyInvocation.MyCommand.Path . "$here\commons.ps1" -function Get-PCCustomer -{ +<# +.SYNOPSIS +Returns a list of customers or a specified customer. + +.DESCRIPTION +The Get-PCCustomer cmdlet retrieves a list of customers, or a specified customer. + +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. + +.PARAMETER TenantId +The tenant Id assigned to the customer you want to retrieve. + +.PARAMETER ResultSize +Specifies the maximum number of results to return. The default value is 200. + +.PARAMETER StartsWith +Specifies a filter for the customer names returned. + +.EXAMPLE +Return a list of customers for a partner. + +Get-PCCustomer + +.EXAMPLE +Return a customer by specifying an Id + +$customer = Get-PCCustomer -TenantId '<tenant id GUID>' + +.EXAMPLE +Return a customer by specifying part of the company name +Get-PCCustomer -StartsWith '<company name>' + +.NOTES +You need to have a authentication credential already established before running this cmdlet. + +#> +function Get-PCCustomer { [CmdletBinding()] Param( - [Parameter(ParameterSetName='all', Mandatory = $false)][switch]$all, - [Parameter(ParameterSetName='tenantid', Mandatory = $false)][String]$tenantid, - [Parameter(ParameterSetName='filter', Mandatory = $true)][String]$startswith, - [Parameter(ParameterSetName='filter',Mandatory = $false)][int]$size = 200, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken - ) - _testTokenContext($satoken) - - function Private:Get-CustomerAllInner ($satoken) - { - $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers" - $headers = @{Authorization="Bearer $satoken"} + [Parameter(ParameterSetName = 'TenantId', Mandatory = $false)][String]$TenantId, + [Parameter(ParameterSetName = 'filter', Mandatory = $true)][String]$StartsWith, + [Parameter(ParameterSetName = 'filter', Mandatory = $false)][int]$ResultSize = 200, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj += $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "Customer") - } + ) + _testTokenContext($SaToken) - function Private:Get-CustomerInner ($satoken,$tenantid) - { + function Private:Get-CustomerInner ($SaToken, $TenantId) { $obj = @() - if ($tenantid) - { - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} - - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj += $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "Customer") + if ($TenantId) { + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}" -f $TenantId + } - else - { + else { $url = "https://api.partnercenter.microsoft.com/v1/customers" - $headers = @{Authorization="Bearer $satoken"} - - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj += $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "Customer") + } + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) + + $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" + $obj += $response.Substring(1) | ConvertFrom-Json + return (_formatResult -obj $obj -type "Customer") } - function Private:Search-CustomerInner ($satoken, $startswith, $size) - { + function Private:Search-CustomerInner ($SaToken, $StartsWith, $ResultSize) { $obj = @() - [string]$filter = '{"Field":"CompanyName","Value":"' + $startswith + '","Operator":"starts_with"}' + [string]$filter = '{"Field":"CompanyName","Value":"' + $StartsWith + '","Operator":"starts_with"}' [Reflection.Assembly]::LoadWithPartialName("System.Web") | Out-Null $Encode = [System.Web.HttpUtility]::UrlEncode($filter) - $url = "https://api.partnercenter.microsoft.com/v1/customers?size={0}&filter={1}" -f $size,$Encode - $headers = @{Authorization="Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/customers?size={0}&filter={1}" -f $ResultSize, $Encode + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose + $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Customer") } - switch ($PsCmdlet.ParameterSetName) - { - "tenantid" {$res = Get-CustomerInner -satoken $satoken -tenantid $tenantid - return $res} - - "filter" {$res = Search-CustomerInner -satoken $satoken -startswith $startswith -size $size - return $res} - "all" {$res = Get-CustomerAllInner -satoken $satoken - return $res} + # replace the need to specify -all to retrieve all customers + if ($PsCmdlet.ParameterSetName -eq "TenantId") { + $res = Get-CustomerInner -SaToken $SaToken -TenantId $TenantId + return $res + } + elseif ($PsCmdlet.ParameterSetName -eq "filter") { + $res = Search-CustomerInner -SaToken $SaToken -StartsWith $StartsWith -ResultSize $ResultSize + return $res } + } -function Get-PCSubscribedSKUs -{ - [CmdletBinding()] - param ([Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) +<# +.SYNOPSIS +Returns a list of subscribed SKUs. - Write-Warning " Get-PCSubscribedSKUs is deprecated and will not be available in future releases, use Get-PCSubscribedSKU instead." +.DESCRIPTION +The Get-SubscribedSKU cmdlet retrieves a list of subscribed SKUs. - $obj = @() +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscribedskus" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} +.PARAMETER TenantId +The tenant Id assigned to the customer you want to retrieve. - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj += $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "SubscribedSku") -} +.EXAMPLE +Get-SubscribedSKU -TenantId 97037612-799c-4fa6-8c40-68be72c6b83c -# Add non-plural version of cmdlet. The plural version will be removed in future releases. -function Get-PCSubscribedSKU -{ +Return the subscribed SKUs for the specified TenantId +#> +function Get-PCSubscribedSKU { [CmdletBinding()] - param ([Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + param ([Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscribedskus" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscribedskus" -f $TenantId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "SubscribedSku") } - -function Get-PCSpendingBudget -{ +<# +.SYNOPSIS +Retrieves the spending budget for the specified tenant. +.DESCRIPTION +The Get-PCSpendingBudget cmdlet returns the spending budget set for the specified tenant. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.EXAMPLE +Get-PCSpendingBudget -TenantId 97037612-799c-4fa6-8c40-68be72c6b83c +.NOTES +#> +function Get-PCSpendingBudget { [CmdletBinding()] - param ([Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + param ([Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/usagebudget" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/usagebudget" -f $TenantId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "SpendingBudget") } -function Set-PCSpendingBudget -{ + +<# +.SYNOPSIS +Updates the spending budget for the specified tenant. +.DESCRIPTION +The Set-PCSpendingBudget cmdlet sets a spending budget for the specified tenant. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant for which to set the spending budget +.PARAMETER SpendingBudget +Specifies the spending budget in the default currency for the partner. +.EXAMPLE +Set-PCSpendingBudget -TenantId 97037612-799c-4fa6-8c40-68be72c6b83c -SpendingBudget 3000 +Sets the spending budget to 3000 USD +.NOTES +#> +function Set-PCSpendingBudget { [CmdletBinding()] - param ([Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - $spendingbudget, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + param ( + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $true)][String]$SpendingBudget, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken + ) + + _testTokenContext($SaToken) + _testTenantContext ($TenantId) + + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/usagebudget" -f $TenantId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/usagebudget" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} - $spendingbudget_tmp = [SpendingBudget]::new($spendingbudget) - $body = $spendingbudget_tmp | ConvertTo-Json -Depth 100 + $spendingBudget_tmp = [SpendingBudget]::new($spendingBudget) + $body = $spendingBudget_tmp | ConvertTo-Json -Depth 100 $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Body $body -Method "PATCH" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "CustomerSpendingBudget") } -function New-PCCustomer -{ +<# +.SYNOPSIS +Creates a new customer. +.DESCRIPTION +The New-PCCustomer cmdlet creates a new customer for the current partner. + +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. + +.PARAMETER Email +Specifies the contact email address for the new customer. +.PARAMETER Culture +Specifies the culture for the new customer as an three letter ISO 3 country code. +.PARAMETER Language +Specifies the default language for the new customer. + +.PARAMETER CompanyName +Specifies the company name for the new customer. +.PARAMETER Country +Specifies the country name for the new customer. The country must be valid for the current partner. +.PARAMETER Region +Specifies the region for the new customer. +.PARAMETER City +Specifies the city address for the new customer. +.PARAMETER State +Specifies the state address for the new customer. +.PARAMETER AddressLine1 +Specifies the first line of the address for the new customer. +.PARAMETER PostalCode +Specifies the postal code, if needed, for the new customer. +.PARAMETER FirstName +Specifies the the new customer's contact's first name. +.PARAMETER LastName +Specifies the the new customer's contact's last name. +.PARAMETER PhoneNumber +Specifies the the new customer's contact's phone number. +.PARAMETER BillingProfile +Specifies the billing profile. +.PARAMETER CompanyProfile +Specifies a company profile. +.PARAMETER Domain +Specifies the onmicrosoft.com for the new customer tenant. +.EXAMPLE +$newDefaultAddress = New-PCCustomerDefaultAddress -Country '<Country code>' -Region '<region>' -City '<City>' -State '<State>' -AddressLine1 '<address1>' -PostalCode '<postal code>' -FirstName '<first name>' -LastName '<last name>' -PhoneNumber '<phone number>' +$newBillingProfile = New-PCCustomerBillingProfile -FirstName '<first name>' -LastName '<last name>' -Email '<Email>' -Culture '<ex: en.us>' -Language '<ex: en>' -CompanyName '<company name>' -DefaultAddress $newDefaultAddress +$newCompanyProfile = New-PCCustomerCompanyProfile -Domain '<company name>.onmicrosoft.com' +$newCustomer = New-PCCustomer -BillingProfile $newBillingProfile -CompanyProfile $newCompanyProfile + +Create a new customer. +.NOTES +#> +function New-PCCustomer { [CmdletBinding()] - param ( [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string]$Email, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $Culture, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $Language, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $CompanyName, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $Country, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $Region, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $City, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $State, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $AddressLine1, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $PostalCode, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $FirstName, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $LastName, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $PhoneNumber, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $Domain, - [Parameter(ParameterSetName='ByProfiles',Mandatory = $true)][BillingProfile] $BillingProfile, - [Parameter(ParameterSetName='ByProfiles',Mandatory = $true)][CompanyProfile] $CompanyProfile, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) + param ( [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string]$Email, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $Culture, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $Language, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $CompanyName, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $Country, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $Region, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $City, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $State, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $AddressLine1, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $PostalCode, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $FirstName, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $LastName, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $PhoneNumber, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $Domain, + [Parameter(ParameterSetName = 'ByProfiles', Mandatory = $true)][BillingProfile] $BillingProfile, + [Parameter(ParameterSetName = 'ByProfiles', Mandatory = $true)][CompanyProfile] $CompanyProfile, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken) + _testTokenContext($SaToken) $obj = @() $url = "https://api.partnercenter.microsoft.com/v1/customers" - $headers = @{"Authorization"="Bearer $satoken"} - $headers += @{"MS-Contract-Version"="v1"} - $headers += @{"MS-RequestId"=[Guid]::NewGuid()} - $headers += @{"MS-CorrelationId"=[Guid]::NewGuid()} - - switch ($PsCmdlet.ParameterSetName) - { - 'AllDetails' { $customer = [Customer]::new($Email, $Culture, $Language, $CompanyName, $Country, $Region, $City, $State, $AddressLine1, ` - $PostalCode, $FirstName, $LastName, $PhoneNumber, $Domain) } + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) + + switch ($PsCmdlet.ParameterSetName) { + 'AllDetails' { + $customer = [Customer]::new($Email, $Culture, $Language, $CompanyName, $Country, $region, $City, $State, $AddressLine1, ` + $PostalCode, $FirstName, $LastName, $PhoneNumber, $Domain) + } 'ByProfiles' { $customer = [Customer]::new($BillingProfile, $CompanyProfile)} } @@ -208,57 +319,76 @@ function New-PCCustomer return (_formatResult -obj $obj -type "Customer") } -function Remove-PCCustomer -{ - [CmdletBinding()] - param ($tenantid, [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) +<# +.SYNOPSIS +Removes a customer from the Partner Center integration sandbox. - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}" -f $tenantid - $headers = @{"Authorization"="Bearer $satoken"} +.DESCRIPTION +The Remove-PCCCustomer cmdlet removes a customer from the integration sandbox. - $response = try - { - Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "DELETE" #-Debug -Verbose - } - catch - { - $_.Exception.Response - } +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. - return ($response) -} +.EXAMPLE +Remove-PCCustomer -TenantId 97037612-799c-4fa6-8c40-68be72c6b83c -function Get-PCManagedServices -{ +.NOTES +#> +function Remove-PCCustomer { [CmdletBinding()] - param ([Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + param ( + $TenantId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken + ) + _testTokenContext($SaToken) - Write-Warning " Get-PCManagedServices is deprecated and will not be available in future releases, use Get-PCManagedService instead." + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}" -f $TenantId - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/managedservices" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) - $obj = @() - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj += $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "ManagedServices") + $response = try { + Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "DELETE" #-Debug -Verbose + } + catch { + $_.Exception.Response + } + + return ($response) } -# Adding non-plural noun version of cmdlet. Plural version of the cmdlet will be removed in future versions. -function Get-PCManagedService -{ +<# +.SYNOPSIS +Returns a list of managed services. +.DESCRIPTION +The Get-PCManagedService cmdlet returns a list of managed services for the specified +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.EXAMPLE +Get-PCManagedService -TenantId 97037612-799c-4fa6-8c40-68be72c6b83c +Return a list of managed services for the specified tenant. + +.NOTES +#> +function Get-PCManagedService { [CmdletBinding()] - param ([Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + param ( + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken + ) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) + + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/managedservices" -f $TenantId - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/managedservices" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $obj = @() $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose @@ -267,18 +397,35 @@ function Get-PCManagedService } -function Select-PCCustomer -{ +<# +.SYNOPSIS +Selects a customer to be used in other cmdlets. +.DESCRIPTION +The Select-PCCustomer cmdlet selects a customer tenant specified by the tenant id. + +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.EXAMPLE +Select-PCCustomer -TenantId 97037612-799c-4fa6-8c40-68be72c6b83c + +.NOTES +#> +function Select-PCCustomer { [CmdletBinding()] Param( - [Parameter(ParameterSetName='tenantid', Mandatory = $true)][String]$tenantid, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(ParameterSetName = 'TenantId', Mandatory = $true)][String]$TenantId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}" -f $TenantId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json @@ -289,18 +436,34 @@ function Select-PCCustomer return (_formatResult -obj $obj -type "Customer") } -function Get-PCCustomerRelationships -{ +<# +.SYNOPSIS +Returns the type of relationship the specified tenant has with the current partner for an indirect partner. +.DESCRIPTION +The Get-PCCustomerRelationship cmdlet returns the relationship the specified customer has with the current partner. This cmdlet can only be used for an indirect partner. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.EXAMPLE +Get-PCCustomerRelationship -TenantId 97037612-799c-4fa6-8c40-68be72c6b83c +.NOTES +This can only be used in an indirect model. +#> +function Get-PCCustomerRelationship { [CmdletBinding()] - param ([Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + param ( + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken + ) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) - Write-Warning " Get-PCCustomerRelationships is deprecated and will not be available in future releases, use Get-PCCustomerRelationship instead." + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/relationships" -f $TenantId - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/relationships" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $obj = @() $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose @@ -308,70 +471,45 @@ function Get-PCCustomerRelationships return (_formatResult -obj $obj -type "PartnerRelationship") } -# Adding non-plural noun version of cmdlet. Plural version of the cmdlet will be removed in future versions. -function Get-PCCustomerRelationship -{ - [CmdletBinding()] - param ([Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) - - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/relationships" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} - $obj = @() - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj += $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "PartnerRelationship") -} - -function Get-PCResellerCustomers -{ +<# +.SYNOPSIS +Returns a list of reseller customers for the specified indirect provider. + +.DESCRIPTION +The Get-PCResellerCustomer cmdlet returns a list of reseller customers or a specified reseller for the current indirect provider. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER ResellerId +Specifies the reseller id for which to return customers. +.PARAMETER ResultSize +Specifies the maximum number of results to return. The default value is 200. +.EXAMPLE +Get-PCResellerCustomer -ResellerId '86f61a80-23de-4071-ba9f-249254da7e95' +Return a list of customers for the specified reseller id +.NOTES +#> +function Get-PCResellerCustomer { [CmdletBinding()] Param( - [Parameter(ParameterSetName='filter', Mandatory = $true)][String]$resellerId, - [Parameter(ParameterSetName='filter', Mandatory = $false)][int]$size = 200, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(ParameterSetName = 'filter', Mandatory = $true)][String]$ResellerId, + [Parameter(ParameterSetName = 'filter', Mandatory = $false)][int]$ResultSize= 200, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) - Write-Warning " Get-PCResellerCustomers is deprecated and will not be available in future releases, use Get-PCResellerCustomer instead." $obj = @() - [string]$filter = '{"Field":"IndirectReseller","Value":"' + $resellerId + '","Operator":"starts_with"}' + [string]$filter = '{"Field":"IndirectReseller","Value":"' + $ResellerId + '","Operator":"starts_with"}' [Reflection.Assembly]::LoadWithPartialName("System.Web") | Out-Null $Encode = [System.Web.HttpUtility]::UrlEncode($filter) - $url = "https://api.partnercenter.microsoft.com/v1/customers?size={0}&filter={1}" -f $size,$Encode - $headers = @{Authorization="Bearer $satoken"} - - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj += $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "Customer") -} - -# Add non-plural noun version of cmdlet. Plural version of the cmdlet will be removed in future versions. -function Get-PCResellerCustomer -{ - [CmdletBinding()] - - Param( - [Parameter(ParameterSetName='filter', Mandatory = $true)][String]$resellerId, - [Parameter(ParameterSetName='filter', Mandatory = $false)][int]$size = 200, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken - ) - _testTokenContext($satoken) - - $obj = @() - - [string]$filter = '{"Field":"IndirectReseller","Value":"' + $resellerId + '","Operator":"starts_with"}' - [Reflection.Assembly]::LoadWithPartialName("System.Web") | Out-Null - $Encode = [System.Web.HttpUtility]::UrlEncode($filter) + $url = "https://api.partnercenter.microsoft.com/v1/customers?size={0}&filter={1}" -f $ResultSize, $Encode - $url = "https://api.partnercenter.microsoft.com/v1/customers?size={0}&filter={1}" -f $size,$Encode - $headers = @{Authorization="Bearer $satoken"} + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json diff --git a/PartnerCenterModule/PartnerCenterDirectory.psm1 b/PartnerCenterModule/PartnerCenterDirectory.psm1 index aa8f3bd..6d01205 100644 --- a/PartnerCenterModule/PartnerCenterDirectory.psm1 +++ b/PartnerCenterModule/PartnerCenterDirectory.psm1 @@ -1,6 +1,6 @@ Set-StrictMode -Version latest <# - © 2017 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. + © 2018 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. This sample code is provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, @@ -12,22 +12,38 @@ $here = Split-Path -Parent $MyInvocation.MyCommand.Path . "$here\commons.ps1" +<# +.SYNOPSIS +Tests to see if the specified onmicrosoft.com is available to be used for a new tenant. + +.DESCRIPTION +The Get-PCDomainAvailability cmdlet tests to see if the specified tenant domain (onmicrosoft.com) is available to create a new tenant. + +.PARAMETER SaToken +Specifies a security token for authenticating and executing the cmdlet. + +.PARAMETER Domain +Specifies a onmicrosoft.com domain to check as to whether is available for use for a new tenant. + +.EXAMPLE +Get-PCDomainAvailability -Domain contoso.onmicrosoft.com + +Test to see if contoso.onmicrosoft.com is available for a new tenant. +.NOTES +#> function Get-PCDomainAvailability { [CmdletBinding()] param ( - [Parameter(Mandatory = $true)] - [string]$domain, - - [Parameter(Mandatory = $false)] - [string]$satoken = $GlobalToken + [Parameter(Mandatory = $true)][string]$Domain, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) try { - $url = "https://api.partnercenter.microsoft.com/v1/domains/{0}" -f $domain + $url = "https://api.partnercenter.microsoft.com/v1/domains/{0}" -f $Domain $headers = @{Authorization="Bearer $GlobalToken"} $null = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "HEAD" #-Debug -Verbose return $false @@ -44,98 +60,236 @@ function Get-PCDomainAvailability } } +<# +.SYNOPSIS +Returns a list of customer roles. +.DESCRIPTION +The Get-PCCustomerRole cmdlet retrieves a list of customer roles. +.PARAMETER SaToken +Specifies a security token for authenticating and executing the cmdlet. + +.PARAMETER TenantId +Specifies the tenant id for which to return the customer roles. +.EXAMPLE +Get-PCCustomerRole + +.NOTES +#> function Get-PCCustomerRole { [CmdletBinding()] - param ([Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + param ([Parameter(Mandatory = $false)][String]$TenantId=$GlobalCustomerId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/directoryroles" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/directoryroles" -f $TenantId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "DirectoryRoles") } +<# +.SYNOPSIS +Returns a list of members for the specified customer role. +.DESCRIPTION +The Get-PCCustomerRoleMember cmdlet retrieves a list of customer role members. + +.PARAMETER SaToken +Specifies a security token for authenticating and executing the cmdlet. + +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. + +.PARAMETER RoleId +Specifies the role id + +.EXAMPLE +Get-PCCustomerRoleMember + +.NOTES +#> function Get-PCCustomerRoleMember { [CmdletBinding()] param ( - [Parameter(Mandatory = $true)][string]$roleid, - [Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + [Parameter(Mandatory = $true)][string]$RoleId, + [Parameter(Mandatory = $false)][String]$TenantId=$GlobalCustomerId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/directoryroles/{1}/usermembers" -f $tenantid, $roleid - $headers = @{Authorization="Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/directoryroles/{1}/usermembers" -f $TenantId, $RoleId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "DirectoryRolesUser") } +<# +.SYNOPSIS +Adds a customer user account to the specified role. +.DESCRIPTION +The Add-PCCustomerRoleMember cmdlet adds a customer user account into a role. + +.PARAMETER SaToken +Specifies a security token for authenticating and executing the cmdlet. + +.PARAMETER TenantId +Specifies the tenant for which to add the role member. + +.PARAMETER RoleId +Specifies the role id for which to add the member. + +.PARAMETER CustomerRoleMember +Specifies the member to add to the role. + +.EXAMPLE +Specify a customer + $customer = Get-PCCustomer -TenantId '<Tenant Id Guid>' + +Get a role + + $role = Get-PCCustomerRole -TenantId $customer.id | Where-Object name -Contains '<role name>' + +Get a User + + $user = Get-PCCustomerUser -TenantId $customer.id -UserId '<User id Guid>' + +Add a User to a Role + + $customerRoleMember = [DirectoryRoleMember]::new() + $customerRoleMember.id = $user.id + Add-PCCustomerRoleMember -TenantId $customer.id -RoleId $role.id -CustomerRoleMember $customerRoleMember +.NOTES +#> function Add-PCCustomerRoleMember { [CmdletBinding()] - param ([Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $true)][string]$roleid, - [Parameter(Mandatory = $true,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)][PSCustomObject]$customerrolemember, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + param ( + [Parameter(Mandatory = $false)][String]$TenantId=$GlobalCustomerId, + [Parameter(Mandatory = $true)][string]$RoleId, + [Parameter(Mandatory = $true,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)][PSCustomObject]$CustomerRoleMember, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken + ) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/directoryroles/{1}/usermembers" -f $tenantid, $roleid - $headers = @{Authorization="Bearer $satoken"} - $headers += @{"MS-RequestId"=[Guid]::NewGuid()} - $headers += @{"MS-CorrelationId"=[Guid]::NewGuid()} - $body = $customerrolemember | ConvertTo-Json -Depth 100 + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/directoryroles/{1}/usermembers" -f $TenantId, $RoleId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) + + $body = $CustomerRoleMember | ConvertTo-Json -Depth 100 $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Body $body -Method "POST" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "DirectoryRolesUser") } +<# +.SYNOPSIS +Removes the specified user id from the specified role id. +.DESCRIPTION +The Remove-PCCustomerRoleMember cmdlet removes the specified user from the specified role. +.PARAMETER SaToken +Specifies a security token for authenticating and executing the cmdlet. + +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. + +.PARAMETER RoleId +Specifies the role guid for which to remove the user. +.PARAMETER UserId +Specifies the user id to remove from the role. +.EXAMPLE +Remove a user from a specified role. + +Get a customer + $customer = Get-PCCustomer | Where-Object {$_.CompanyProfile.CompanyName -eq 'Wingtip Toys'} + +Get a role named Helpdesk Administrator + + $role = Get-PCCustomerRole -TenantId $c.id | Where-Object {$_.Name -eq 'Helpdesk Administrator'} + +Get a User + + $user = Get-PCCustomerUser -TenantId $customer.id | Where-Object {$_.userPrincipalName -eq 'John@wingtiptoyscsptest.onmicrosoft.com'} + +Remove a user from a role + + Remove-PCCustomerRoleMember -TenantId $customer.id -RoleId $Role.Id -UserId $User.Id + +.NOTES +#> function Remove-PCCustomerRoleMember { [CmdletBinding()] - param ( [Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $true)][string]$roleid, - [Parameter(Mandatory = $true)][string]$userid, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + param ( [Parameter(Mandatory = $false)][String]$TenantId=$GlobalCustomerId, + [Parameter(Mandatory = $true)][string]$RoleId, + [Parameter(Mandatory = $true)][string]$UserId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/directoryroles/{1}/usermembers/{2}" -f $tenantid, $roleid, $userid - $headers = @{Authorization="Bearer $satoken"} - $headers += @{"MS-RequestId"=[Guid]::NewGuid()} - $headers += @{"MS-CorrelationId"=[Guid]::NewGuid()} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/directoryroles/{1}/usermembers/{2}" -f $TenantId, $RoleId, $UserId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "DELETE" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "DirectoryRolesUser") } +<# +.SYNOPSIS +Returns the request text to send to the end customer administrator to initiate a relationship with the partner. + +.DESCRIPTION +The New-PCRelationshipRequest cmdlet. + +.PARAMETER SaToken +Specifies a security token for authenticating and executing the cmdlet. + +.EXAMPLE +$inviteUrl = (New-PCRelationshipRequest).Url + +Get an invitation Url to send to a new customer. +#> function New-PCRelationshipRequest { [CmdletBinding()] - param ([Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) + param ( + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken + ) + _testTokenContext($SaToken) $obj = @() $url = "https://api.partnercenter.microsoft.com/v1/customers/relationshiprequests" - $headers = @{"Authorization"="Bearer $satoken"} + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" -Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json diff --git a/PartnerCenterModule/PartnerCenterInvoice.psm1 b/PartnerCenterModule/PartnerCenterInvoice.psm1 index 7f4beee..106cfa6 100644 --- a/PartnerCenterModule/PartnerCenterInvoice.psm1 +++ b/PartnerCenterModule/PartnerCenterInvoice.psm1 @@ -1,6 +1,6 @@ Set-StrictMode -Version latest <# - © 2017 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. + © 2018 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. This sample code is provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, @@ -13,125 +13,148 @@ $here = Split-Path -Parent $MyInvocation.MyCommand.Path . "$here\commons.ps1" -function Get-PCInvoice -{ +<# +.SYNOPSIS +Returns a list of all invoices or a specified invoice. +.DESCRIPTION +The Get-PCInvoice cmdlet retrieves either a specific invoice or a list of invoices. This cmdlet requires App+User authentication. + +.PARAMETER SaToken +Specifies a security token for authenticating and executing the cmdlet. + +.PARAMETER InvoiceId +Specifies an invoice id to return. + +.PARAMETER Summary +Specifies whether to retrieve a summary of the invoice. + +.EXAMPLE +Get-PCInvoice +Return a list of all invoices. + +.EXAMPLE +Get-PCInvoice -InvoiceId D030001IZ6 +Return the specified invoice + +.EXAMPLE +Get-PCInvoice -InvoiceId D030001IZ6 -Summary +Return a summary for the specified invoice + +.NOTES +This cmdlet requires App+User authentication. +#> +function Get-PCInvoice { [CmdletBinding()] Param( - [Parameter(ParameterSetName='allinvoices', Mandatory = $false)][switch]$all, - [Parameter(ParameterSetName='invoice', Mandatory = $false)][String]$invoiceid, - [Parameter(ParameterSetName='summary',Mandatory = $false)][switch]$summary, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken - #[Parameter(ParameterSetName='detailurl',Mandatory = $false)][switch]$detailurl + [Parameter(Mandatory = $false)][String]$InvoiceId, + [Parameter(Mandatory = $false)][switch]$Summary, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken + #[Parameter(ParameterSetName='detailUrl',Mandatory = $false)][switch]$detailUrl ) - _testTokenContext($satoken) + _testTokenContext($SaToken) - function Private:Get-InvoiceSummaryInner($satoken) - { + function Private:Get-InvoiceSummaryInner($SaToken) { $obj = @() $url = "https://api.partnercenter.microsoft.com/v1/invoices/summary" - $headers = @{Authorization="Bearer $satoken"} + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response return (_formatResult -obj $obj -type "Invoice") } - function Private:Get-InvoiceByIdInner($satoken, $invoiceid) - { + function Private:Get-InvoiceByIdInner($SaToken, $InvoiceId) { $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/invoices/{0}" -f $invoiceid - $headers = @{Authorization="Bearer $satoken"} - + if ($InvoiceId -ne $null) { + $url = "https://api.partnercenter.microsoft.com/v1/invoices/{0}" -f $InvoiceId + } + else { + + $url = "https://api.partnercenter.microsoft.com/v1/invoices" + } + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) + $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response return (_formatResult -obj $obj -type "Invoice") } - function Private:Get-AllInvoicesInner($satoken) - { - $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/invoices" - $headers = @{Authorization="Bearer $satoken"} - - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj += $response - return (_formatResult -obj $obj -type "Invoice") + If ($Summary) { + $res = Get-InvoiceSummaryInner -SaToken $SaToken + return $res } - -<#deprecated - function Private:Get-InvoiceDetailInner($satoken, $detailurl) - { - $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1{0}" -f $detailurl - $headers = @{Authorization="Bearer $satoken"} - - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj += $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "Invoice") + else { + $res = Get-InvoiceByIdInner -SaToken $SaToken -InvoiceID $InvoiceId + return $res } -#> - switch ($PsCmdlet.ParameterSetName) - { - "summary" {$res = Get-InvoiceSummaryInner -satoken $satoken - return $res} - "invoice"{$res = Get-InvoiceByIdInner -satoken $satoken -invoiceID $invoiceid - return $res} - "allinvoices" {$res = Get-AllInvoicesInner -satoken $satoken - return $res} - <#deprecated - "detailurl" {$res = Get-InvoiceDetailInner -satoken $satoken -detailurl $detailurl + <#"allInvoices" {$res = Get-AllInvoicesInner -SaToken $SaToken + return $res} + #> + <#deprecated + "detailUrl" {$res = Get-InvoiceDetailInner -SaToken $SaToken -detailUrl $detailUrl return $res} #> - } } -function Get-PCInvoiceLineItems -{ - [CmdletBinding()] +<# +.SYNOPSIS +Returns information about a specified invoice line item. This cmdlet requires App+User authentication. - Param( - [Parameter(Mandatory = $true)][String]$invoiceid, - [Parameter(Mandatory = $true)][ValidateSet("Azure","Office")][string]$billingprovider, - [Parameter(Mandatory = $true)][ValidateSet("BillingLineItems","UsageLineItems")][string]$invoicelineitemtype, - [Parameter(Mandatory = $false)][int]$size = 200, - [Parameter(Mandatory = $false)][int]$offset = 0, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken - ) - _testTokenContext($satoken) +.DESCRIPTION +The Get-PCInvoiceLineItem cmdlet retrieves a specified invoice line item. - Write-Warning " Get-PCInvoiceLineItems is deprecated and will not be available in future releases, use Get-PCInvoiceLineItem instead." +.PARAMETER SaToken +Specifies a security token for authenticating and executing the cmdlet. - $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/invoices/{0}/lineitems/{1}/{2}?size={3}&offset={4}" -f $invoiceid, $billingprovider, $invoicelineitemtype, $size, $offset +.PARAMETER InvoiceId +Specifies the invoice id to retrieve. - $headers = @{Authorization="Bearer $satoken"} +.PARAMETER BillingProvider +Specifies either Azure or Office. - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj += $response - return (_formatResult -obj $obj -type "Invoice") -} +.PARAMETER InvoiceLineItemType +Specifies either BillingLineItems for invoiced licence-based services or UsageLineItems for invoiced usage-based services. + +.PARAMETER ResultSize +Specifies the maximum number of results to return. The default value is 200. -# Adding non-plural noun version of cmdlet. Plural version of the cmdlet will be removed in future versions. -function Get-PCInvoiceLineItem -{ +.PARAMETER Offset +Specifies an offset + +.EXAMPLE +Get-PCInvoiceLineItem -InvoiceId 12345678 -BillingProvider Azure -InvoiceLineItemType UsageLineItems + +Retrieve a list of Azure usage from invoice 12345678. + +.NOTES +#> +function Get-PCInvoiceLineItem { [CmdletBinding()] Param( - [Parameter(Mandatory = $true)][String]$invoiceid, - [Parameter(Mandatory = $true)][ValidateSet("Azure","Office")][string]$billingprovider, - [Parameter(Mandatory = $true)][ValidateSet("BillingLineItems","UsageLineItems")][string]$invoicelineitemtype, - [Parameter(Mandatory = $false)][int]$size = 200, - [Parameter(Mandatory = $false)][int]$offset = 0, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $true)][String]$InvoiceId, + [Parameter(Mandatory = $true)][ValidateSet("Azure", "Office")][string]$BillingProvider, + [Parameter(Mandatory = $true)][ValidateSet("BillingLineItems", "UsageLineItems")][string]$InvoiceLineItemType, + [Parameter(Mandatory = $false)][int]$ResultSize= 200, + [Parameter(Mandatory = $false)][int]$Offset = 0, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/invoices/{0}/lineitems/{1}/{2}?size={3}&offset={4}" -f $invoiceid, $billingprovider, $invoicelineitemtype, $size, $offset + $url = "https://api.partnercenter.microsoft.com/v1/invoices/{0}/lineitems/{1}/{2}?size={3}&offset={4}" -f $InvoiceId, $BillingProvider, $InvoiceLineItemType, $ResultSize, $Offset - $headers = @{Authorization="Bearer $satoken"} + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response diff --git a/PartnerCenterModule/PartnerCenterModule.psd1 b/PartnerCenterModule/PartnerCenterModule.psd1 index 3d86124..adc42fc 100644 --- a/PartnerCenterModule/PartnerCenterModule.psd1 +++ b/PartnerCenterModule/PartnerCenterModule.psd1 @@ -1,24 +1,9 @@ -# -# Module manifest for module 'PartnerCenterModule' -# https://msdn.microsoft.com/en-us/library/dd878337(v=vs.85).aspx -# -<# - © 2017 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. - This sample code is provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, - any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance - of the sample code and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, - production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business - profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the - sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages. -#> - -@{ - +@{ # Script module or binary module file associated with this manifest RootModule = 'PartnerCenterModule.psm1' # Version number of this module. -ModuleVersion = '0.9.0.21' +ModuleVersion = '0.10.0.0' # ID used to uniquely identify this module GUID = '4a0bfb55-926c-4c31-8d05-50813b31c712' @@ -43,17 +28,13 @@ Description = 'Partner Center Powershell Module (preview)' FunctionsToExport = @('Add-PCAuthentication', 'Add-PCCustomerRoleMember', 'Get-PCAddressRulesByMarket', - 'Get-PCAuditRecords', 'Get-PCAuditRecord', 'Get-PCAzureRateCard', - 'Get-PCAzureResourceMonthlyUsageRecords', 'Get-PCAzureResourceMonthlyUsageRecord', 'Get-PCBillingProfile', 'Get-PCCustomer', 'Get-PCCustomerBillingProfile', 'Get-PCCustomerCompanyProfile', - 'Get-PCCustomerLicensesDeployment', - 'Get-PCCustomerLicensesUsage', 'Get-PCCustomerLicenseDeployment', 'Get-PCCustomerLicenseUsage', 'Get-PCCustomerServiceCostSummary', @@ -62,35 +43,27 @@ FunctionsToExport = @('Add-PCAuthentication', 'Get-PCCustomerUserRole', 'Get-PCCustomerRoleMember', 'Get-PCCustomerRole', - 'Get-PCCustomerRelationships', 'Get-PCCustomerRelationship', 'Get-PCDomainAvailability', 'Get-PCInvoice', - 'Get-PCInvoiceLineItems', 'Get-PCInvoiceLineItem', 'Get-PCLegalBusinessProfile', - 'Get-PCLicensesDeployment', 'Get-PCLicenseDeployment', 'Get-PCLicenseUsage', - 'Get-PCLicensesUsage', - 'Get-PCManagedServices', 'Get-PCManagedService', 'Get-PCMpnProfile', 'Get-PCOffer', 'Get-PCOfferCategoriesByMarket', 'Get-PCOrder', 'Get-PCOrganizationProfile', - 'Get-PCSAToken', + 'Get-PCSaToken', 'Get-PCSpendingBudget', 'Get-PCSR', - 'Get-PCSRTopics', 'Get-PCSRTopic', - 'Get-PCSubscribedSKUs', 'Get-PCSubscribedSKU', 'Get-PCSubscription', 'Get-PCSupportProfile', 'Get-PCUsage', - 'Get-PCUsage2', 'New-PCAddress', 'New-PCCustomer', 'New-PCCustomerBillingProfile', @@ -100,7 +73,7 @@ FunctionsToExport = @('Add-PCAuthentication', 'New-PCOrder', 'New-PCOrderLineItem', 'New-PCRelationshipRequest', - 'New-PCSAToken', + 'New-PCSaToken', 'New-PCSR', 'Remove-PCCustomer', 'Remove-PCCustomerUser', @@ -110,12 +83,9 @@ FunctionsToExport = @('Add-PCAuthentication', 'Set-PCBillingProfile', 'Set-PCCustomerBillingProfile', 'Set-PCCustomerUser', - 'Set-PCGraphUserPassword', 'Set-PCLegalBusinessProfile', 'Set-PCOrganizationProfile', - 'Get-PCIndirectResellers', 'Get-PCIndirectReseller', - 'Get-PCResellerCustomers', 'Get-PCResellerCustomer', 'Set-PCSpendingBudget', 'Set-PCSR', diff --git a/PartnerCenterModule/PartnerCenterModule.psm1 b/PartnerCenterModule/PartnerCenterModule.psm1 index 86d1836..27a6c50 100644 --- a/PartnerCenterModule/PartnerCenterModule.psm1 +++ b/PartnerCenterModule/PartnerCenterModule.psm1 @@ -1,7 +1,6 @@ -# v1.4.0.0 -Set-StrictMode -Version latest +Set-StrictMode -Version latest <# - © 2017 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. + © 2018 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. This sample code is provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, @@ -53,7 +52,7 @@ class CompanyProfile class DefaultAddress { [string] $Country - [string] $Region + [string] $region [string] $City [string] $State [string] $AddressLine1 @@ -64,7 +63,7 @@ class DefaultAddress [string] $PhoneNumber #main constructor - DefaultAddress ([string] $Country, [string] $Region, [string] $City, [string] $State, [string] $AddressLine1, ` + DefaultAddress ([string] $Country, [string] $region, [string] $City, [string] $State, [string] $AddressLine1, ` [string] $PostalCode, [string] $FirstName, [string] $LastName, [string] $PhoneNumber) { $this.Country = $Country @@ -76,12 +75,12 @@ class DefaultAddress $this.LastName = $LastName $this.PhoneNumber = $PhoneNumber - if(-not [string]::IsNullOrEmpty($Region)) { - $this.Region = $Region + if(-not [string]::IsNullOrEmpty($region)) { + $this.Region = $region } } - DefaultAddress ([string] $Country, [string] $Region, [string] $City, [string] $State, [string] $AddressLine1, ` + DefaultAddress ([string] $Country, [string] $region, [string] $City, [string] $State, [string] $AddressLine1, ` [string] $PostalCode) { $this.Country = $Country @@ -90,8 +89,8 @@ class DefaultAddress $this.AddressLine1 = $AddressLine1 $this.PostalCode = $PostalCode - if(-not [string]::IsNullOrEmpty($Region)) { - $this.Region = $Region + if(-not [string]::IsNullOrEmpty($region)) { + $this.Region = $region } } } @@ -111,14 +110,14 @@ class BillingProfile [Attributes] $Attributes #main constructors - BillingProfile ([string] $Email,[string] $Culture,[string] $Language,[string] $CompanyName, [string] $Country, [string] $Region, [string] $City, [string] $State, [string] $AddressLine1,[string] $PostalCode, [string] $FirstName, [string] $LastName, [string] $PhoneNumber) + BillingProfile ([string] $Email,[string] $Culture,[string] $Language,[string] $CompanyName, [string] $Country, [string] $region, [string] $City, [string] $State, [string] $AddressLine1,[string] $PostalCode, [string] $FirstName, [string] $LastName, [string] $PhoneNumber) { - $defaultAddresstmp = [DefaultAddress]::new($Country, $Region, $City,$State,$AddressLine1,$PostalCode,$FirstName,$LastName,$PhoneNumber) + $defaultAddressTmp = [DefaultAddress]::new($Country, $region, $City,$State,$AddressLine1,$PostalCode,$FirstName,$LastName,$PhoneNumber) $att_tmp = [Attributes]::new('BillingProfile') $this.FirstName = $FirstName $this.LastName = $LastName - $this.DefaultAddress = $defaultAddresstmp + $this.DefaultAddress = $defaultAddressTmp $this.Email = $Email $this.Culture = $Culture $this.Language = $Language @@ -160,20 +159,20 @@ class Customer #main constructors Customer ([string] $Email,[string] $Culture,[string] $Language,[string] $CompanyName, ` - [string] $Country, [string] $Region, [string] $City, [string] $State, [string] $AddressLine1, ` + [string] $Country, [string] $region, [string] $City, [string] $State, [string] $AddressLine1, ` [string] $PostalCode, [string] $FirstName, [string] $LastName, [string] $PhoneNumber, ` [string] $Domain) { - $defaultaddress_tmp = [DefaultAddress]::new($Country,$Region,$City,$State,$AddressLine1, ` + $defaultAddress_tmp = [DefaultAddress]::new($Country,$region,$City,$State,$AddressLine1, ` $PostalCode,$FirstName,$LastName,$PhoneNumber) - $billingprofile_tmp = [BillingProfile]::new($FirstName, $LastName, $Email,$Culture,$Language,$CompanyName,$defaultaddress_tmp) + $billingProfile_tmp = [BillingProfile]::new($FirstName, $LastName, $Email,$Culture,$Language,$CompanyName,$defaultAddress_tmp) - $companyprofile_tmp = [CompanyProfile]::new($Domain) + $companyProfile_tmp = [CompanyProfile]::new($Domain) $att_tmp = [Attributes]::new('Customer') - $this.CompanyProfile = $companyprofile_tmp - $this.BillingProfile = $billingprofile_tmp + $this.CompanyProfile = $companyProfile_tmp + $this.BillingProfile = $billingProfile_tmp $this.Attributes = $att_tmp } @@ -193,7 +192,8 @@ class CustomerUserPasswordProfile [bool] $forceChangePassword CustomerUserPasswordProfile ([SecureString] $password,[bool]$forceChangePassword) { - $this.password = _unsecureString -string $password + $this.password = _ + String -string $password $this.forceChangePassword = $forceChangePassword } } @@ -204,33 +204,33 @@ class CustomerUser [string] $Id [string] $usageLocation [string] $userPrincipalName - [string] $firstName - [string] $lastName + [string] $FirstName + [string] $LastName [string] $displayName [CustomerUserPasswordProfile] $passwordProfile [Attributes] $Attributes - CustomerUser ([string]$usageLocation ,[string] $userPrincipalName,[string] $firstName,[string] $lastName,[string] $displayName,[SecureString] $password,[bool] $forceChangePassword) + CustomerUser ([string]$usageLocation ,[string] $userPrincipalName,[string] $FirstName,[string] $LastName,[string] $displayName,[SecureString] $password,[bool] $forceChangePassword) { $passwordProfile_tmp = [CustomerUserPasswordProfile]::new($password,$forceChangePassword) $att_tmp = [Attributes]::new('CustomerUser') $this.usageLocation = $usageLocation $this.userPrincipalName = $userPrincipalName - $this.firstName = $firstName - $this.lastName = $lastName + $this.FirstName = $FirstName + $this.LastName = $LastName $this.displayName = $displayName $this.passwordProfile = $passwordProfile_tmp $this.Attributes = $att_tmp } <# - CustomerUser([string]$usageLocation ,[string] $userPrincipalName,[string] $firstName,[string] $lastName,[string] $displayName,[CustomerUserPasswordProfile]$CustomerUserPasswordProfile) + CustomerUser([string]$usageLocation ,[string] $userPrincipalName,[string] $FirstName,[string] $LastName,[string] $displayName,[CustomerUserPasswordProfile]$CustomerUserPasswordProfile) { $att_tmp = [Attributes]::new('CustomerUser') $this.usageLocation = $usageLocation $this.userPrincipalName = $userPrincipalName - $this.firstName = $firstName - $this.lastName = $lastName + $this.FirstName = $FirstName + $this.LastName = $LastName $this.displayName = $displayName $this.passwordProfile = $CustomerUserPasswordProfile $this.Attributes = $att_tmp @@ -280,7 +280,7 @@ class OrderLineItem [string] $FriendlyName [string] $PartnerIdOnRecord [string] $ParentSubscriptionId - #[psobject] $Links + #[PsObject] $Links OrderLineItem ([uint16] $LineItemNumber,[string] $OfferId,[uint16] $Quantity) { $this.LineItemNumber = $LineItemNumber @@ -370,7 +370,7 @@ class ServiceRequest [ServiceRequestContact] $PrimaryContact [ServiceRequestContact] $LastUpdatedBy [ServiceRequestOrganization] $Organization - [validateset('none','open','closed','attention_needed')][string] $Status + [ValidateSet('none','open','closed','attention_needed')][string] $Status #main constructor ServiceRequest ([string]$Title,[string]$Description,[string]$Severity,[string]$SupportTopicId) @@ -396,7 +396,7 @@ class _Filter [string]$Value [string]$Operator <# - [validateset('CONTAINS','NOT_CONTAINS','IS','IS_NOT','ARE','IN','NOT_IN', + [ValidateSet('CONTAINS','NOT_CONTAINS','IS','IS_NOT','ARE','IN','NOT_IN', 'IN_RANGE','NOT_IN_RANGE','STARTS_WITH','ENDS_WITH','ON_OR_BEFORE','ON_OR_AFTER','BETWEEN', 'EARLIER_THAN','WITHIN_THE_LAST','GREATER_THAN','LESS_THAN','IS_EMPTY','IS_NOT_EMPTY','INCLUDE' 'DO_NOT_INCLUDE','IS_APPLIED','IS_NOT_APPLIED', diff --git a/PartnerCenterModule/PartnerCenterOffer.psm1 b/PartnerCenterModule/PartnerCenterOffer.psm1 index 48eb1ac..4cf98e9 100644 --- a/PartnerCenterModule/PartnerCenterOffer.psm1 +++ b/PartnerCenterModule/PartnerCenterOffer.psm1 @@ -1,6 +1,6 @@ Set-StrictMode -Version latest <# - © 2017 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. + © 2018 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. This sample code is provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, @@ -12,56 +12,90 @@ $here = Split-Path -Parent $MyInvocation.MyCommand.Path . "$here\commons.ps1" -function Get-PCOffer -{ +<# +.SYNOPSIS +Returns aa list of offers based on the specified country id. +.DESCRIPTION +The Get-PCOffer cmdlet retrieves a list of offers based on the specified country id +.PARAMETER SaToken +Specifies an authentication token you have created with your Partner Center credentials. +.PARAMETER CountryId +Specifies a two letter country id +.PARAMETER OfferId +Specifies the offer id to return. +.PARAMETER LocaleId +Specifies a locale as the language and country code. For example, English in the United States is en-us +.PARAMETER AddOns +Specifies add on SKUs +.EXAMPLE +Get-PCOffer -CountryId 'US' +Get all offer details for the US Country Id +.EXAMPLE +Get-PCOffer -CountryId 'US' -OfferId '8AA7E78B-B265-4AC6-ADA0-14900A8A3F94' +Get a specific offer using the offer id and country. +.EXAMPLE +Get-PCOffer -CountryId 'US' -localeId 'en-us' +Get all offer details using the Country Id and Locale Id. +.EXAMPLE +Get-PCOffer -CountryId 'US' -OfferId '8AA7E78B-B265-4AC6-ADA0-14900A8A3F94' -addOns +Get add ons for the specified offer id. +.NOTES +#> +function Get-PCOffer { [CmdletBinding()] param( - [Parameter(Mandatory = $true)][string]$countryid, - [Parameter(Mandatory = $false)][string]$offerid, - [Parameter(Mandatory = $false)][string]$localeid, - [Parameter(Mandatory = $false)][switch]$addons, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $true)][ValidatePattern("^(BG|BR|CN|CZ|DE|DK|EE|ES|ES|ES|ES|FI|FR|GR|HR|HU|ID|IL|IN|IT|JP|KR|KZ|LT|LV|MY|NL|NO|PL|PT|RO|RS|RS|RU|SE|SG|SI|SK|TH|TR|TW|UA|US|VN)$")][string]$CountryId, + [string]$OfferId, + [Parameter(Mandatory = $false)][ValidatePattern("^(bg-bg|pt-br|zh-cn|cs-cz|de-de|da-dk|et-ee|ca-es|es-es|eu-es|gl-es|fi-fi|fr-fr|el-gr|hr-hr|hu-hu|id-id|he-il|hi-in|it-it|ja-jp|ko-kr|kk-kz|lt-lt|lv-lv|ms-my|nl-nl|nb-no|pl-pl|pt-pt|ro-ro|sr-cyrl-rs|sr-latn-rs|ru-ru|sv-se|zh-sg|sl-si|sk-sk|th-th|tr-tr|zh-tw|uk-ua|en-us|vi-vn|)$")][string]$LocaleId, + [Parameter(Mandatory = $false)][switch]$AddOns, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() - if ($offerid) - { - if ($addons) - { - $url = "https://api.partnercenter.microsoft.com/v1/offers/{0}/addons?country={1}" -f $offerid, $countryid - $headers = @{Authorization="Bearer $satoken"} + if ($OfferId) { + if ($addons) { + $url = "https://api.partnercenter.microsoft.com/v1/offers/{0}/addons?Country={1}" -f $OfferId, $CountryId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "OfferAddons") } - else - { - $url = "https://api.partnercenter.microsoft.com/v1/offers/{0}?country={1}&locale={2}" -f $offerid, $countryid, $localeid - $headers = @{Authorization="Bearer $satoken"} + else { + $url = "https://api.partnercenter.microsoft.com/v1/offers/{0}?Country={1}&locale={2}" -f $OfferId, $CountryId, $LocaleId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Offer") } } - else - { - if ($localeid) - { - $url = "https://api.partnercenter.microsoft.com/v1/offers?country={0}&locale={1}" -f $countryid, $localeid - $headers = @{Authorization="Bearer $satoken"} + else { + if ($LocaleId) { + $url = "https://api.partnercenter.microsoft.com/v1/offers?Country={0}&locale={1}" -f $CountryId, $LocaleId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Offer") } - else - { - $url = "https://api.partnercenter.microsoft.com/v1/offers?country={0}" -f $countryid - $headers = @{Authorization="Bearer $satoken"} + else { + $url = "https://api.partnercenter.microsoft.com/v1/offers?Country={0}" -f $CountryId + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) + $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Offer") @@ -69,49 +103,124 @@ function Get-PCOffer } } -function Get-PCOfferCategoriesByMarket -{ +<# +.SYNOPSIS +Returns a list of offer categories based on the specified country id. +.DESCRIPTION +The Get-PCOfferCategoriesByMarket cmdlet retrieves a list of offer categories for the specified country id. + +.PARAMETER SaToken +Specifies an authentication token you created with your Partner Center credentials. +.PARAMETER CountryId +Specifies a two-character ISO 2 country code. +.EXAMPLE +Get-PCOfferCategoriesByMarket -CountryId US + +.NOTES +#> +function Get-PCOfferCategoriesByMarket { [CmdletBinding()] - param($countryid, [Parameter(Mandatory = $true)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) + param( + [ValidatePattern("^(BG|BR|CN|CZ|DE|DK|EE|ES|ES|ES|ES|FI|FR|GR|HR|HU|ID|IL|IN|IT|JP|KR|KZ|LT|LV|MY|NL|NO|PL|PT|RO|RS|RS|RU|SE|SG|SI|SK|TH|TR|TW|UA|US|VN)$")]$CountryId, + [Parameter(Mandatory = $true)][string]$SaToken = $GlobalToken + ) + _testTokenContext($SaToken) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/offercategories?country={0}" -f $countryid - $headers = @{Authorization="Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/offercategories?Country={0}" -f $CountryId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "OfferCategories") } -function Get-PCAddressRulesByMarket -{ +<# +.SYNOPSIS +Retrieves a list of address rules for a specified market. + +.DESCRIPTION +The Get-PCAddressRulesByMarket returns a list of rules for the specified market. + +.PARAMETER SaToken +Specifies an authentication token you have created with your Partner Center Credentials. + +.PARAMETER CountryId +Specifies a two-character ISO 2 country code. + +.EXAMPLE +Returns the address rules for the US. + +Get-PCAddressRulesByMarket -CountryId US + +.NOTES +You need to have a authentication Credential already established before running this cmdlet. + +#> +function Get-PCAddressRulesByMarket { [CmdletBinding()] - param ($countryid, [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) + param ( + [Parameter(Mandatory = $true)][ValidatePattern("^(BG|BR|CN|CZ|DE|DK|EE|ES|ES|ES|ES|FI|FR|GR|HR|HU|ID|IL|IN|IT|JP|KR|KZ|LT|LV|MY|NL|NO|PL|PT|RO|RS|RS|RU|SE|SG|SI|SK|TH|TR|TW|UA|US|VN)$")][string]$CountryId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken) + _testTokenContext($SaToken) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/countryvalidationrules/{0}" -f $countryid - $headers = @{Authorization="Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/Countryvalidationrules/{0}" -f $CountryId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "MarketRules") } -function Get-PCAzureRateCard -{ +<# +.SYNOPSIS +Retrieves the Azure services rate card for the specified region. + +.DESCRIPTION +The Get-PCAzureRateCard returns a list of Azure rates for the specified region. + +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. + +.PARAMETER Region +Specifies a two-character ISO 2 country code. + +.PARAMETER Currency +Specifies a three-character ISO currency code. + +.EXAMPLE +Get-PCAzureRateCard -region US -currency USD + +Returns the Azure rate card for the specified region and currency. +.NOTES +You need to have a authentication Credential already established before running this cmdlet. The region and the currency must match to return a result. + +#> +function Get-PCAzureRateCard { [CmdletBinding()] - param ($currency, $region, [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) + param ( + [ValidatePattern("^(NOK|SZL|SEK|CHF|CHE|CHW|SYP|TWD|TJS|TZS|THB|USD|XOF|NZD|TOP|TTD|TND|TRY|TMT|USD|AUD|UGX|UAH|AED|GBP|USD|USD|USN|UYU|UYI|UZS|VUV|VEF|VND|USD|USD|XPF|MAD|YER|ZMW|ZWL|XBA|XBB|XBC|XBD|XTS|XXX|XAU|XPD|XPT|XAG)$")][string]$Currency, + [ValidatePattern("^(BG|BR|CN|CZ|DE|DK|EE|ES|ES|ES|ES|FI|FR|GR|HR|HU|ID|IL|IN|IT|JP|KR|KZ|LT|LV|MY|NL|NO|PL|PT|RO|RS|RS|RU|SE|SG|SI|SK|TH|TR|TW|UA|US|VN)$")][string]$Region, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken) + _testTokenContext($SaToken) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/ratecards/azure?¤cy={0}®ion={1}" -f $currency, $region - $headers = @{Authorization="Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/ratecards/azure?¤cy={0}®ion={1}" -f $Currency, $Region + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json diff --git a/PartnerCenterModule/PartnerCenterOrder.psm1 b/PartnerCenterModule/PartnerCenterOrder.psm1 index bf2c31e..2d79daa 100644 --- a/PartnerCenterModule/PartnerCenterOrder.psm1 +++ b/PartnerCenterModule/PartnerCenterOrder.psm1 @@ -1,6 +1,6 @@ Set-StrictMode -Version latest <# - © 2017 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. + © 2018 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. This sample code is provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, @@ -12,30 +12,57 @@ $here = Split-Path -Parent $MyInvocation.MyCommand.Path . "$here\commons.ps1" -function Get-PCOrder -{ +<# +.SYNOPSIS +Returns a list of orders or a specific order. + +.DESCRIPTION +The Get-PCOrder cmdlet returns a list of orders or information about a specific order. + +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.PARAMETER OrderId +Specifies the order id for which to return information. +.EXAMPLE +Return all orders for the specified customer tenant. + Get-PCOrder -TenantId 3c762ceb-b839-4b4a-85d8-0e7304c89f62 + +.EXAMPLE +Get the specified customer order + Get-PCOrder -TenantId -TenantId '3c762ceb-b839-4b4a-85d8-0e7304c89f62' -OrderId '1168c0f1-f0ed-4f9a-9e8c-1dcac072cba8' +.NOTES +#> +function Get-PCOrder { [CmdletBinding()] - param ([Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [string]$orderid, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + param ( + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [string]$OrderId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken + ) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - if ($orderid) - { - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/orders/{1}" -f $tenantid,$orderid - $headers = @{Authorization="Bearer $satoken"} + if ($OrderId) { + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/orders/{1}" -f $TenantId, $OrderId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Order") } - else - { - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/orders" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + else { + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/orders" -f $TenantId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json @@ -43,49 +70,121 @@ function Get-PCOrder } } -function New-PCOrder -{ +<# +.SYNOPSIS +Creates a new order. +.DESCRIPTION +The New-PCOrder cmdlet creates a new order. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.PARAMETER OrderId +Specifies the order id if this is an add on order. +.PARAMETER LineItems +Specifies line items to include in the order +.PARAMETER OfferId +Specifies the offer id guid for the ordered items. +.PARAMETER Quantity +Specifies the number of licenses for a license-based subscription or instances for an Azure reservation. +.PARAMETER FriendlyName +Optional. The friendly name for the subscription defined by the partner to help disambiguate. +.PARAMETER PartnerIdOnRecord +When an indirect provider places an order on behalf of an indirect reseller, populate this field with the MPN ID of the indirect reseller only (never the ID of the indirect provider). This ensures proper accounting for incentives. +.EXAMPLE +Order a new subscription + +Select a customer + $customer = Get-PCCustomer -TenantId '<tenant id GUID>' + Get offer + $offer = Get-PCOffer -CountryId '<Country two digits id>' -OfferId '<offer id GUID>' + +Create the OrderLineItem + $lineItems = @() + $lineItems += [OrderLineItem]::new() + $lineItems[0].LineItemNumber = 0 + $lineItems[0].FriendlyName = '<friendly name>' + $lineItems[0].OfferId = $offer.id + $lineItems[0].Quantity = <quantity> + +Send order + New-PCOrder -TenantId $customer.id -LineItems $lineItems + +.EXAMPLE +Order an Add on to an existing subscription +Get subscription + $subscription = Get-PCSubscription -TenantId $customer.id -subscriptionid '<subscription id>' + +Get list of addons available for the subscription offer + $addons = Get-PCOffer -CountryId '<Country two digits id>' -OfferId $subscription.OfferId -addons + +Get addon offer + $addon = Get-PCOffer -CountryId 'US' -OfferId '<offer id>' + +Get subscription order + $order = Get-PCOrder -TenantId $customer.id -OrderId $subscription.OrderId + +Get the next OrderLineItem number + + $newLineItemNumber = $order.lineItems.Count + +Create the addon OrderLineItem + $lineItems = @() + $lineItems += [OrderLineItem]::new() + $lineItems[0].LineItemNumber = 0 + $lineItems[0].FriendlyName = '<friendly name>' + $lineItems[0].OfferId = $addon.id + $lineItems[0].ParentSubscriptionId = $subscription.id + $lineItems[0].Quantity = <quantity> + +Send order + New-PCOrder -TenantId $customer.id -OrderId $order.id -LineItems $lineItems + +.NOTES +#> +function New-PCOrder { [CmdletBinding()] - param( [Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(ParameterSetName='Addon',Mandatory = $true)][string]$orderid, - [Parameter(ParameterSetName='ByArray',Mandatory = $true)][Parameter(ParameterSetName='Addon')][Array]$LineItems, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string]$OfferId, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][uint16]$Quantity, - [Parameter(ParameterSetName='AllDetails',Mandatory = $false)][string]$FriendlyName, - [Parameter(ParameterSetName='AllDetails',Mandatory = $false)][string]$PartnerIdOnRecord, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + param( + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(ParameterSetName = 'Addon', Mandatory = $true)][string]$OrderId, + [Parameter(ParameterSetName = 'ByArray', Mandatory = $true)][Parameter(ParameterSetName = 'Addon')][Array]$LineItems, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string]$OfferId, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][uint16]$Quantity, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $false)][string]$FriendlyName, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $false)][string]$PartnerIdOnRecord, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken + ) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $headers = @{"Authorization"="Bearer $satoken"} - $headers += @{"MS-Contract-Version"="v1"} - $headers += @{"MS-RequestId"=[Guid]::NewGuid()} - $headers += @{"MS-CorrelationId"=[Guid]::NewGuid()} + $headers = @{"Authorization" = "Bearer $SaToken"} + $headers += @{"MS-Contract-Version" = "v1"} + $headers += @{"MS-RequestId" = [Guid]::NewGuid()} + $headers += @{"MS-CorrelationId" = [Guid]::NewGuid()} - if ($orderid) - { - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/orders/{1}" -f $tenantid, $orderid + if ($OrderId) { + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/orders/{1}" -f $TenantId, $OrderId - $order = [Order]::new($tenantid, $LineItems) + $order = [Order]::new($TenantId, $LineItems) $body = $order | ConvertTo-Json -Depth 100 $method = "PATCH" } - else - { - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/orders" -f $tenantid - - switch ($PsCmdlet.ParameterSetName) - { - 'ByArray' { $order = [Order]::new($tenantid,$LineItems)} - 'AllDetails' { $lineItems_tmp = [OrderLineItem]::new(0,$OfferId,$Quantity) - if ($FriendlyName){$lineItems_tmp.FriendlyName = $FriendlyName} - if ($PartnerIdOnRecord){$lineItems_tmp.PartnerIdOnRecord = $PartnerIdOnRecord} - $arr = @() - $arr += $lineItems_tmp - $order = [Order]::new($tenantid,$arr)} + else { + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/orders" -f $TenantId + + switch ($PsCmdlet.ParameterSetName) { + 'ByArray' { $order = [Order]::new($TenantId, $LineItems)} + 'AllDetails' { + $lineItems_tmp = [OrderLineItem]::new(0, $OfferId, $Quantity) + if ($FriendlyName) {$lineItems_tmp.friendlyName = $FriendlyName} + if ($PartnerIdOnRecord) {$lineItems_tmp.partnerIdOnRecord = $PartnerIdOnRecord} + $arr = @() + $arr += $lineItems_tmp + $order = [Order]::new($TenantId, $arr) + } } $body = $order | ConvertTo-Json -Depth 100 @@ -97,28 +196,44 @@ function New-PCOrder return (_formatResult -obj $obj -type "Order") } -function New-PCAddonOrder -{ +<# +.SYNOPSIS +Creates a bew add on order for the specified order. +.DESCRIPTION +The New-PCAddonOrder cmdlet creates a new addon order for an already created order. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.PARAMETER OrderId +Specifies the order id for which to associate the add on. +.PARAMETER LineItems +Specifies the line items. +.EXAMPLE +New-PCAddonOrder +.NOTES +#> +function New-PCAddonOrder { [CmdletBinding()] param ( - [Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $true)][string]$orderid, + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $true)][string]$OrderId, [Parameter(Mandatory = $true)][Array]$LineItems, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/orders/{1}" -f $tenantid, $orderid - $headers = @{"Authorization"="Bearer $satoken"} - $headers += @{"MS-Contract-Version"="v1"} - $headers += @{"MS-RequestId"=[Guid]::NewGuid()} - $headers += @{"MS-CorrelationId"=[Guid]::NewGuid()} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/orders/{1}" -f $TenantId, $OrderId + $headers = @{"Authorization" = "Bearer $SaToken"} + $headers += @{"MS-Contract-Version" = "v1"} + $headers += @{"MS-RequestId" = [Guid]::NewGuid()} + $headers += @{"MS-CorrelationId" = [Guid]::NewGuid()} - $order = [Order]::new($tenantid, $LineItems) + $order = [Order]::new($TenantId, $LineItems) $body = $order | ConvertTo-Json -Depth 100 $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Body $body -Method "PATCH" #-Debug -Verbose @@ -127,40 +242,87 @@ function New-PCAddonOrder } <# -function Set-Order -{ +.SYNOPSIS +Modifies an existing order. +.DESCRIPTION +The Set-PCOrder cmdlet updates an order. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER Order +Specifies the order to modify. +.PARAMETER LineItemNumber +Specifies a line item number to modify +.PARAMETER FriendlyName +Specifies a friendly name for the order. +.PARAMETER Quantity +Specifies the quantity of items on the specified order line item. + +.PARAMETER BillingCycleType +Specifies the billing cycle type. Valid values are: unknown, monthly, annual, none. +.EXAMPLE +Set-PCOrder +.NOTES + +#> +function Set-PCOrder { [CmdletBinding()] - param ([Parameter(Mandatory = $true,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)][PSCustomObject]$order, - [Parameter(Mandatory = $true)][uint16]$LineItemNumber, - [Parameter(Mandatory = $false)][string]$FriendlyName, - [Parameter(Mandatory = $false)][uint16]$Quantity, - [Parameter(Mandatory = $false)][ValidateSet('Unknown','Monthly','Annual','None')][string]$BillingCycleType, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) + param ([Parameter(Mandatory = $true, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][PSCustomObject]$order, + [Parameter(Mandatory = $true)][uint16]$LineItemNumber, + [Parameter(Mandatory = $false)][string]$FriendlyName, + [Parameter(Mandatory = $false)][uint16]$Quantity, + [Parameter(Mandatory = $false)][ValidateSet('Unknown', 'Monthly', 'Annual', 'None')][string]$BillingCycleType, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken + ) + $obj = @() - _testTokenContext($satoken) - $actualOrder = Get-PCOrder -tenantID $order.ReferenceCustomerId -orderID $order.id -satoken $satoken + _testTokenContext($SaToken) + $actualOrder = Get-PCOrder -tenantID $order.referenceCustomerId -orderID $Order.id -SaToken $SaToken if ($FriendlyName) { $actualOrder.lineItems[$LineItemNumber].friendlyName = $FriendlyName} - if ($quantity) {$actualOrder.lineItems[$LineItemNumber].Quantity = $quantity} - if ($BillingCycleType){$actualOrder.BillingCycleType = $BillingCycleType} - - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/orders/{1}" -f $order.ReferenceCustomerId, $order.id - $headers = @{"Authorization"="Bearer $satoken"} - $headers += @{"MS-Contract-Version"="v1"} - $headers += @{"MS-RequestId"=[Guid]::NewGuid()} - $headers += @{"MS-CorrelationId"=[Guid]::NewGuid()} + if ($Quantity) {$actualOrder.lineItems[$LineItemNumber].quantity = $Quantity} + if ($BillingCycleType) {$actualOrder.billingCycleType = $BillingCycleType} + + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/orders/{1}" -f $order.referenceCustomerId, $Order.id + $headers = @{"Authorization" = "Bearer $SaToken"} + $headers += @{"MS-Contract-Version" = "v1"} + $headers += @{"MS-RequestId" = [Guid]::NewGuid()} + $headers += @{"MS-CorrelationId" = [Guid]::NewGuid()} $body = $actualOrder | ConvertTo-Json -Depth 100 $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Body $body -Method "PATCH" #-Debug -Verbose + $obj += $response.Substring(1) | ConvertFrom-Json + return $obj } -#> -function New-OrderLineItem -{ +<# +.SYNOPSIS +Returns a new PC Order line item PowerShell object. +.DESCRIPTION +The New-PCOrderLineItem cmdlet creates a PowerShell object used to create an order line item. +.PARAMETER LineItemNumber +Specifies the line number of the order to add the line item. Specifying an existing line item will overwrite the current line item. +.PARAMETER OfferId +Specifies the offer id for which to purchase. Use Get-PCOffer to list offers available in your region. +.PARAMETER Quantity +Specifies a quantity of licenses to purchase for this line item. +.PARAMETER FriendlyName +Specifies a friendly name for the line item. +.EXAMPLE +New-OrderLineItem +.NOTES + +#> +function New-PCOrderLineItem { [CmdletBinding()] - Param ([uint16] $LineItemNumber,[string] $OfferId,[uint16] $Quantity, [string]$FriendlyName) - $LineItem = [OrderLineItem]::new($LineItemNumber,$OfferId,$Quantity) - if ($FriendlyName){$LineItem.FriendlyName = $FriendlyName} + Param ( + [uint16] $LineItemNumber, + [string] $OfferId, + [uint16] $Quantity, + [string] $FriendlyName + + ) + $LineItem = [OrderLineItem]::new($LineItemNumber, $OfferId, $Quantity) + if ($FriendlyName) {$LineItem.friendlyName = $FriendlyName} return $LineItem -} \ No newline at end of file +} diff --git a/PartnerCenterModule/PartnerCenterPartner.psm1 b/PartnerCenterModule/PartnerCenterPartner.psm1 index b10b788..9280519 100644 --- a/PartnerCenterModule/PartnerCenterPartner.psm1 +++ b/PartnerCenterModule/PartnerCenterPartner.psm1 @@ -1,6 +1,6 @@ Set-StrictMode -Version latest <# - © 2017 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. + © 2018 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. This sample code is provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, @@ -12,54 +12,40 @@ $here = Split-Path -Parent $MyInvocation.MyCommand.Path . "$here\commons.ps1" -function Get-PCAuditRecords -{ - [CmdletBinding()] - Param( - [Parameter(Mandatory = $true)][string]$startDate, - [Parameter(Mandatory = $false)][string]$endDate, - #[Parameter(Mandatory = $false)][string]$filter, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken - ) - _testTokenContext($satoken) - - Write-Warning " Get-PCAuditRecords is deprecated and will not be available in future releases, use Get-PCAuditRecord instead." - $obj = @() - - if ($startDate) { $url = "https://api.partnercenter.microsoft.com/v1/auditrecords?startDate={0}" -f $startDate } - if ($endDate) { $url = "https://api.partnercenter.microsoft.com/v1/auditrecords?startDate={0}&endDate={1}" -f $startDate, $endDate } - #if ($filter) - #{ - # [Reflection.Assembly]::LoadWithPartialName("System.Web") | Out-Null - # $filter = [System.Web.HttpUtility]::UrlEncode($filter) - # $url = "https://api.partnercenter.microsoft.com/v1/auditrecords?startDate={0}&endDate={1}&filter={2}" -f $startDate, $endDate, $filter - #} - - $headers = @{Authorization="Bearer $satoken"} - - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj += $response.items - return (_formatResult -obj $obj -type "AuditRecord") -} - -# Add non-plural noun version of cmdlet. Plural version of the cmdlet will be removed in future releases. -function Get-PCAuditRecord -{ +<# +.SYNOPSIS +Returns audit records based on the specified time. + +.DESCRIPTION +The Get-PCAuditRecord cmdlet retrieves a list of audit records for the specified time period. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER StartDate +The date from which you will start retrieving data. Must be formated yyyy-mm-dd. + +.PARAMETER EndDate +The date from which you will stop retrieving data. Must be formated yyyy-mm-dd. + +.EXAMPLE +Get-PCAuditRecord +.NOTES +#> +function Get-PCAuditRecord { [CmdletBinding()] Param( - [Parameter(Mandatory = $true)][string]$startDate, - [Parameter(Mandatory = $false)][string]$endDate, - #[Parameter(Mandatory = $false)][string]$filter, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $true)][ValidatePattern("\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])*")][string]$StartDate, + [Parameter(Mandatory = $false)][ValidatePattern("\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])*")][string]$EndDate, + #[Parameter(Mandatory = $false)][string]$filter, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() # TODO Only 30 days can be returned per request, limit the request to 30 days span before executing request - if ($startDate) { $url = "https://api.partnercenter.microsoft.com/v1/auditrecords?startDate={0}" -f $startDate } - if ($endDate) { $url = "https://api.partnercenter.microsoft.com/v1/auditrecords?startDate={0}&endDate={1}" -f $startDate, $endDate } + if ($startDate) { $url = "https://api.partnercenter.microsoft.com/v1/auditrecords?startDate={0}" -f $StartDate } + if ($endDate) { $url = "https://api.partnercenter.microsoft.com/v1/auditrecords?startDate={0}&endDate={1}" -f $StartDate, $EndDate } #if ($filter) #{ # [Reflection.Assembly]::LoadWithPartialName("System.Web") | Out-Null @@ -67,46 +53,44 @@ function Get-PCAuditRecord # $url = "https://api.partnercenter.microsoft.com/v1/auditrecords?startDate={0}&endDate={1}&filter={2}" -f $startDate, $endDate, $filter #} - $headers = @{Authorization="Bearer $satoken"} + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.items return (_formatResult -obj $obj -type "AuditRecord") } -function Get-PCIndirectResellers -{ - [CmdletBinding()] - Param( - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken - ) - _testTokenContext($satoken) - Write-Warning " Get-PCIndirectResellers is deprecated and will not be available in future releases, use Get-PCIndirectReseller instead." - - $obj = @() +<# +.SYNOPSIS +Returns a list of indirect resellers. - $url = "https://api.partnercenter.microsoft.com/v1/relationships?relationship_type=IsIndirectCloudSolutionProviderOf" - $headers = @{Authorization="Bearer $satoken"} +.DESCRIPTION +The Get-PCIndirectReseller cmdlet. - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj += $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "PartnerRelationship") -} +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. -# Add non-plural noun version of cmdlet. Plural version of the cmdlet will be removed in future releases. -function Get-PCIndirectReseller -{ +.EXAMPLE +Get-PCIndirectReseller +.NOTES +#> +function Get-PCIndirectReseller { [CmdletBinding()] Param( - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() $url = "https://api.partnercenter.microsoft.com/v1/relationships?relationship_type=IsIndirectCloudSolutionProviderOf" - $headers = @{Authorization="Bearer $satoken"} + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json diff --git a/PartnerCenterModule/PartnerCenterProfiles.psm1 b/PartnerCenterModule/PartnerCenterProfiles.psm1 index 3a8d694..48bb690 100644 --- a/PartnerCenterModule/PartnerCenterProfiles.psm1 +++ b/PartnerCenterModule/PartnerCenterProfiles.psm1 @@ -1,6 +1,6 @@ Set-StrictMode -Version latest <# - © 2017 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. + © 2018 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. This sample code is provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, @@ -12,148 +12,247 @@ $here = Split-Path -Parent $MyInvocation.MyCommand.Path . "$here\commons.ps1" -function Get-PCLegalBusinessProfile -{ +<# +.SYNOPSIS +Returns the partner's legal business profile. +.DESCRIPTION +The Get-PCLegalBusinessProfile cmdlet returns the partner's legal business profile. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.EXAMPLE +Get-PCLegalBusinessProfile +.NOTES +#> +function Get-PCLegalBusinessProfile { [CmdletBinding()] param ( - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() $url = "https://api.partnercenter.microsoft.com/v1/profiles/legalbusiness" - $headers = @{Authorization="Bearer $satoken"} + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Profile") } -function Get-PCOrganizationProfile -{ +<# +.SYNOPSIS +Returns the organizational profile. +.DESCRIPTION +The Get-PCOrganizationProfile cmdlet returns the organization profile. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.EXAMPLE +Get-PCOrganizationProfile +.NOTES +#> +function Get-PCOrganizationProfile { [CmdletBinding()] param ( - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() $url = "https://api.partnercenter.microsoft.com/v1/profiles/organization" - $headers = @{Authorization="Bearer $satoken"} + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Profile") } -function Get-PCBillingProfile -{ +<# +.SYNOPSIS +Return the partner's billing profile. +.DESCRIPTION +The Get-PCBillingProfile cmdlet returns the billing profile for the current partner tenant. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.EXAMPLE +Get-PCBillingProfile +.NOTES +#> +function Get-PCBillingProfile { [CmdletBinding()] param ( - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() $url = "https://api.partnercenter.microsoft.com/v1/profiles/billing" - $headers = @{Authorization="Bearer $satoken"} + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Profile") } -function Get-PCMpnProfile -{ +<# +.SYNOPSIS +Returns the specified Mpn profile. +.DESCRIPTION +The Get-PCMpnProfile cmdlet returns the specified Mpn profile. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER MpnId +Specifies the MPN id used to scope this cmdlet. +.EXAMPLE +Get-PCMpnProfile +.NOTES +#> +function Get-PCMpnProfile { [CmdletBinding()] param ( - [Parameter(Mandatory = $false)][string]$mpnid, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][string]$MpnId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() - if($mpnid) - { - $url = "https://api.partnercenter.microsoft.com/v1/profiles/partnernetworkprofile?mpnId={0}" -f $mpnid + if ($mpnId) { + $url = "https://api.partnercenter.microsoft.com/v1/profiles/partnernetworkprofile?mpnId={0}" -f $MpnId } - else - { + else { $url = "https://api.partnercenter.microsoft.com/v1/profiles/mpn" } - $headers = @{Authorization="Bearer $satoken"} + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Profile") } -function Get-PCSupportProfile -{ +<# +.SYNOPSIS +Return the partner's support profile. +.DESCRIPTION +The Get-PCSupportProfile cmdlet returns the partner's support profile. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. + +.EXAMPLE +Get-PCSupportProfile +.NOTES +#> +function Get-PCSupportProfile { [CmdletBinding()] param ( - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() $url = "https://api.partnercenter.microsoft.com/v1/profiles/support" - $headers = @{Authorization="Bearer $satoken"} + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Profile") } -function Set-PCLegalBusinessProfile -{ +<# +.SYNOPSIS +Updates the partner's legal business profile. +.DESCRIPTION +The Set-PCLegalBusinessProfile cmdlet updates the partner's legal business profile. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER Country +Specifies an updated two letter ISO country code for the legal business profile. +.PARAMETER AddressLine1 +Specifies an updated street address for the legal business profile. +.PARAMETER AddressLine2 +Specifies an updated second address line for the legal business profile. +.PARAMETER City +Specifies an updated city name for the legal business profile. +.PARAMETER State +Specifies an updated city name for the legal business profile. +.PARAMETER PostalCode +Specifies an updated postal code for the legal business profile. +.PARAMETER PrimaryContactFirstName +Specifies an updated first name for the primary legal business contact. +.PARAMETER PrimaryContactLastName +Specifies an updated last name for the primary legal business contact. +.PARAMETER PrimaryContactPhoneNumber +Specifies an updated phone number for the primary legal business contact. +.PARAMETER PrimaryContactEmail +Specifies an updated e-mail address for the primary legal business contact. +.EXAMPLE + Set-PCLegalBusinessProfile -PrimaryContactFirstName 'John' -PrimaryContactLastName 'Smith' -PrimaryContactEmail 'john@contoso.com' +Update the legal business profile to use John Smith with the email address of john@contoso.com. +.NOTES +#> +function Set-PCLegalBusinessProfile { [CmdletBinding()] param( #write properties - [Parameter(Mandatory = $false)][string]$country, + [Parameter(Mandatory = $false)][string]$Country, [Parameter(Mandatory = $false)][string]$AddressLine1, [Parameter(Mandatory = $false)][string]$AddressLine2, - [Parameter(Mandatory = $false)][string]$city, - [Parameter(Mandatory = $false)][string]$state, - [Parameter(Mandatory = $false)][string]$postalcode, - [Parameter(Mandatory = $false)][string]$primarycontactfirstname, - [Parameter(Mandatory = $false)][string]$primarycontactlastname, - [Parameter(Mandatory = $false)][string]$primarycontactphonenumber, - [Parameter(Mandatory = $false)][string]$primarycontactemail, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][string]$City, + [Parameter(Mandatory = $false)][string]$State, + [Parameter(Mandatory = $false)][string]$PostalCode, + [Parameter(Mandatory = $false)][string]$PrimaryContactFirstName, + [Parameter(Mandatory = $false)][string]$PrimaryContactLastName, + [Parameter(Mandatory = $false)][string]$PrimaryContactPhoneNumber, + [Parameter(Mandatory = $false)][string]$PrimaryContactEmail, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken #read-only properties - #$primarycontactfirstname,#$primarycontactlastname,#$primarycontactphonenumber, + #$primaryContactFirstName,#$primaryContactLastName,#$primaryContactPhoneNumber, #companyApproverAddress property - #$country_approver,#$AddressLine1_approver,#$AddressLine2_approver,#$city_approver,#$state_approver,#$postalcode_approver, + #$Country_approver,#$AddressLine1_approver,#$AddressLine2_approver,#$city_approver,#$state_approver,#$postalCode_approver, #companyApproverEmail property - #$email_approver + #$email_approver ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() - $actualLegalBP = Get-PCLegalBusinessProfile -satoken $satoken + $actualLegalBP = Get-PCLegalBusinessProfile -SaToken $SaToken - if($AddressLine1) {$actualLegalBP.address.addressLine1 = $AddressLine1} - if ($AddressLine2) {$actualLegalBP.address.addressLine2 = $AddressLine2} - if ($country) {$actualLegalBP.address.country = $country} - if ($city) {$actualLegalBP.address.city = $city} - if ($state) {$actualLegalBP.address.state = $state} - if ($postalcode) {$actualLegalBP.address.postalCode = $postalcode} - if ($primarycontactfirstname) {$actualLegalBP.address.firstName = $primarycontactfirstname} - if ($primarycontactlastname) {$actualLegalBP.address.lastName = $primarycontactlastname} - if ($primarycontactphonenumber){$actualLegalBP.address.phoneNumber = $primarycontactphonenumber} - if ($primarycontactemail) {$actualLegalBP.primaryContact.email = $primarycontactemail} + if ($AddressLine1) {$actualLegalBP.address.addressLine1 = $AddressLine1} + if ($AddressLine2) {$actualLegalBP.address.addressLine2 = $AddressLine2} + if ($Country) {$actualLegalBP.address.country = $Country} + if ($City) {$actualLegalBP.address.city = $City} + if ($State) {$actualLegalBP.address.state = $State} + if ($PostalCode) {$actualLegalBP.address.postalCode = $PostalCode} + if ($PrimaryContactFirstName) {$actualLegalBP.PrimaryContact.firstName = $PrimaryContactFirstName} + if ($PrimaryContactLastName) {$actualLegalBP.PrimaryContact.lastName = $PrimaryContactLastName} + if ($PrimaryContactPhoneNumber) {$actualLegalBP.PrimaryContact.phoneNumber = $PrimaryContactPhoneNumber} + if ($PrimaryContactEmail) {$actualLegalBP.primaryContact.email = $PrimaryContactEmail} $url = "https://api.partnercenter.microsoft.com/v1/profiles/legalbusiness" - $headers = @{Authorization="Bearer $satoken"} + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $body = $actualLegalBP | ConvertTo-Json -Depth 100 $utf8body = [System.Text.Encoding]::UTF8.GetBytes($body) @@ -163,44 +262,84 @@ function Set-PCLegalBusinessProfile return (_formatResult -obj $obj -type "Profile") } -function Set-PCOrganizationProfile -{ +<# +.SYNOPSIS +Updates the partner's organization profile. +.DESCRIPTION +The Set-PCOrganizationProfile cmdlet sets information on a partner's organizational profile. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER CompanyName +Specifies an updated company name for the partner's organizational profile. +.PARAMETER Country +Specifies an updated two letter ISO code for the partner's organizational profile. +.PARAMETER AddressLine1 +Specifies the first address line for the partner's organizational profile. +.PARAMETER AddressLine2 +Specifies the second address line for the partner's organizational profile. +.PARAMETER City +Specifies the second city for the partner's organizational profile. +.PARAMETER State +Specifies the state for the partner's organizational profile. +.PARAMETER PostalCode +Specifies the postal code for the partner's organizational profile. +.PARAMETER FirstName +Specifies the first name of the company contact for the partner's organizational profile. +.PARAMETER LastName +Specifies the last name of the company contact for the partner's organizational profile. +.PARAMETER PhoneNumber +Specifies the phone number of the company contact for the partner's organizational profile. +.PARAMETER Email +Specifies the email address for the company contact. +.PARAMETER Language +Specifies the two letter ISO code for the language. +.EXAMPLE + Set-PCOrganizationProfile -FirstName 'John' -LastName 'Smith' -Email 'john@contoso.com' +Sets John Smith with the email address of john@contoso.com as the contact on the partner's organizational profile. +.NOTES +#> +function Set-PCOrganizationProfile { [CmdletBinding()] param( #write properties - [Parameter(Mandatory = $false)][string]$companyName, - [Parameter(Mandatory = $false)][string]$country, + [Parameter(Mandatory = $false)][string]$CompanyName, + [Parameter(Mandatory = $false)][string]$Country, [Parameter(Mandatory = $false)][string]$AddressLine1, - [Parameter(Mandatory = $false)][string]$city, - [Parameter(Mandatory = $false)][string]$state, - [Parameter(Mandatory = $false)][string]$postalcode, - [Parameter(Mandatory = $false)][string]$firstname, - [Parameter(Mandatory = $false)][string]$lastname, - [Parameter(Mandatory = $false)][string]$phonenumber, - [Parameter(Mandatory = $false)][string]$email, - [Parameter(Mandatory = $false)][string]$language, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][string]$AddressLine2, + [Parameter(Mandatory = $false)][string]$City, + [Parameter(Mandatory = $false)][string]$State, + [Parameter(Mandatory = $false)][string]$PostalCode, + [Parameter(Mandatory = $false)][string]$FirstName, + [Parameter(Mandatory = $false)][string]$LastName, + [Parameter(Mandatory = $false)][string]$PhoneNumber, + [Parameter(Mandatory = $false)][string]$Email, + [Parameter(Mandatory = $false)][string]$Language, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() - $actualOrganizationP = Get-PCOrganizationProfile -satoken $satoken - - if($companyName) {$actualOrganizationP.companyName = $companyName} - if($AddressLine1){$actualOrganizationP.defaultAddress.addressLine1 = $AddressLine1} - if($city) {$actualOrganizationP.defaultAddress.city = $city} - if($state) {$actualOrganizationP.defaultAddress.state = $state} - if($postalcode) {$actualOrganizationP.defaultAddress.postalCode = $postalcode} - if($country) {$actualOrganizationP.defaultAddress.country = $country} - if($firstname) {$actualOrganizationP.defaultAddress.firstName = $firstname} - if($lastname) {$actualOrganizationP.defaultAddress.lastName = $lastname} - if($phonenumber) {$actualOrganizationP.defaultAddress.phoneNumber = $phonenumber} - if($email) {$actualOrganizationP.email = $email} - if($language) {$actualOrganizationP.language = $language} + $actualOrganizationP = Get-PCOrganizationProfile -SaToken $SaToken + + if ($CompanyName) {$actualOrganizationP.companyName = $CompanyName} + if ($AddressLine1) {$actualOrganizationP.defaultAddress.addressLine1 = $AddressLine1} + if ($AddressLine2) {$actualOrganizationP.defaultAddress.addressLine2 = $AddressLine2} + if ($City) {$actualOrganizationP.defaultAddress.city = $City} + if ($State) {$actualOrganizationP.defaultAddress.state = $State} + if ($PostalCode) {$actualOrganizationP.defaultAddress.postalCode = $PostalCode} + if ($Country) {$actualOrganizationP.defaultAddress.country = $Country} + if ($FirstName) {$actualOrganizationP.defaultAddress.firstName = $FirstName} + if ($LastName) {$actualOrganizationP.defaultAddress.lastName = $LastName} + if ($PhoneNumber) {$actualOrganizationP.defaultAddress.phoneNumber = $PhoneNumber} + if ($Email) {$actualOrganizationP.email = $Email} + if ($Language) {$actualOrganizationP.language = $Language} $url = "https://api.partnercenter.microsoft.com/v1/profiles/organization" - $headers = @{Authorization="Bearer $satoken"} + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $body = $actualOrganizationP | ConvertTo-Json -Depth 100 $utf8body = [System.Text.Encoding]::UTF8.GetBytes($body) @@ -210,43 +349,74 @@ function Set-PCOrganizationProfile return (_formatResult -obj $obj -type "Profile") } -function Set-PCBillingProfile -{ +<# +.SYNOPSIS +Updates a partner's billing profile. +.DESCRIPTION +The Set-PCBillingProfile cmdlet updates the partner's billing profile. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER AddressLine1 +Specifies the first address line for the billing contact. +.PARAMETER AddressLine2 +Specifies the second address line for the billing contact. +.PARAMETER City +Specifies the billing contact's city. +.PARAMETER State +Specifies the billing contact's state. +.PARAMETER Country +Specifies the billing contact's country two letter ISO code. +.PARAMETER PostalCode +Specifies the billing contact's postal code. +.PARAMETER FirstName +Specifies the billing contact's first name. +.PARAMETER LastName +Specifies the billing contact's last name. +.PARAMETER PhoneNumber +Specifies the billing contact's phone number. +.EXAMPLE +Set-PCBillingProfile -FirstName '<first name>' -LastName '<last name>' -PhoneNumber '<phone number>' -AddressLine1 '<address 1>' -AddressLine2 '<address 2>' +.NOTES +#> +function Set-PCBillingProfile { [CmdletBinding()] param( #write properties - [Parameter(Mandatory = $false)][string]$country, + [Parameter(Mandatory = $false)][string]$Country, [Parameter(Mandatory = $false)][string]$AddressLine1, [Parameter(Mandatory = $false)][string]$AddressLine2, - [Parameter(Mandatory = $false)][string]$city, - [Parameter(Mandatory = $false)][string]$state, - [Parameter(Mandatory = $false)][string]$postalcode, - [Parameter(Mandatory = $false)][string]$firstname, - [Parameter(Mandatory = $false)][string]$lastname, - [Parameter(Mandatory = $false)][string]$phonenumber, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][string]$City, + [Parameter(Mandatory = $false)][string]$State, + [Parameter(Mandatory = $false)][string]$PostalCode, + [Parameter(Mandatory = $false)][string]$FirstName, + [Parameter(Mandatory = $false)][string]$LastName, + [Parameter(Mandatory = $false)][string]$PhoneNumber, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken #read-only properties #$tax_id,$billingCurrency ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() - $actualBillingP = Get-PCBillingProfile -satoken $satoken + $actualBillingP = Get-PCBillingProfile -SaToken $SaToken - if($AddressLine1) {$actualBillingP.address.addressLine1 = $AddressLine1} - if($AddressLine2){$actualBillingP.address.addressLine2 = $AddressLine2} - if($city) {$actualBillingP.address.city = $city} - if($state) {$actualBillingP.address.state = $state} - if($postalcode) {$actualBillingP.address.postalCode = $postalcode} - if($country) {$actualBillingP.address.country = $country} - if($firstname) {$actualBillingP.primaryContact.firstName = $firstname} - if($lastname) {$actualBillingP.primaryContact.lastName = $lastname} - if($phonenumber) {$actualBillingP.primaryContact.phoneNumber = $phonenumber} + if ($AddressLine1) {$actualBillingP.address.addressLine1 = $AddressLine1} + if ($AddressLine2) {$actualBillingP.address.addressLine2 = $AddressLine2} + if ($City) {$actualBillingP.address.city = $City} + if ($State) {$actualBillingP.address.state = $State} + if ($PostalCode) {$actualBillingP.address.postalCode = $PostalCode} + if ($Country) {$actualBillingP.address.country = $Country} + if ($FirstName) {$actualBillingP.primaryContact.firstName = $FirstName} + if ($LastName) {$actualBillingP.primaryContact.lastName = $LastName} + if ($PhoneNumber) {$actualBillingP.primaryContact.phoneNumber = $PhoneNumber} $url = "https://api.partnercenter.microsoft.com/v1/profiles/billing" - $headers = @{Authorization="Bearer $satoken"} + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $body = $actualBillingP | ConvertTo-Json -Depth 100 $utf8body = [System.Text.Encoding]::UTF8.GetBytes($body) @@ -256,29 +426,61 @@ function Set-PCBillingProfile return (_formatResult -obj $obj -type "Profile") } -function Set-PCSupportProfile -{ +<# +.SYNOPSIS +Modifies the partner's support profile. +.DESCRIPTION +The Set-PCSupportProfile cmdlet update the partner's support profile. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER Website +Specifies an updated support website for the partner. Do not include 'http://', specify just the DNS name of the site. +.PARAMETER Email +Specifies an updated support email address for the partner. +.PARAMETER Phone +Specifies an updated support phone number for the partner. +.EXAMPLE + Set-PCSupportProfile -Website 'support.contoso.com' +Updates the support website to be support.contoso.com. +.NOTES +#> +function Set-PCSupportProfile { [CmdletBinding()] param( #write properties - [Parameter(Mandatory = $false)][string]$website, - [Parameter(Mandatory = $false)][string]$email, - [Parameter(Mandatory = $false)][string]$phone, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][string]$Website, + [Parameter(Mandatory = $false)][string]$Email, + [Parameter(Mandatory = $false)][string]$Phone, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() - $actualSupportProfile = Get-PCSupportProfile -satoken $satoken - - if($website){$actualSupportProfile.website = $website} - if($email){$actualSupportProfile.email = $email} - if($phone){$actualSupportProfile.telephone = $phone} + $actualSupportProfile = Get-PCSupportProfile -SaToken $SaToken + # Check to make sure all of the required properties exist. If not, add them. + if (!($actualSupportProfile.PSObject.properties.name -match "website")) { + $actualSupportProfile | Add-Member -MemberType NoteProperty -Name 'website' -Value " " + } + if (!($actualSupportProfile.PSObject.properties.name -match "email")) { + + $actualSupportProfile | Add-Member -MemberType NoteProperty -Name 'email' -Value " " + } + if (!($actualSupportProfile.PSObject.properties.name -match "telephone")) + { + $actualSupportProfile | Add-Member -MemberType NoteProperty -Name 'telephone' -Value " " + } + if ($Website) {$actualSupportProfile.website = $Website} + if ($Email) {$actualSupportProfile.email = $Email} + if ($Phone) {$actualSupportProfile.telephone = $Phone} + $url = "https://api.partnercenter.microsoft.com/v1/profiles/support" - $headers = @{Authorization="Bearer $satoken"} + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) + $body = $actualSupportProfile | ConvertTo-Json -Depth 100 $utf8body = [System.Text.Encoding]::UTF8.GetBytes($body) @@ -287,43 +489,91 @@ function Set-PCSupportProfile return (_formatResult -obj $obj -type "Profile") } -function Get-PCCustomerBillingProfile -{ +<# +.SYNOPSIS +Returns the specified customer's billing profile. +.DESCRIPTION +The Get-PCCustomerBillingProfile cmdlet returns the billing profile for the specified tenant. +.PARAMETER SaToken +Specifies an authentication token you have created with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.EXAMPLE +Get-PCCustomerBillingProfile -TenantId <TenantId> +.NOTES +#> +function Get-PCCustomerBillingProfile { [CmdletBinding()] param ( - [Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/profiles/billing" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/profiles/billing" -f $TenantId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Profile") } -function Set-PCCustomerBillingProfile -{ +<# +.SYNOPSIS +Updates the specified customer's billing profile. The cmdlet accepts an updated billing profile object to determine the updates to be made. Use either Get-PCCustomerBillingProfile or New-PCCustomerBillingProfile cmdlet to create the updated customer billing profile object. +.DESCRIPTION +The Set-PCCustomerBillingProfile cmdlet updates a customer's billing profile. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.PARAMETER BillingProfile +Specifies a variable that includes the billing profile. +.EXAMPLE +Update the current customer billing profile. + +Get customer Billing Profile + +$customerBillingProfile = Get-PCCustomerBillingProfile -TenantId db8ea5b4-a69b-45f3-abd3-dca19e87c536 + +Update name and email address on the customer billing profile. + + $customerBillingProfile.FirstName = 'Joan' + $customerBillingProfile.LastName = 'Sullivan' + $customerBillingProfile.Email = 'joan@wingtiptoyscsptest.onmicrosoft.com' + +Complete update for the customer's billing profile + + Set-PCCustomerBillingProfile -TenantId db8ea5b4-a69b-45f3-abd3-dca19e87c536 -BillingProfile $customerBillingProfile + +.NOTES +#> +function Set-PCCustomerBillingProfile { [CmdletBinding()] param ( - [Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $true,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)][PSCustomObject]$billingprofile, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $true, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][PSCustomObject]$BillingProfile, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/profiles/billing" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} - $body = $billingprofile | ConvertTo-Json -Depth 100 + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/profiles/billing" -f $TenantId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) + + $body = $BillingProfile | ConvertTo-Json -Depth 100 $utf8body = [System.Text.Encoding]::UTF8.GetBytes($body) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Body $utf8body -Method "PUT" #-Debug -Verbose @@ -331,28 +581,85 @@ function Set-PCCustomerBillingProfile return (_formatResult -obj $obj -type "Profile") } -function Get-PCCustomerCompanyProfile -{ +<# +.SYNOPSIS +Returns the specified customer's company profile. +.DESCRIPTION +The Get-PCCustomerCompanyProfile cmdlet returns the customer's company profile. + +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. + +.PARAMETER TenantId +Specifies a tenant id to scope this cmdlet. +.EXAMPLE +Get-PCCustomerCompanyProfile -TenantId <TenantId> +Retrieve the customer's company profile for the specified tenant id. +.NOTES +#> +function Get-PCCustomerCompanyProfile { [CmdletBinding()] param ( - [Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/profiles/company" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/profiles/company" -f $TenantId + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) + $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Profile") } -function New-PCCustomerBillingProfile -{ +<# +.SYNOPSIS +This cmdlet is used to create a PowerShell object that can be passed to other cmdlets, such as the the New-PCCustomer cmdlet when creating a new customer. +.DESCRIPTION +The New-PCCustomerBillingProfile cmdlet creates a PowerShell object that includes properties for the customer billing profile. +.PARAMETER SaToken +Specifies an authentication token you have created with your Partner Center credentials. +.PARAMETER FirstName +Specifies the first name of the customer company contact. +.PARAMETER LastName +Specifies the last name of the customer company contact. +.PARAMETER Email +Specifies the email address of the customer company contact. +.PARAMETER Culture +Specifies the two letter ISO culture of the customer company contact. +.PARAMETER Language +Specifies the two letter ISO culture of the customer company contact. +.PARAMETER CompanyName +Specifies the name of the customer company. +.PARAMETER Country +Specifies the country for the customer company. +.PARAMETER Region +Specifies the three letter region for the customer company. +.PARAMETER City +Specifies the city for the customer's company address. +.PARAMETER State +Specifies the state for the customer's company address. +.PARAMETER AddressLine1 +Specifies the first line of the street address for the customer company's address. +.PARAMETER PostalCode +Specifies the postal code for the customer company's address. +.PARAMETER PhoneNumber +Specifies the phone number for the customer company's contact. +.PARAMETER DefaultAddress +Specifies a PowerShell object that contains the default address information for the company. +.EXAMPLE +$cBP = New-PCCustomerBillingProfile -FirstName 'Joe' -LastName 'Smith' -Email 'joe@contoso.com' -Country 'US' -City 'Redmond' -State 'WA' -PostalCode 98502 - AddressLine1 '1 Microsoft Way' +Create an object that has the billing profile information for Joe Smith at Contoso. +.NOTES +#> +function New-PCCustomerBillingProfile { [CmdletBinding()] param ( [Parameter(Mandatory = $true)][string]$FirstName, @@ -361,28 +668,59 @@ function New-PCCustomerBillingProfile [Parameter(Mandatory = $true)][string]$Culture, [Parameter(Mandatory = $true)][string]$Language, [Parameter(Mandatory = $true)][string]$CompanyName, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string]$Country, - [Parameter(ParameterSetName='AllDetails',Mandatory = $false)][string]$Region = $null, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string]$City, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string]$State, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string]$AddressLine1, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string]$PostalCode, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string]$PhoneNumber, - [Parameter(ParameterSetName='DefaultAddress',Mandatory = $true)][DefaultAddress]$DefaultAddress + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string]$Country, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $false)][string]$Region = $null, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string]$City, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string]$State, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string]$AddressLine1, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string]$PostalCode, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string]$PhoneNumber, + [Parameter(ParameterSetName = 'DefaultAddress', Mandatory = $true)][DefaultAddress]$DefaultAddress ) - switch ($PsCmdlet.ParameterSetName) - { - 'AllDetails' { $billingProfile = [BillingProfile]::new($Email,$Culture,$Language,$CompanyName,$Country,$Region,$City,$State,$AddressLine1, ` - $PostalCode, $FirstName, $LastName, $PhoneNumber) } - 'DefaultAddress'{ $billingProfile = [BillingProfile]::new($FirstName, $LastName, $Email,$Culture,$Language,$CompanyName,$DefaultAddress)} + switch ($PsCmdlet.ParameterSetName) { + 'AllDetails' { + $billingProfile = [BillingProfile]::new($Email, $Culture, $Language, $CompanyName, $Country, $region, $City, $State, $AddressLine1, ` + $PostalCode, $FirstName, $LastName, $PhoneNumber) + } + 'DefaultAddress' { $billingProfile = [BillingProfile]::new($FirstName, $LastName, $Email, $Culture, $Language, $CompanyName, $DefaultAddress)} } return $billingProfile } -function New-PCCustomerDefaultAddress -{ +<# +.SYNOPSIS +This cmdlet is used to create a PowerShell object that can be passed to other cmdlets, such as the the New-PCCustomerBillingProfile cmdlet. +.DESCRIPTION +The New-PCCustomerDefaultAddress cmdlet returns a PowerShell object with the properties for a default address. + +.PARAMETER Country +Specifies the country for the customer company. +.PARAMETER Region +Specifies the three letter region for the customer company. + +.PARAMETER City +Specifies the city for the customer's company address. +.PARAMETER State +Specifies the state for the customer's company address. + +.PARAMETER AddressLine1 +Specifies the first address line for the customer's address. +.PARAMETER PostalCode +Specifies the postal code for the customer's address. +.PARAMETER FirstName +Specifies the first name for the customer's contact. +.PARAMETER LastName +Specifies the last name for the customer's contact. +.PARAMETER PhoneNumber +Specifies the phone number for the customer's contact. +.EXAMPLE + $cda = New-PCCustomerDefaultAddress -Country 'US' -Region 'USA' -City 'Redmond' -State 'WA' -AddressLine1 '1 Microsoft Way' -PostalCode '98502' -FirstName 'John' -LastName 'Smith' -PhoneNumber '8005551212' +Create a new PowerShell object that includes the properties for a customer's default address. +.NOTES +#> +function New-PCCustomerDefaultAddress { [CmdletBinding()] param ( [Parameter(Mandatory = $true)][string]$Country, @@ -396,23 +734,58 @@ function New-PCCustomerDefaultAddress [Parameter(Mandatory = $true)][string]$PhoneNumber ) - $DefaultAddress = [DefaultAddress]::new($Country, $Region, $City,$State,$AddressLine1,$PostalCode,$FirstName,$LastName,$PhoneNumber) + $DefaultAddress = [DefaultAddress]::new($Country, $Region, $City, $State, $AddressLine1, $PostalCode, $FirstName, $LastName, $PhoneNumber) return $DefaultAddress } -function New-PCCustomerCompanyProfile -{ +<# +.SYNOPSIS +Returns a PowerShell object that includes the properties for the customer's company properties. The object is passed to the New-PCCustomer cmdlet to create a new customer. +.DESCRIPTION +The New-PCCustomerCompanyProfile cmdlet returns a PowerShell object that includes the properties for the customer's company properties. + +.PARAMETER Domain +Specifies the domain for the company profile +.EXAMPLE +$ccp = New-PCCustomerCompanyProfile -Domain 'contoso.onmicrosoft.com' +Create a new customer profile with the contoso.onmicrosoft.com domain and assign it to $ccp variable. +.NOTES +#> +function New-PCCustomerCompanyProfile { [CmdletBinding()] param ( [Parameter(Mandatory = $true)][string]$Domain ) $companyProfile = [CompanyProfile]::new($Domain) - return $companyProfile + return $CompanyProfile } -function New-PCAddress -{ +<# +.SYNOPSIS +Returns a PowerShell object with all of the address properties. This is used to create new customers. +.DESCRIPTION +The New-PCAddress cmdlet returns a PowerShell object with all of address properties. +.PARAMETER AddressLine1 +Specifies address line 1 for the new address. +.PARAMETER AddressLine2 +Specifies address line 2 for the new address. +.PARAMETER City +Specifies the city name. +.PARAMETER State +Specifies the state name. +.PARAMETER PostalCode +Specifies the postal code. +.PARAMETER Country +Specifies the country +.PARAMETER Region +Specifies the region. +.EXAMPLE + $add = New-PCAddress -AddressLine1 '1 Microsoft Way' -City 'Redmond' -State 'WA' -Country 'US' -PostalCode '95802' +Create a new address object for an address and assign it to the $add variable. +.NOTES +#> +function New-PCAddress { [CmdletBinding()] param ( [Parameter(Mandatory = $true)][string]$AddressLine1, @@ -424,36 +797,68 @@ function New-PCAddress [Parameter(Mandatory = $false)][string]$Region = $null ) - $Address = [DefaultAddress]::new($Country, $Region, $City,$State,$AddressLine1,$PostalCode) - if ($AddressLine2) {$Address.AddressLine2 = $AddressLine2} - return $Address + $address = [DefaultAddress]::new($Country, $Region, $City, $State, $AddressLine1, $PostalCode) + if ($AddressLine2) {$address.AddressLine2 = $AddressLine2} + return $address } -function Test-PCAddress -{ +<# +.SYNOPSIS +Validates the provided address information to determine if it meets the Partner Center validation rules. +.DESCRIPTION +The Test-PCAddress cmdlet validates the provided the address information as to whether it conforms to the Partner Center address rules. +.PARAMETER SaToken +Specifies an partner center access token. +.PARAMETER Address +Specifies a variable object that includes all of the address information. This object can be created by using the New-PCAddress cmdlet. +.PARAMETER AddressLine1 +Specifies the first address line. +.PARAMETER AddressLine2 +Specifies the second address line. +.PARAMETER City +Specifies the city. +.PARAMETER State +Specifies the state. +.PARAMETER PostalCode +Specifies the postal code. +.PARAMETER Country +Specifies a two letter ISO code to define the country. +.EXAMPLE +$address = New-PCAddress -AddressLine1 '<string>' -AddressLine2 '<string>' -City '<string>' -State '<string>' -PostalCode '<string>' -Country 'two digits Country code' -region '<string>' +Test-PCAddress -Address $add +Validate an address by passing an object variable named $add that was created using the New-PCAddress cmdlet. +.EXAMPLE +Test-PCAddress -AddressLine1 '1 Microsoft Way' -City 'Redmond' -State 'WA' -Country 'US' -PostalCode '95802' +Validate an address by passing the address information to the cmdlet. +.NOTES +#> +function Test-PCAddress { [CmdletBinding()] - param ( [Parameter(ParameterSetName='ByObject',Mandatory = $true)][DefaultAddress] $Address, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $AddressLine1, - [Parameter(ParameterSetName='AllDetails',Mandatory = $false)][string] $AddressLine2, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $City, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $State, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $PostalCode, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][string] $country, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) + param ( + [Parameter(ParameterSetName = 'ByObject', Mandatory = $true)][DefaultAddress] $Address, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $AddressLine1, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $false)][string] $AddressLine2, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $City, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $State, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $PostalCode, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][string] $Country, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken + ) + _testTokenContext($SaToken) $obj = @() $url = "https://api.partnercenter.microsoft.com/v1/validations/address" - $headers = @{"Authorization"="Bearer $satoken"} - $headers += @{"MS-Contract-Version"="v1"} - $headers += @{"MS-RequestId"=[Guid]::NewGuid()} - $headers += @{"MS-CorrelationId"=[Guid]::NewGuid()} + $headers = @{"Authorization" = "Bearer $SaToken"} + $headers += @{"MS-Contract-Version" = "v1"} + $headers += @{"MS-RequestId" = [Guid]::NewGuid()} + $headers += @{"MS-CorrelationId" = [Guid]::NewGuid()} - switch ($PsCmdlet.ParameterSetName) - { - 'ByObject' { $address_tmp = $Address} - 'AllDetails' { $address_tmp = [DefaultAddress]::new($Country, $Region, $City,$State,$AddressLine1,$PostalCode)} + + # TODO $Region is listed below, but it doesn't appear to be assigned from anywhere. + switch ($PsCmdlet.ParameterSetName) { + 'ByObject' { $address_tmp = $address} + 'AllDetails' { $address_tmp = [DefaultAddress]::new($Country, $Region, $City, $State, $AddressLine1, $PostalCode)} } $body = $address_tmp | ConvertTo-Json -Depth 100 diff --git a/PartnerCenterModule/PartnerCenterServiceRequest.psm1 b/PartnerCenterModule/PartnerCenterServiceRequest.psm1 index 36db6fd..da3d7db 100644 --- a/PartnerCenterModule/PartnerCenterServiceRequest.psm1 +++ b/PartnerCenterModule/PartnerCenterServiceRequest.psm1 @@ -1,6 +1,6 @@ Set-StrictMode -Version latest <# - © 2017 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. + © 2018 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. This sample code is provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, @@ -12,98 +12,187 @@ $here = Split-Path -Parent $MyInvocation.MyCommand.Path . "$here\commons.ps1" -function Get-PCSR -{ +<# +.SYNOPSIS +Returns either a list of service requests or a specific service request. +.DESCRIPTION +The Get-PCSR cmdlet retrieves either a specific service request or a list of service requests for the tenant or the partner. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant id used for scoping this cmdlet. +.PARAMETER ServiceRequestId +Specifies the service request id to return. +.EXAMPLE +Get-PCSR +Get all service requests. + +.EXAMPLE +Get-PCSR -ServiceRequestId '335c4cad-b235-4a31-8273-e73da43e7817' +Get the specified service request. + +.EXAMPLE +Get-PCSR -TenantId '3c762ceb-b839-4b4a-85d8-0e7304c89f62' +Get all customer service requests for the specified tenant id. + +.NOTES +The -All parameter has been removed in this version. +#> +function Get-PCSR { [CmdletBinding()] Param( - [Parameter(ParameterSetName='tenantid', Mandatory = $false)][String]$tenantid, - [Parameter(ParameterSetName='srid', Mandatory = $false)][String]$serviceRequestId, - [Parameter(ParameterSetName='all', Mandatory = $true)][switch]$all, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][String]$TenantId, + [Parameter(Mandatory = $false)][String]$ServiceRequestId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() - $headers = @{Authorization="Bearer $satoken"} + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) - switch ($PsCmdlet.ParameterSetName) - { - "tenantid" {$url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/servicerequests" -f $tenantid} - "all" {$url = "https://api.partnercenter.microsoft.com/v1/servicerequests"} - "srid" {$url = "https://api.partnercenter.microsoft.com/v1/servicerequests/{0}" -f $serviceRequestId} + if ($TenantId) { + if ($ServiceRequestId) { + + $url = "https://api.partnercenter.microsoft.com/v1/servicerequests/{0}" -f $ServiceRequestId + } + + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/servicerequests" -f $TenantId } + else { + if ($ServiceRequestId) { + + $url = "https://api.partnercenter.microsoft.com/v1/servicerequests/{0}" -f $ServiceRequestId + } + else { + + $url = "https://api.partnercenter.microsoft.com/v1/servicerequests" + } + } + $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "ServiceRequest") } -function Get-PCSRTopics -{ +<# +.SYNOPSIS +Returns a list of service request topics. +.DESCRIPTION +The Get-PCSRTopic cmdlet retrieves a list of service request topics. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.EXAMPLE +Get-PCSRTopic +.NOTES +#> +function Get-PCSRTopic { [CmdletBinding()] - param([Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - - Write-Warning " Get-PCSRTopics is deprecated and will not be available in future releases, use Get-PCSRTopic instead." + param([Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken) + _testTokenContext($SaToken) $obj = @() - + $url = "https://api.partnercenter.microsoft.com/v1/servicerequests/supporttopics" - $headers = @{Authorization="Bearer $satoken"} + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "ServiceRequestTopics") } -# Add non-plural version of the cmdlet. The plural version will be removed in future versions. -function Get-PCSRTopic -{ - [CmdletBinding()] - param([Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) +<# +.SYNOPSIS +Creates a new service request. +.DESCRIPTION +The New-PCSR cmdlet creates a new service request. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER ServiceRequest +Specifies the service request object variable created that defines the service request to open. +.PARAMETER Title +Specifies the title of the service request. +.PARAMETER Description +Specifies details of the the service request. - $obj = @() - - $url = "https://api.partnercenter.microsoft.com/v1/servicerequests/supporttopics" - $headers = @{Authorization="Bearer $satoken"} +.PARAMETER Severity +Specifies the severity of request. Valid entries are: minimal, moderate, or critical. +.PARAMETER SupportTopicId +Specifies the Id of the support topic that should be associated with the new service request. +.PARAMETER ServiceRequestContact +Specifies an object that defines the contact for the new service request. +.PARAMETER ServiceRequestNote +Specifies a note to add to the new service request. +.PARAMETER AgentLocale +Specifies the two letter ISO code for the language and country. For example United States English would be en-us. +.EXAMPLE +Create a new service request - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj += $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "ServiceRequestTopics") -} +Get support topic for the request + + $supportTopic = Get-PCSRTopics | Where-Object name -Contains '<support topic name>' + New-PCSR -title '<service request title>' -description '<service request description>' -severity '<Minimal | Moderate | Critical>' -supportTopicID '<support topic id guid>' + +.EXAMPLE +Create a new service request by specifying the information manually. + + $serviceRequestContact = [ServiceRequestContact]::new() + $serviceRequestContact.FirstName = '<first name>' + $serviceRequestContact.LastName = '<last name>' + $serviceRequestContact.Email = '<Email>' + $serviceRequestContact.PhoneNumber = '<phone number>' + $supportTopic = Get-PCSRTopics | Where-Object name -Contains '<support topic name>' -function New-PCSR -{ - [CmdletBinding()] - param ( - [Parameter(ParameterSetName='byObject', Mandatory = $true)][ServiceRequest]$serviceRequest, - [Parameter(ParameterSetName='byParam', Mandatory = $true)][string]$title, - [Parameter(ParameterSetName='byParam', Mandatory = $true)][string]$description, - [Parameter(ParameterSetName='byParam', Mandatory = $true)][ValidateSet("Minimal","Moderate","Critical")][string]$severity, - [Parameter(ParameterSetName='byParam', Mandatory = $true)][string]$supportTopicID, - [Parameter(ParameterSetName='byParam', Mandatory = $false)][ServiceRequestContact]$serviceRequestContact, - [Parameter(ParameterSetName='byParam', Mandatory = $false)][ServiceRequestNote]$serviceRequestNote, - [Parameter(Mandatory = $false)][string]$agentLocale = "en-US", - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + $serviceRequestNote = [ServiceRequestNote]::new() + $serviceRequestNote.Text = '<problem detailed description>' + + $serviceRequest = [ServiceRequest]::new() + $serviceRequest.Title = '<title>' + $serviceRequest.SYNOPSIS \n \n .DESCRIPTION = '<description>' + $serviceRequest.Severity = '<Minimal | Moderate | Critical>' + $serviceRequest.supportTopicID = $supportTopic.id + $serviceRequest.PrimaryContact = $serviceRequestContact + $serviceRequest.NewNote = $serviceRequestNote + + New-PCSR -serviceRequest $serviceRequest +.NOTES +#> +function New-PCSR { + [CmdletBinding()] + param ( + [Parameter(ParameterSetName = 'byObject', Mandatory = $true)][ServiceRequest]$ServiceRequest, + [Parameter(ParameterSetName = 'byParam', Mandatory = $true)][string]$Title, + [Parameter(ParameterSetName = 'byParam', Mandatory = $true)][string]$Description, + [Parameter(ParameterSetName = 'byParam', Mandatory = $true)][ValidateSet("Minimal", "Moderate", "Critical")][string]$Severity, + [Parameter(ParameterSetName = 'byParam', Mandatory = $true)][string]$SupportTopicID, + [Parameter(ParameterSetName = 'byParam', Mandatory = $false)][ServiceRequestContact]$ServiceRequestContact, + [Parameter(ParameterSetName = 'byParam', Mandatory = $false)][ServiceRequestNote]$ServiceRequestNote, + [Parameter(Mandatory = $false)][ValidatePattern("^(bg-bg|pt-br|zh-cn|cs-cz|de-de|da-dk|et-ee|ca-es|es-es|eu-es|gl-es|fi-fi|fr-fr|el-gr|hr-hr|hu-hu|id-id|he-il|hi-in|it-it|ja-jp|ko-kr|kk-kz|lt-lt|lv-lv|ms-my|nl-nl|nb-no|pl-pl|pt-pt|ro-ro|sr-cyrl-rs|sr-latn-rs|ru-ru|sv-se|zh-sg|sl-si|sk-sk|th-th|tr-tr|zh-tw|uk-ua|en-us|vi-vn|)$")][string]$AgentLocale = "en-US", + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/servicerequests/{0}" -f $agentLocale - $headers = @{Authorization="Bearer $satoken"} - $headers += @{"MS-RequestId"=[Guid]::NewGuid()} - $headers += @{"MS-CorrelationId"=[Guid]::NewGuid()} + $url = "https://api.partnercenter.microsoft.com/v1/servicerequests/{0}" -f $AgentLocale + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $newSR = [ServiceRequest]::new() if ($serviceRequest) { $newSR = $serviceRequest } - else - { - $newSR = [ServiceRequest]::new($title,$description,$severity,$supportTopicID) - if ($serviceRequestContact) { $newSR.PrimaryContact = $serviceRequestContact } - if ($serviceRequestNote) { $newSR.NewNote = $serviceRequestNote } + else { + $newSR = [ServiceRequest]::new($Title, $Description, $Severity, $SupportTopicID) + if ($ServiceRequestContact) { $newSR.primaryContact = $ServiceRequestContact } + if ($ServiceRequestNote) { $newSR.newNote = $ServiceRequestNote } } $body = $newSR | ConvertTo-Json -Depth 100 @@ -114,38 +203,66 @@ function New-PCSR return (_formatResult -obj $obj -type "ServiceRequest") } -function Set-PCSR -{ +<# +.SYNOPSIS +Updates a service request. +.DESCRIPTION +The Set-PCSR cmdlet updates a service request.. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER ServiceRequest +Specifies the updated service request object used to update the service request. +.PARAMETER Status +Specifies whether the service request is open or closed. Valid values are: open and closed. +.PARAMETER Description +Specifies the updated service request description. +.PARAMETER Title +Specifies the updated service request title. +.PARAMETER AddNote +Specifies a note to add to the service request. +.EXAMPLE +$sr = Get-PCServiceRequest -TenantId 'e974093c-2a52-4ebd-994e-b3e7e0f90cf2' | Where-Object {$_.Status -eq 'open'} +Set-PCSR -ServiceRequest $sr -Status 'closed' +Set all open service request for the specified tenant to closed. +.EXAMPLE +$sr = Get-PCServiceRequest -ServiceRequestId '615112491169010' +Set-PCSR -ServiceRequest $sr -AddNote 'After further testing, the problem is still occurring.' +Add a note to an existing service request. +.NOTES +#> +function Set-PCSR { [CmdletBinding()] param ( - [Parameter(ParameterSetName='byParam', Mandatory = $true,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)][PSCustomObject]$serviceRequest, - [Parameter(ParameterSetName='byParam', Mandatory = $false)][ValidateSet("open","closed")][string]$status, - [Parameter(ParameterSetName='byParam', Mandatory = $false)][string]$title, - [Parameter(ParameterSetName='byParam', Mandatory = $false)][string]$description, - [Parameter(ParameterSetName='byParam', Mandatory = $false)][string]$addnote, - [Parameter(ParameterSetName='byParam', Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(ParameterSetName = 'byParam', Mandatory = $true, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][PSCustomObject]$ServiceRequest, + [Parameter(ParameterSetName = 'byParam', Mandatory = $false)][ValidateSet("open", "closed")][string]$Status, + [Parameter(ParameterSetName = 'byParam', Mandatory = $false)][string]$Title, + [Parameter(ParameterSetName = 'byParam', Mandatory = $false)][string]$Description, + [Parameter(ParameterSetName = 'byParam', Mandatory = $false)][string]$AddNote, + [Parameter(ParameterSetName = 'byParam', Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) + _testTokenContext($SaToken) $obj = @() - if ($serviceRequest) {$body = $serviceRequest | ConvertTo-Json -Depth 100} - else - { - $actualSR = Get-PCSR -serviceRequestId $serviceRequest.id -satoken $satoken - if ($status) {$actualSR.status = $status - $body = $actualSR | ConvertTo-Json -Depth 100} - if ($addnote) { - $newSR = [ServiceRequest]::new($actualSR.title, $actualSR.description,$actualSR.severity,$actualSR.SupportTopicID) - $newSR.newnote = $addnote + if ($ServiceRequest) {$body = $ServiceRequest | ConvertTo-Json -Depth 100} + else { + $actualSR = Get-PCSR -serviceRequestId $serviceRequest.id -SaToken $SaToken + if ($Status) { + $actualSR.status = $Status + $body = $actualSR | ConvertTo-Json -Depth 100 + } + if ($AddNote) { + $newSR = [ServiceRequest]::new($actualSR.title, $actualSR.description, $actualSR.severity, $actualSR.supportTopicID) + $newSR.newNote = $AddNote $body = $newSR | ConvertTo-Json -Depth 100 } } - $url = "https://api.partnercenter.microsoft.com/v1/servicerequests/{0}" -f $serviceRequest.id - $headers = @{Authorization="Bearer $satoken"} - $headers += @{"MS-RequestId"=[Guid]::NewGuid()} - $headers += @{"MS-CorrelationId"=[Guid]::NewGuid()} + $url = "https://api.partnercenter.microsoft.com/v1/servicerequests/{0}" -f $ServiceRequest.id + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $utf8body = [System.Text.Encoding]::UTF8.GetBytes($body) diff --git a/PartnerCenterModule/PartnerCenterSubscription.psm1 b/PartnerCenterModule/PartnerCenterSubscription.psm1 index 618f941..e3c0cd4 100644 --- a/PartnerCenterModule/PartnerCenterSubscription.psm1 +++ b/PartnerCenterModule/PartnerCenterSubscription.psm1 @@ -1,6 +1,6 @@ Set-StrictMode -Version latest <# - © 2017 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. + © 2018 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. This sample code is provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, @@ -12,62 +12,103 @@ $here = Split-Path -Parent $MyInvocation.MyCommand.Path . "$here\commons.ps1" -function Get-PCSubscription -{ - [CmdletBinding()] +<# +.SYNOPSIS +Returns a list of subscriptions for a specified tenant or MPN partner Id. +.DESCRIPTION +The Get-PCSubscription cmdlet returns a list of subscriptions for a specified customer tenant or MPN partner id. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. The tenant must be specified either using this parameter or by using the Select-PCCustomer cmdlet. + +.PARAMETER SubscriptionId +Specifies a subscription id for which to return detailed information. +.PARAMETER AddOns +Specifies whether you want to return any addons for the subscription. +.PARAMETER PartnerId +Specifies the Mpn partner id for which to list the subscriptions. +.PARAMETER ResultSize +Specifies the maximum number of results to return. The default value is 200. +.PARAMETER OrderId +Specifies an order id to for which to return a list of subscriptions. +.EXAMPLE + Get-PCSubscription -PartnerId '46662300' +Return a list of all subscriptions for the specified partner id +.EXAMPLE + Get-PCSubscription -TenantId 99ed2a33-e3ea-34df-bade-30997e2413e5 -SubscriptionId 335c4cad-b235-4a31-8273-e73da43e7817 +Return information about the specified subscription. +.EXAMPLE + Get-PCSubscription -TenantId 99ed2a33-e3ea-34df-bade-30997e2413e5 -OrderId 335c4cad-b235-4a31-8273-e73da43e7817 +Return a list of subscriptions from an order. +.EXAMPLE + Get-PCSubscription -TenantId 99ed2a33-e3ea-34df-bade-30997e2413e5 -PartnerId '46662300' +Return a list of customer subscriptions from a reseller (Only available in an Indirect Provider tenant) +.NOTES +#> +function Get-PCSubscription { + [CmdletBinding(DefaultParameterSetName = 'SubscriptionId')] Param( - [Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(ParameterSetName='all', Mandatory = $false)][switch]$all, - [Parameter(ParameterSetName='subscriptionid', Mandatory = $false)][String]$subscriptionid, - [Parameter(ParameterSetName='subscriptionid', Mandatory = $false)][switch]$addons, - [Parameter(ParameterSetName='partnerid', Mandatory = $true)][String]$partnerid, - [Parameter(ParameterSetName='partnerid',Mandatory = $false)][int]$size = 200, - [Parameter(ParameterSetName='orderid', Mandatory = $false)][string]$orderid, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken, + [Parameter(ParameterSetName = 'SubscriptionId', Mandatory = $false)][String]$SubscriptionId, + [Parameter(ParameterSetName = 'SubscriptionId', Mandatory = $false)][switch]$AddOns, + [Parameter(ParameterSetName = 'PartnerId', Mandatory = $true)][String]$PartnerId, + [Parameter(ParameterSetName = 'PartnerId', Mandatory = $false)][int]$ResultSize= 200, + [Parameter(ParameterSetName = 'OrderId', Mandatory = $false)][string]$OrderId ) - _testTokenContext($satoken) - _testTenantContext ($tenantid) - + _testTokenContext($SaToken) + _testTenantContext ($TenantId) - function Private:Get-SubscriptionsAllInner ($satoken, $tenantid) + <# + function Private:Get-SubscriptionsAllInner ($SaToken, $TenantId) { $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions" -f $TenantId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Subscription") } + #> - function Private:Get-SubscriptionInner ($satoken, $tenantid, $subscriptionid,$addons) - { + function Private:Get-SubscriptionInner ($SaToken, $TenantId, $SubscriptionId, $AddOns) { $obj = @() - if($subscriptionid) - { - if ($addons) - { - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions/{1}/addons" -f $tenantid, $subscriptionid - $headers = @{Authorization="Bearer $satoken"} + if ($SubscriptionId) { + if ($addons) { + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions/{1}/addons" -f $TenantId, $SubscriptionId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "SubscriptionAddons") } else { - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions/{1}" -f $tenantid, $subscriptionid - $headers = @{Authorization="Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions/{1}" -f $TenantId, $SubscriptionId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Subscription") } } - else - { - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + else { + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions" -f $TenantId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json @@ -75,33 +116,38 @@ function Get-PCSubscription } } - function Private:Get-SubscriptionPartnerInner ($satoken, $tenantid, $partnerid, $size) - { + function Private:Get-SubscriptionPartnerInner ($SaToken, $TenantId, $partnerId, $ResultSize) { $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions?mpn_id={1}&offset=0&size={2}" -f $tenantid,$partnerid,$size - $headers = @{Authorization="Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions?mpn_id={1}&offset=0&size={2}" -f $TenantId, $partnerId, $ResultSize + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Subscription") } - function Private:Get-SubscriptionByOrderInner ($satoken, $tenantid, $orderid) - { + function Private:Get-SubscriptionByOrderInner ($SaToken, $TenantId, $OrderId) { $obj = @() - if($orderid) - { - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions?order_id={1}" -f $tenantid, $orderid - $headers = @{Authorization="Bearer $satoken"} + if ($OrderId) { + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions?order_id={1}" -f $TenantId, $OrderId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Subscription") } - else - { - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + else { + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions" -f $TenantId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json @@ -109,54 +155,141 @@ function Get-PCSubscription } } - switch ($PsCmdlet.ParameterSetName) - { - "subscriptionid" {$res = Get-SubscriptionInner -satoken $satoken -tenantid $tenantid -subscriptionid $subscriptionid -addons $addons - return $res} + # Determine which type of search to run based on the parameter sets. + If ($PsCmdlet.ParameterSetName -eq "SubscriptionId") { + $res = Get-SubscriptionInner -SaToken $SaToken -TenantId $TenantId -SubscriptionId $SubscriptionId -addons $addons + return $res + } + elseif ($PsCmdlet.ParameterSetName -eq "PartnerId") { + $res = Get-SubscriptionPartnerInner -SaToken $SaToken -TenantId $TenantId -partnerId $partnerId -ResultSize $ResultSize + return $res + } + elseif ($PsCmdlet.ParameterSetName -eq "OrderId") { + $res = Get-SubscriptionByOrderInner -SaToken $SaToken -TenantId $TenantId -OrderId $OrderId + return $res + } + else { + # If no parameter sets were valid, then return all subscriptions + $res = Get-SubscriptionsInner -SaToken $SaToken -TenantId $TenantId + return $res + } - "partnerid" {$res = Get-SubscriptionPartnerInner -satoken $satoken -tenantid $tenantid -partnerid $partnerid -size $size - return $res} +} - "orderid" {$res = Get-SubscriptionByOrderInner -satoken $satoken -tenantid $tenantid -orderid $orderid - return $res} +<# +.SYNOPSIS +Modifies an existing subscription. +.DESCRIPTION +The Set-PCSubscription cmdlet modifies an existing subscription. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.PARAMETER Subscription +Specifies the subscription object that identifies the subscription you will modified. This object can be retrieved using the Get-PCSubscription cmdlet. +.PARAMETER Status +Specifies the status for the subscription. Valid values are: none, active, suspended, and deleted. +.PARAMETER FriendlyName +Specifies a friendly name for the subscription. +.PARAMETER AutoRenew +Specifies as to whether the subscription will auto renew. This is only valid on license-based subscriptions. Valid inputs are: enabled, disabled. This parameter used to be -AutoRenewEnabled in earlier releases. +.PARAMETER Quantity +Specifies the number of licenses included in the subscription. This is valid only on license-based subscriptions. +.EXAMPLE +Update subscription friendly name - "all" {$res = Get-SubscriptionsAllInner -satoken $satoken -tenantid $tenantid - return $res} - } +Find the tenant information about the customer named Wingtip Toys +$customer = Get-PCCustomer | Where-Object {$_.CompanyProfile.CompanyName -eq 'Wingtip Toys'} -} +Find the the customer subscription +$subscription = Get-PCSubscription -TenantId $customer.id | Where-Object {$_.FriendlyName -eq 'old friendly name'} + +Update the subscription with a new friendly name +$subscription | Set-PCSubscription -TenantId $customer.id -FriendlyName 'New friendly name' + +.EXAMPLE +Update subscription seats (license based only) + +Find the tenant information about the customer named Wingtip Toys +$customer = Get-PCCustomer | Where-Object {$_.CompanyProfile.CompanyName -eq 'Wingtip Toys'} + +Find the the customer subscription +$subscription = Get-PCSubscription -TenantId $customer.id | Where-Object {$_.FriendlyName -eq 'Office 365 Enterprise E1'} + +Update the license quantity for the specified subscription +$subscription | Set-PCSubscription -TenantId $customer.id -quantity 100 + +.EXAMPLE +Change the subscription auto renewal + +Find the tenant information about the customer named Wingtip Toys +$customer = Get-PCCustomer | Where-Object {$_.CompanyProfile.CompanyName -eq 'Wingtip Toys'} + +Find the the customer subscription +$subscription = Get-PCSubscription -TenantId $customer.id | Where-Object {$_.FriendlyName -eq 'Office 365 Enterprise E1'} + +Modify the AutoRenew option for the subscription +$subscription | Set-PCSubscription -TenantId $customer.id -AutoRenew disabled + +.EXAMPLE +Suspend a subscription -function Set-PCSubscription -{ +Find the tenant information about the customer named Wingtip Toys +$customer = Get-PCCustomer | Where-Object {$_.CompanyProfile.CompanyName -eq 'Wingtip Toys'} + +Find the the customer subscription +$subscription = Get-PCSubscription -TenantId $customer.id | Where-Object {$_.FriendlyName -eq 'Office 365 Enterprise E1'} + +Suspend the subscription +$subscription | Set-PCSubscription -TenantId $customer.id -status suspended + +.EXAMPLE +Activate a subscription + +Find the tenant information about the customer named Wingtip Toys +$customer = Get-PCCustomer | Where-Object {$_.CompanyProfile.CompanyName -eq 'Wingtip Toys'} + +Find the the customer subscription +$subscription = Get-PCSubscription -TenantId $customer.id | Where-Object {$_.FriendlyName -eq 'Office 365 Enterprise E1'} + +$subscription | Set-PCSubscription -TenantId $customer.id -Status active + +.NOTES +#> +function Set-PCSubscription { [CmdletBinding()] Param( - [Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $true,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)][PSCustomObject]$subscription, - [Parameter(Mandatory = $false)][ValidateSet("none","active","suspended","deleted")][String]$status, - [Parameter(Mandatory = $false)][String]$friendlyName, - [Parameter(Mandatory = $false)][ValidateSet("enabled","disabled")][String]$AutoRenewEnabled, - [Parameter(Mandatory = $false)][int]$quantity, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $true, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][PSCustomObject]$Subscription, + [Parameter(Mandatory = $false)][ValidateSet("none", "active", "suspended", "deleted")][String]$Status, + [Parameter(Mandatory = $false)][String]$FriendlyName, + [Parameter(Mandatory = $false)][ValidateSet("enabled", "disabled")][String]$AutoRenew, + [Parameter(Mandatory = $false)][int]$Quantity, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $actualSubscription = Get-PCSubscription -satoken $satoken -tenantid $tenantid -subscriptionid $subscription.Id + $actualSubscription = Get-PCSubscription -SaToken $SaToken -TenantId $TenantId -SubscriptionId $Subscription.Id + + if ($Status) {$actualSubscription.status = $status} + if ($FriendlyName) {$actualSubscription.friendlyName = $FriendlyName} + if ($AutoRenew -eq "enabled") {$actualSubscription.autoRenewEnabled = $true} + if ($AutoRenew -eq "disabled") {$actualSubscription.autoRenewEnabled = $false} + if (($Quantity) -and ($actualSubscription.billingType -eq "license")) {$actualSubscription.quantity = $Quantity} + + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions/{1}" -f $TenantId, $Subscription.Id - if($status) {$actualSubscription.status = $status} - if($friendlyName){$actualSubscription.friendlyName = $friendlyName} - if($AutoRenewEnabled -eq "enabled") {$actualSubscription.autoRenewEnabled = $true} - if($AutoRenewEnabled -eq "disabled") {$actualSubscription.autoRenewEnabled = $false} - if(($quantity) -and ($actualSubscription.billingType -eq "license")) {$actualSubscription.quantity = $quantity} + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions/{1}" -f $tenantid, $subscription.Id - $headers = @{Authorization="Bearer $satoken"} $body = $actualSubscription | ConvertTo-Json -Depth 100 $utf8body = [System.Text.Encoding]::UTF8.GetBytes($body) - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Body $utf8body -Method "PATCH" #-Debug -Verbose + $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Body $utf8body -Method "PATCH" -Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "Subscription") } diff --git a/PartnerCenterModule/PartnerCenterUsage.psm1 b/PartnerCenterModule/PartnerCenterUsage.psm1 index 9d27325..f9a460d 100644 --- a/PartnerCenterModule/PartnerCenterUsage.psm1 +++ b/PartnerCenterModule/PartnerCenterUsage.psm1 @@ -1,6 +1,6 @@ Set-StrictMode -Version latest <# - © 2017 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. + © 2018 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. This sample code is provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, @@ -12,108 +12,126 @@ $here = Split-Path -Parent $MyInvocation.MyCommand.Path . "$here\commons.ps1" -function Get-PCUsage -{ +<# +.SYNOPSIS +Retrieve a collection of usage records for the specified date range. Usage records are only available for the last 90 days. +.DESCRIPTION +The Get-PCUsage cmdlet returns the usage records specified by the start and end times. +.PARAMETER SaToken +Specifies a authentication token you have created with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.PARAMETER SubscriptionId +Specifies a subscription if for which to return usage information. +.PARAMETER StartTime +Specifies the start time for which to retrieve usage information. Usage is only available for the last 90 days, therefore this value cannot be more than 90 days from the current date. +.PARAMETER EndTime +Specifies the end time for which to retrieve usage information. +.PARAMETER Granularity +Specifies the granularity of the data to return. Valid values are: daily or hourly. The default value is daily. +.PARAMETER ShowDetail +Default this is set to $true. If set to $true, the utilization records will be split by the resource instance levels. If set to false, the utilization records will be aggregated on the resource level. +.PARAMETER ResultSize +Specifies the maximum number of results to return. The default value and the maximum value is 1000. To retrieve more than 1000 records you must use the continuation link. +.PARAMETER ContinuationLink +Specifies a variable to save the URL to retrieve additional results. +.EXAMPLE + Get-PCUsage -TenantId 2a14b164-f983-4048-92e1-4f9591b87445 -SubscriptionId b027a4b3-5487-413b-aa48-ec8733c874d6 -StartTime '06-12-2018 00:00:00' -EndTime '06-31-2018 23:59:59' -Granularity hourly -ResultSize 2000 +Return up to 2000 hourly usage records for the specified date range. +.NOTES +#> +function Get-PCUsage { [CmdletBinding()] - param ( [Parameter(Mandatory = $true)][String]$subscriptionid, - [Parameter(Mandatory = $true)][String]$start_time, - [Parameter(Mandatory = $true)][String]$end_time, - [Parameter(Mandatory = $false)][ValidateSet('daily', 'hourly')][String]$granularity = 'daily', - [Parameter(Mandatory = $false)][bool]$show_details = $true, - [Parameter(Mandatory = $false)][ValidateRange(1, 1000)] [int]$size = 1000, - [Parameter(Mandatory = $false)][String]$tenantid = $GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) - - $retObject = Get-PCUsage_implementation -subscriptionid $subscriptionid -start_time $start_time -end_time $end_time -granularity $granularity -show_details $show_details -size $size -tenantid $tenantid -satoken $satoken - - return $retObject.Items -} + param ( + [Parameter(Mandatory = $true)][String]$SubscriptionId, + [Parameter(Mandatory = $true)][String]$StartTime, + [Parameter(Mandatory = $true)][String]$EndTime, + [Parameter(Mandatory = $false)][ValidateSet('daily', 'hourly')][String]$Granularity = 'daily', + [Parameter(Mandatory = $false)][bool]$ShowDetail = $true, + [Parameter(Mandatory = $false)][ValidateRange(1, 100000)][int]$ResultSize = 1000, + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $false)][Parameter(Mandatory = $false, ParameterSetName = 'next')][string]$SaToken = $GlobalToken + ) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) + + if ($ResultSize -ge 1000) { + + $retObject = Get-PCUsage_implementation -SubscriptionId $SubscriptionId -StartTime $startTime -EndTime $endTime -Granularity $granularity -ShowDetail $ShowDetail -ResultSize 1000 -TenantId $TenantId -SaToken $SaToken + $returnItems = $retObject.Items -function Get-PCUsage2 -{ - [CmdletBinding()] - param ( [Parameter(Mandatory = $true, ParameterSetName = 'first')][String]$subscriptionid, - [Parameter(Mandatory = $true, ParameterSetName = 'first')][String]$start_time, - [Parameter(Mandatory = $true, ParameterSetName = 'first')][String]$end_time, - [Parameter(Mandatory = $false, ParameterSetName = 'first')][ValidateSet('daily', 'hourly')][String]$granularity = 'daily', - [Parameter(Mandatory = $false, ParameterSetName = 'first')][bool]$show_details = $true, - [Parameter(Mandatory = $false, ParameterSetName = 'first')][ValidateRange(1, 1000)] [int]$size = 1000, - [Parameter(Mandatory = $false, ParameterSetName = 'first')][String]$tenantid = $GlobalCustomerID, - [Parameter(Mandatory = $false, ParameterSetName = 'first')][Parameter(Mandatory = $false, ParameterSetName = 'next')][string]$satoken = $GlobalToken, - [Parameter(Mandatory = $true, ParameterSetName = 'next')]$continuationLink = $null) - _testTokenContext($satoken) - - switch ($PsCmdlet.ParameterSetName) - { - "first" - { - _testTenantContext ($tenantid) - $retObject = Get-PCUsage_implementation -subscriptionid $subscriptionid -start_time $start_time -end_time $end_time -granularity $granularity -show_details $show_details -size $size -tenantid $tenantid -satoken $satoken + if ($retObject.Count -ge 1000) { + + do { + + $r = Get-PCUsage_implementation -SaToken $SaToken -ContinuationLink $retObject.links + #foreach ($i in $r) + #{ + $returnItems += $r.Items + + #} + #$retObject += $retObject2 + } + until(!($r.links.PsObject.Properties.Name -match 'next')) } - "next" - { - $retObject = Get-PCUsage_implementation -satoken $satoken -continuationLink $continuationLink - } } + else { + + $retObject = Get-PCUsage_implementation -SubscriptionId $SubscriptionId -StartTime $startTime -EndTime $endTime -Granularity $granularity -ShowDetail $ShowDetail -ResultSize $ResultSize -TenantId $TenantId -SaToken $SaToken + $returnItems = $retObject.Items + } + + ## $retObject = Get-PCUsage_implementation -SaToken $SaToken -ContinuationLink $continuationLink - return $retObject + return $returnItems } -function Get-PCUsage_implementation -{ +function Get-PCUsage_implementation { [CmdletBinding()] - param ( [String]$subscriptionid, - [String]$start_time, - [String]$end_time, - [String]$granularity, - [bool]$show_details, - [int]$size, - [String]$tenantid, - [string]$satoken, - $continuationLink) + param ( [String]$SubscriptionId, + [String]$StartTime, + [String]$EndTime, + [String]$Granularity, + [bool]$ShowDetail, + [int]$ResultSize, + [String]$TenantId, + [string]$SaToken, + $ContinuationLink) $obj = @() $urlParts = @("https://api.partnercenter.microsoft.com/v1/") - $headers = @{Authorization = "Bearer $satoken"} - if ($continuationLink -eq $null) - { - try - { - $s_time = get-date $start_time -Format s + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) + + if ($ContinuationLink -eq $null) { + try { + $s_time = get-date $StartTime -Format s } - catch - { - "Start time is not in a valid format. Use '31-12-1999 00:00:00' format" + catch { + "Start time is not in a valid format. Use '01-06-2018 00:00:00' format" } - try - { - $e_time = get-date $end_time -Format s + try { + $e_time = get-date $EndTime -Format s } - catch - { - "End time is not in a valid format. Use '31-12-1999 00:00:00' format" + catch { + "End time is not in a valid format. Use '01-06-2018 23:59:00' format" } - $urlParts += "Customers/{0}/Subscriptions/{1}/Utilizations/azure?start_time={2}Z&end_time={3}Z&show_details={4}&granularity={5}&size={6}" -f $tenantid, $subscriptionid, $s_time, $e_time, $show_details, $granularity, $size + $urlParts += "Customers/{0}/Subscriptions/{1}/Utilizations/azure?start_time={2}Z&end_time={3}Z&show_details={4}&granularity={5}&size={6}" -f $TenantId, $SubscriptionId, $s_time, $e_time, $ShowDetail, $granularity, $ResultSize } - else - { - if (Get-Member -inputobject $continuationLink -name "next" -Membertype Properties) - { + else { + if (Get-Member -InputObject $continuationLink -name "next" -MemberType Properties) { $urlParts += $continuationLink.next.uri - foreach ($i in $continuationLink.next.headers) - { + foreach ($i in $continuationLink.next.headers) { $headers.Add($i.Key, $i.Value) } } - else - { + else { throw "Check the Count or Link properties before trying to retrieve the next set of records" } } @@ -133,134 +151,152 @@ function Get-PCUsage_implementation return $retObject } -function Get-PCSubscriptionMonthlyUsageRecords -{ - [CmdletBinding()] - param ([Parameter(Mandatory = $false)][String]$tenantid = $GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) - - Write-Warning " Get-PCSubscriptionMonthlyUsageRecords is deprecated and will not be available in future releases, use Get-PCSubscriptionMonthlyUsageRecord instead." - - $obj = @() - - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions/usagerecords" -f $tenantid - $headers = @{Authorization = "Bearer $satoken"} - $headers += @{"MS-RequestId" = [Guid]::NewGuid()} - $headers += @{"MS-CorrelationId" = [Guid]::NewGuid()} - - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj += $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "SubscriptionMonthlyUsageRecord") -} +<# +.SYNOPSIS +Returns usage records for the specified tenant. +.DESCRIPTION +The Get-PCSubscriptionMonthlyUsageRecord returns a usage record for the specified tenant +.PARAMETER SaToken +Specified an authentication token you have created with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant id for which to return a usage record +.EXAMPLE +Get-PCSubscriptionMonthlyUsageRecord +.NOTES -# Adding non-plural noun version of cmdlet. Plural version of the cmdlet will be removed in future versions. -function Get-PCSubscriptionMonthlyUsageRecord -{ +#> +function Get-PCSubscriptionMonthlyUsageRecord { [CmdletBinding()] - param ([Parameter(Mandatory = $false)][String]$tenantid = $GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + param ( + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken + ) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions/usagerecords" -f $tenantid - $headers = @{Authorization = "Bearer $satoken"} - $headers += @{"MS-RequestId" = [Guid]::NewGuid()} - $headers += @{"MS-CorrelationId" = [Guid]::NewGuid()} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions/usagerecords" -f $TenantId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "SubscriptionMonthlyUsageRecord") } -function Get-PCAzureResourceMonthlyUsageRecords -{ +<# +.SYNOPSIS +Returns monthly Azure usage for the specified tenant. +.DESCRIPTION +The Get-PCAzureResourceMonthlyUsageRecord cmdlet returns Azure usage for the specified tenant. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.PARAMETER SubscriptionId +Specifies the subscription id for which to return usage. +.EXAMPLE + Get-PCAzureResourceMonthlyUsageRecord +.NOTES +#> +function Get-PCAzureResourceMonthlyUsageRecord { [CmdletBinding()] param ( - [Parameter(Mandatory = $false)][String]$tenantid = $GlobalCustomerID, - [string]$subscriptionid, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) - - Write-Warning " Get-PCAzureResourceMonthlyUsageRecords is deprecated and will not be available in future releases, use Get-PCAzureResourceMonthlyUsageRecord instead." + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [string]$SubscriptionId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken + ) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions/{1}/usagerecords/resources" -f $tenantid, $subscriptionid - $headers = @{Authorization = "Bearer $satoken"} - $headers += @{"MS-RequestId" = [Guid]::NewGuid()} - $headers += @{"MS-CorrelationId" = [Guid]::NewGuid()} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions/{1}/usagerecords/resources" -f $TenantId, $SubscriptionId - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj += $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "AzureResourceMonthlyUsageRecord") -} - -# Adding non-plural noun version of cmdlet. Plural version of the cmdlet will be removed in future versions. -function Get-PCAzureResourceMonthlyUsageRecord -{ - [CmdletBinding()] - param ( - [Parameter(Mandatory = $false)][String]$tenantid = $GlobalCustomerID, - [string]$subscriptionid, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) - - $obj = @() - - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/subscriptions/{1}/usagerecords/resources" -f $tenantid, $subscriptionid - $headers = @{Authorization = "Bearer $satoken"} - $headers += @{"MS-RequestId" = [Guid]::NewGuid()} - $headers += @{"MS-CorrelationId" = [Guid]::NewGuid()} + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "AzureResourceMonthlyUsageRecord") } +<# +.SYNOPSIS +Returns a summary of usage for the specified tenant. +.DESCRIPTION +The Get-PCCustomerUsageSummary cmdlet returns a summary of usage for the specified tenant. +.PARAMETER SaToken +Specifies an authentication token created with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.EXAMPLE + Get-PCCustomerUsageSummary -TenantId 45916f92-e9c3-4ed2-b8c2-d87aa129905f +Get the usage summary for all subscriptions for the specified tenant id. + +.NOTES -function Get-PCCustomerUsageSummary -{ +#> +function Get-PCCustomerUsageSummary { [CmdletBinding()] param( - [Parameter(Mandatory = $false)][String]$tenantid = $GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken + + ) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/usagesummary" -f $tenantid - $headers = @{Authorization = "Bearer $satoken"} - $headers += @{"MS-RequestId" = [Guid]::NewGuid()} - $headers += @{"MS-CorrelationId" = [Guid]::NewGuid()} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/usagesummary" -f $TenantId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "CustomerUsageSummary") } -function Get-PCCustomerServiceCostSummary -{ +<# +.SYNOPSIS +Returns a cost summary for the specified billing period. +.DESCRIPTION +The Get-PCCustomerServiceCostSummary returns a cost summary for the specified billing period +.PARAMETER SaToken +Specifies an authentication token created with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.PARAMETER BillingPeriod +Specifies the billing period. The only valid value is MostRecent. Current and None may be added in the future. +.EXAMPLE +Get-PCCustomerServiceCostSummary +.NOTES +#> +function Get-PCCustomerServiceCostSummary { [CmdletBinding()] param ( [Parameter(Mandatory = $true)][ValidateSet("MostRecent")][String]$BillingPeriod, #toAdd "Current","none" as soon as they're supported - [Parameter(Mandatory = $false)][String]$tenantid = $GlobalCustomerID, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/servicecosts/{1}" -f $tenantid, $BillingPeriod - $headers = @{Authorization = "Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/servicecosts/{1}" -f $TenantId, $BillingPeriod + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json diff --git a/PartnerCenterModule/PartnerCenterUser.psm1 b/PartnerCenterModule/PartnerCenterUser.psm1 index 7531b42..429f046 100644 --- a/PartnerCenterModule/PartnerCenterUser.psm1 +++ b/PartnerCenterModule/PartnerCenterUser.psm1 @@ -1,6 +1,6 @@ Set-StrictMode -Version latest <# - © 2017 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. + © 2018 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. This sample code is provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, @@ -12,60 +12,102 @@ $here = Split-Path -Parent $MyInvocation.MyCommand.Path . "$here\commons.ps1" -function Get-PCCustomerUser -{ +<# +.SYNOPSIS +Returns either all users for a customer tenant or the specified customer user. +.DESCRIPTION +The Get-PCCustomerUser cmdlet returns either all users or a specified user from the tenant. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.PARAMETER UserId +Specifies the user id. +.PARAMETER Licenses +Specifies whether to return the licenses assigned to the specified user. +.PARAMETER Deleted +Specifies whether to return deleted users. +.PARAMETER ResultSize +Specifies the maximum number of results to return. The default value is 200. +.EXAMPLE +Get all users for the specified tenant. +PS C:\>Get-PCCustomerUser -TenantId 45916f92-e9c3-4ed2-b8c2-d87aa129905f + +.EXAMPLE +Get a customer user +PS C:\>$user = Get-PCCustomerUser -TenantId 45916f92-e9c3-4ed2-b8c2-d87aa129905f -UserId 'e2e56b09-aac5-4685-947d-29e735ee7ed7' + +.EXAMPLE +Get a list of user assigned licenses for the specified user id. +PS C:\>Get-PCCustomerUser -TenantId 45916f92-e9c3-4ed2-b8c2-d87aa129905f -UserId 'e2e56b09-aac5-4685-947d-29e735ee7ed7' -Licenses + +.EXAMPLE +Get a list of deleted users for the tenant +PS C:\>Get-PCCustomerUser -TenantId 45916f92-e9c3-4ed2-b8c2-d87aa129905f -Deleted + +.NOTES +#> +function Get-PCCustomerUser { [CmdletBinding()] Param( - [Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(ParameterSetName='all', Mandatory = $false)][switch]$all, - [Parameter(ParameterSetName='activeuser', Mandatory = $false)][String]$userid, - [Parameter(ParameterSetName='activeuser', Mandatory = $false)][switch]$licenses, - [Parameter(ParameterSetName='deleteduser', Mandatory = $false)][switch]$deleted, - [Parameter(ParameterSetName='deleteduser', Mandatory = $false)][int]$size = 200, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken + [Parameter(ParameterSetName = 'activeUser', Mandatory = $false)] + [parameter(ParameterSetName = "deletedUser")] + [parameter(ParameterSetName = "all")] + [string]$TenantId = $GlobalCustomerId, + [Parameter(ParameterSetName = 'activeUser', Mandatory = $true)][string]$UserId, + [Parameter(ParameterSetName = 'activeUser', Mandatory = $false)][switch]$Licenses, + [Parameter(ParameterSetName = 'deletedUser', Mandatory = $true)][switch]$Deleted, + [Parameter(ParameterSetName = 'deletedUser', Mandatory = $false)][int]$ResultSize = 200, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken ) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) - function Private:Get-CustomerAllUserInner ($satoken, $tenantid) - { + function Private:Get-CustomerAllUserInner ($SaToken, $TenantId) { $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users" -f $TenantId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "CustomerUser") } - function Private:Get-CustomerUserInner ($satoken, $tenantid, $userid, $licenses) - { - $obj = @() - if ($userid) - { - if ($licenses) - { - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users/{1}/licenses" -f $tenantid, $userid - $headers = @{Authorization="Bearer $satoken"} + function Private:Get-CustomerUserInner ($SaToken, $TenantId, $UserId, $Licenses) { + $obj = @() + if ($UserId) { + if ($Licenses) { + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users/{1}/licenses" -f $TenantId, $UserId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "CustomerUserLicenses") } - else - { - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users/{1}" -f $tenantid, $userid - $headers = @{Authorization="Bearer $satoken"} + else { + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users/{1}" -f $TenantId, $UserId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "CustomerUser") } } - else - { - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} + else { + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users" -f $TenantId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json @@ -73,58 +115,88 @@ function Get-PCCustomerUser } } - function Private:Get-DeletedUsersInner ($satoken, $tenantid, $size) - { - $obj = @() + function Private:Get-DeletedUsersInner ($SaToken, $TenantId, $ResultSize) { + $obj = @() $filter = '{"Field":"UserStatus","Value":"Inactive","Operator":"equals"}' [Reflection.Assembly]::LoadWithPartialName("System.Web") | Out-Null $Encode = [System.Web.HttpUtility]::UrlEncode($filter) - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users?size={1}&filter={2}" -f $tenantid,$size,$Encode - $headers = @{Authorization="Bearer $satoken"} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users?size={1}&filter={2}" -f $TenantId, $ResultSize, $Encode + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "CustomerUser") } - switch ($PsCmdlet.ParameterSetName) - { - "activeuser" {$res = Get-CustomerUserInner -satoken $satoken -tenantid $tenantid -user $userid -licenses $licenses - return $res} - - "deleteduser"{$res = Get-DeletedUsersInner -satoken $satoken -tenantid $tenantid -size $size - return $res} - - "all" {$res = Get-CustomerAllUserInner -satoken $satoken -tenantid $tenantid - return $res} - + if ($PsCmdlet.ParameterSetName -eq "activeUser") { + $res = Get-CustomerUserInner -SaToken $SaToken -TenantId $TenantId -user $UserId -licenses $Licenses + return $res + } + elseif ($PsCmdlet.ParameterSetName -eq "deletedUser") { + $res = Get-DeletedUsersInner -SaToken $SaToken -TenantId $TenantId -ResultSize $ResultSize + return $res + } + else { + $res = Get-CustomerAllUserInner -SaToken $SaToken -TenantId $TenantId + return $res } + } -function New-PCCustomerUser -{ +<# +.SYNOPSIS +Creates a new user in the specified customer Azure Active Directory tenant. +.DESCRIPTION +The New-PCCustomerUser cmdlet creates a new user in the tenant Azure Active Directory. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.PARAMETER UsageLocation +Specifies the location the user will be used. +.PARAMETER UserPrincipalName +Specifies the user name including the domain for the new user. +.PARAMETER FirstName +Specifies the first name of the new users. +.PARAMETER LastName +Specifies the last name for the new user. +.PARAMETER DisplayName +Specifies the display name for the new user. +.PARAMETER Password +Specifies a secure string to be assigned as the password for the new user. +.PARAMETER ForceChangePassword +Specifies whether the new user must change their password during the first logon. +.EXAMPLE + New-PCCustomerUser -TenantId 45916f92-e9c3-4ed2-b8c2-d87aa129905f -UsageLocation US -userPrincipalName 'joe@contoso.onmicrosoft.com' -FirstName 'Joe' -LastName 'Smith' -DisplayName 'Joe Smith' -ForceChangePassword $true -Password $PasswordSecure +.NOTES +#> +function New-PCCustomerUser { [CmdletBinding()] - param ([Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $true)][string]$usageLocation, - [Parameter(Mandatory = $true)][string]$userPrincipalName, - [Parameter(Mandatory = $true)][string]$firstName, - [Parameter(Mandatory = $true)][string]$lastName, - [Parameter(Mandatory = $true)][string]$displayName, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][SecureString]$password, - [Parameter(ParameterSetName='AllDetails',Mandatory = $true)][bool]$forceChangePassword, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + param ([Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $true)][string]$UsageLocation, + [Parameter(Mandatory = $true)][string]$UserPrincipalName, + [Parameter(Mandatory = $true)][string]$FirstName, + [Parameter(Mandatory = $true)][string]$LastName, + [Parameter(Mandatory = $true)][string]$DisplayName, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][SecureString]$Password, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $true)][bool]$ForceChangePassword, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users" -f $tenantid - $headers = @{Authorization="Bearer $satoken"} - $headers += @{"MS-RequestId"=[Guid]::NewGuid()} - $headers += @{"MS-CorrelationId"=[Guid]::NewGuid()} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users" -f $TenantId - $user = [CustomerUser]::new($usageLocation,$userPrincipalName,$firstName,$lastName,$displayName,$password,$forceChangePassword) + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) + + $user = [CustomerUser]::new($UsageLocation, $UserPrincipalName, $FirstName, $LastName, $DisplayName, $Password, $ForceChangePassword) $body = $user | ConvertTo-Json -Depth 100 $utf8body = [System.Text.Encoding]::UTF8.GetBytes($body) @@ -133,40 +205,97 @@ function New-PCCustomerUser return (_formatResult -obj $obj -type "CustomerUser") } -function Set-PCCustomerUser -{ +<# +.SYNOPSIS +Updates the specified customer user account. +.DESCRIPTION +The Set-PCustomerUser cmdlet modifies a customer user account. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.PARAMETER UserId +Specifies the user id to modify. +.PARAMETER FirstName +Specifies the modified first name for the user. +.PARAMETER LastName +Specifies the modified last name for the user. +.PARAMETER userPrincipalName +Specifies a modified user name including the domain name. +.PARAMETER Location +Specifies a modified location for the user. +.PARAMETER Password +Specifies an updated password as a secure string to set for the user. +.PARAMETER forceChangePassword +Specifies whether the user will need to change their password the next time they sign in. +.EXAMPLE +Update a customer user's last name + +Find the tenant information about the customer named Wingtip Toys + + $customer = Get-PCCustomer | Where-Object {$_.CompanyProfile.CompanyName -eq 'Wingtip Toys'} + +Find the user with the joan@wingtiptoyscsptest.onmicrosoft.com + + $user = Get-PCCustomerUser -TenantId $customer.id | Where-Object {$_.userPrincipalName -eq 'joan@wingtiptoyscsptest.onmicrosoft.com'} + +Modify the user's last name + + Set-PCCustomerUser -TenantId $customer.id -userId $user.id -LastName 'Sullivan' + +.EXAMPLE +Reset a customer user's password + +Find the tenant information about the customer named Wingtip Toys + + $customer = Get-PCCustomer | Where-Object {$_.CompanyProfile.CompanyName -eq 'Wingtip Toys'} + +Find the user with the joan@wingtiptoyscsptest.onmicrosoft.com + + $user = Get-PCCustomerUser -TenantId $customer.id | Where-Object {$_.userPrincipalName -eq 'joan@wingtiptoyscsptest.onmicrosoft.com'} + +Set the password for the user account and require the user to change the password during the next sign on. + + $password = '<password>' + $passwordSecure = $password | ConvertTo-SecureString -AsPlainText -Force + Set-PCCustomerUser -TenantId $customer.id -UserId $user.Id -Password $passwordSecure -ForceChangePassword $true + +.NOTES +#> +function Set-PCCustomerUser { [CmdletBinding()] param ( - [Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $true,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)][PSCustomObject]$user, - [Parameter(Mandatory = $false)][string]$firstName, - [Parameter(Mandatory = $false)][string]$lastName, - [Parameter(Mandatory = $false)][string]$userPrincipalName, - [Parameter(Mandatory = $false)][string]$location, - [Parameter(ParameterSetName='AllDetails',Mandatory = $false)][SecureString]$password, - [Parameter(ParameterSetName='AllDetails',Mandatory = $false)][bool]$forceChangePassword, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $true)][String]$UserId, + [Parameter(Mandatory = $false)][string]$FirstName, + [Parameter(Mandatory = $false)][string]$LastName, + [Parameter(Mandatory = $false)][string]$UserPrincipalName, + [Parameter(Mandatory = $false)][string]$Location, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $false)][SecureString]$Password, + [Parameter(ParameterSetName = 'AllDetails', Mandatory = $false)][bool]$ForceChangePassword, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $actualUser = Get-PCCustomerUser -tenantid $tenantid -userid $user.Id -satoken $satoken + $actualUser = Get-PCCustomerUser -TenantId $TenantId -UserId $UserId -SaToken $SaToken - if($firstName) {$actualUser.firstName = $firstName} - if($lastName) {$actualUser.lastName = $lastName} - if($userPrincipalName) {$actualUser.userPrincipalName = $userPrincipalName} - if($location) {$actualUser.location = $location} - if($password -or $forceChangePassword) - { - $passwordProfile = [CustomerUserPasswordProfile]::new($password, $forceChangePassword) - $actualUser | Add-Member -type NoteProperty -name passwordProfile -Value $passwordProfile + if ($FirstName) {$actualUser.firstName = $FirstName} + if ($LastName) {$actualUser.lastName = $LastName} + if ($UserPrincipalName) {$actualUser.userPrincipalName = $UserPrincipalName} + if ($Location) {$actualUser.location = $Location} + if ($Password -or $ForceChangePassword) { + $passwordProfile = [CustomerUserPasswordProfile]::new($Password, $ForceChangePassword) + $actualUser | Add-Member -type NoteProperty -name PasswordProfile -Value $passwordProfile } - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users/{1}" -f $tenantid, $user.id - $headers = @{Authorization="Bearer $satoken"} - $headers += @{"MS-RequestId"=[Guid]::NewGuid()} - $headers += @{"MS-CorrelationId"=[Guid]::NewGuid()} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users/{1}" -f $TenantId, $UserId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) + $body = $actualUser | ConvertTo-Json -Depth 100 $utf8body = [System.Text.Encoding]::UTF8.GetBytes($body) @@ -175,22 +304,46 @@ function Set-PCCustomerUser return (_formatResult -obj $obj -type "CustomerUser") } -function Restore-PCCustomerUser -{ +<# +.SYNOPSIS +Restores the specified customer user. +.DESCRIPTION +The Restore-PCCustomerUser cmdlet restore a deleted customer user. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.PARAMETER UserId +Specifies the user id to restore. +.EXAMPLE +Find the deleted account + + $user = Get-PCCustomerUser -Deleted -TenantId db8ea5b4-a69b-45f3-abd3-dca19e87c536 | Where-Object {$_.userPrincipalName -eq 'John@wingtiptoyscsptest.onmicrosoft.com'} + +Restore the deleted user account + + Restore-PCCustomerUser -TenantId $customer.id -UserId $User.Id + +.NOTES + +#> +function Restore-PCCustomerUser { [CmdletBinding()] param ( - [Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $true,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)][PSCustomObject]$user, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $true)][string]$UserId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users/{1}" -f $tenantid, $user.id - $headers = @{Authorization="Bearer $satoken"} - $headers += @{"MS-RequestId"=[Guid]::NewGuid()} - $headers += @{"MS-CorrelationId"=[Guid]::NewGuid()} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users/{1}" -f $TenantId, $UserId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) + $body = "{ ""State"": ""active"", ""Attributes"": { ""ObjectType"": ""CustomerUser"" } }" $utf8body = [System.Text.Encoding]::UTF8.GetBytes($body) @@ -199,62 +352,95 @@ function Restore-PCCustomerUser return (_formatResult -obj $obj -type "CustomerUser") } -function Remove-PCCustomerUser -{ +<# +.SYNOPSIS +Deletes a user from the customer's tenant. +.DESCRIPTION +The Remove-PCCustomerUser cmdlet removes the specified user from the customer tenant. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant used for scoping this cmdlet. +.PARAMETER UserId +Specifies the user id to remove. +.EXAMPLE +Retrieve the user id for the customer user you want to delete. + + $user = Get-PCCustomerUser -TenantId db8ea5b4-a69b-45f3-abd3-dca19e87c536 | Where-Object {$_.userPrincipalName -eq 'John@wingtiptoyscsptest.onmicrosoft.com'} + +Delete the specified customer user + + Remove-PCCustomerUser -TenantId $customer.id -UserId $user.id + +.NOTES +#> +function Remove-PCCustomerUser { [CmdletBinding()] - param ( [Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $true,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)][PSCustomObject]$user, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + param ( [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $true)][String]$UserId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users/{1}" -f $tenantid, $user.id - $headers = @{Authorization="Bearer $satoken"} - $headers += @{"MS-RequestId"=[Guid]::NewGuid()} - $headers += @{"MS-CorrelationId"=[Guid]::NewGuid()} + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users/{1}" -f $TenantId, $UserId + + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "DELETE" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json return (_formatResult -obj $obj -type "CustomerUser") } -function Get-PCCustomerUserRoles -{ +<# +.SYNOPSIS +Returns the a list of roles for a specified tenant or user. +.DESCRIPTION +The Get-PCCustomerUserRoles cmdlet returns a list of roles for a specified tenant or user. +.PARAMETER SaToken +Specifies an authentication token with your Partner Center credentials. +.PARAMETER TenantId +Specifies the tenant is used for scoping this cmdlet. +.PARAMETER UserId +Specifies the user id for which to retrieve the roles. +.EXAMPLE +Get a list of all roles for the specified tenant. + +Get-PCCustomerUserRole -TenantId a7bc20f7-6041-4165-8bef-59d0e7e8d67b + +.EXAMPLE +Get a list of all the roles for the specified tenant id and user id. + +Get-PCCustomerUserRole -TenantId a7bc20f7-6041-4165-8bef-59d0e7e8d67b -UserId e2e56b09-aac5-4685-947d-29e735ee7ed7 + +.NOTES +#> +function Get-PCCustomerUserRole { [CmdletBinding()] - param ( [Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $true,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)][PSCustomObject]$user, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) - - Write-Warning " Get-PCCustomerUserRoles is deprecated and will not be available in future releases, use Get-PCCustomerUserRole instead." + param ( [Parameter(Mandatory = $false)][String]$TenantId = $GlobalCustomerId, + [Parameter(Mandatory = $false)][string]$UserId, + [Parameter(Mandatory = $false)][string]$SaToken = $GlobalToken) + _testTokenContext($SaToken) + _testTenantContext ($TenantId) $obj = @() - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users/{1}/directoryroles" -f $tenantid, $user.id - $headers = @{Authorization="Bearer $satoken"} - - $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose - $obj += $response.Substring(1) | ConvertFrom-Json - return (_formatResult -obj $obj -type "CustomerUserDirectoryRoles") -} + if ($TenantId) { + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/directoryroles" -f $TenantId, $UserId + + if ($UserId) { -# Adding in non-plural noun versions of the cmdlets -function Get-PCCustomerUserRole -{ - [CmdletBinding()] - param ( [Parameter(Mandatory = $false)][String]$tenantid=$GlobalCustomerID, - [Parameter(Mandatory = $true,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)][PSCustomObject]$user, - [Parameter(Mandatory = $false)][string]$satoken = $GlobalToken) - _testTokenContext($satoken) - _testTenantContext ($tenantid) + $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users/{1}/directoryroles" -f $TenantId, $UserId + } - $obj = @() + } - $url = "https://api.partnercenter.microsoft.com/v1/customers/{0}/users/{1}/directoryroles" -f $tenantid, $user.id - $headers = @{Authorization="Bearer $satoken"} + $headers = New-Object 'System.Collections.Generic.Dictionary[[string],[string]]' + $headers.Add("Authorization", "Bearer $SaToken") + $headers.Add("MS-PartnerCenter-Application", $ApplicationName) $response = Invoke-RestMethod -Uri $url -Headers $headers -ContentType "application/json" -Method "GET" #-Debug -Verbose $obj += $response.Substring(1) | ConvertFrom-Json diff --git a/PartnerCenterModule/commons.ps1 b/PartnerCenterModule/commons.ps1 index 37c41f4..57c9892 100644 --- a/PartnerCenterModule/commons.ps1 +++ b/PartnerCenterModule/commons.ps1 @@ -1,5 +1,5 @@ <# - © 2017 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. + © 2018 Microsoft Corporation. All rights reserved. This sample code is not supported under any Microsoft standard support program or service. This sample code is provided AS IS without warranty of any kind. Microsoft disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, @@ -8,6 +8,9 @@ sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages. #> +# This variable is used in other cmdlets to identify the REST client. +$ApplicationName = "Partner Center PowerShell Module v0.10.0.0" + function _applyTypes { param($item,$type) $item.PSObject.TypeNames.Insert(0, $type) @@ -30,19 +33,19 @@ function _formatResult { } } -function _testTenantContext($tenantID) +function _testTenantContext($TenantId) { - if ($tenantid.Length -lt 1) + if ($TenantId.Length -lt 1) { - throw ">>> Use Select-PCCustomer function to select a specific tenant or use -tenantId parameter<<<" + throw ">>> Use Select-PCCustomer to select a specific tenant or use -TenantId parameter<<<" } } -function _testTokenContext($satoken) +function _testTokenContext($SaToken) { - if ($satoken.Length -lt 1) + if ($SaToken.Length -lt 1) { - throw ">>> Use Add-PCAuthentication function to login to partnercenter or use -saToken parameter<<<" + throw ">>> Use Add-PCAuthentication to login to Partner Center or use -SaToken parameter<<<" } } @@ -53,14 +56,13 @@ function _unsecureString return $tmp_cred.GetNetworkCredential().Password } -#Setting Global Token function Get-SAToken { [CmdletBinding()] - param ($aadtoken,[bool]$global) + param ($AadToken,[bool]$global) $url = "https://api.partnercenter.microsoft.com/generatetoken" $body = "grant_type=jwt_token" - $headers=@{Authorization="Bearer $aadtoken"} + $headers=@{Authorization="Bearer $AadToken"} $response = Invoke-RestMethod -Uri $url -ContentType "application/x-www-form-urlencoded" -Headers $headers -Body $body -method "POST" #-Debug -Verbose @@ -69,7 +71,6 @@ function Get-SAToken Set-Variable -Name "GlobalToken" -Value $response.access_token -Scope Global } - return $response.access_token } diff --git a/README.md b/README.md index fc61eb5..702634c 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,13 @@ using module PartnerCenterModule Just like with AzureRM powershell module, the first step to start using it is to provide authentication. In Partner Center PowerShell Module you use [Add-PCAuthentication](./CmdletHelp/Add-PCAuthentication.md) cmdlet to set your CSP account authentication context. -#### Set user authentication #### +** Some cmdlets require App+User authentication to function correctly.** + +#### Set App+User authentication #### ```powershell $cred = Get-Credential '<username@domain>' -Add-PCAuthentication -cspappID '<native app id GUID>' -cspDomain '<csp partner domain>' -credential $cred +Add-PCAuthentication -CspAppId '<native app id GUID>' -CspDomain '<csp partner domain>' -Credential $cred ``` or @@ -45,7 +47,7 @@ or $clientSecret = '<key code secret>' $clientSecretSecure = $clientSecret | ConvertTo-SecureString -AsPlainText -Force -Add-PCAuthentication -cspappID '<web app id GUID>' -cspDomain '<csp partner domain>' -cspClientSecret $clientSecretSecure +Add-PCAuthentication -CspAppId '<web app id GUID>' -CspDomain '<csp partner domain>' -CspClientSecret $clientSecretSecure ``` You can obtain the Web App ID and the Client Secret from either Partner Center UI or Azure Active Directory @@ -119,7 +121,7 @@ After completing these steps you are ready to start using the cmdlets for the sc | | | | | **Place orders** | | | | Get offers from the catalog | | | -| | [Get a list of offer categories by country and locale](https://msdn.microsoft.com/en-us/library/partnercenter/mt634689.aspx) | [Get-PCOfferCategoriesByMarket](./CmdletHelp/Get-PCOfferCategoriesByMarket.md) | +| | [Get a list of offer categories by Country and locale](https://msdn.microsoft.com/en-us/library/partnercenter/mt634689.aspx) | [Get-PCOfferCategoriesByMarket](./CmdletHelp/Get-PCOfferCategoriesByMarket.md) | | | [Get a list of offers for a market](https://msdn.microsoft.com/en-us/library/partnercenter/mt683488.aspx) | [Get-PCOffer](./CmdletHelp/Get-PCOffer.md) | | | [Get an offer by ID](https://msdn.microsoft.com/en-us/library/partnercenter/mt634678.aspx) | [Get-PCOffer](./CmdletHelp/Get-PCOffer.md) | | | [Get add-ons for an offer ID](https://msdn.microsoft.com/en-us/library/partnercenter/mt634669.aspx) | [Get-PCOffer](./CmdletHelp/Get-PCOffer.md) | diff --git a/tests/Reset-PCTests.ps1 b/tests/Reset-PCTests.ps1 new file mode 100644 index 0000000..6132d68 --- /dev/null +++ b/tests/Reset-PCTests.ps1 @@ -0,0 +1,54 @@ +<# +.SYNOPSIS +Removes and readds the PartnerCenterModule for testing + +.PARAMETER webAppAuth +Authenticates using the Web App authentication information provided. + +.PARAMETER appUserAuth +Authenticates using App+User authentication information provided. + +.PARAMETER credentials +This is a credential object created using Get-Credential. + +.EXAMPLE +.\Reset-PCTest.ps1 -AppUserAuth -credentials $creds -CspDomain ContosoCsp.OnMicrosoft.com -CspAppId $CspApppId + +Resets the test using AppUser Authentication. +.NOTES +You need to have a authentication credential already established before running this cmdlet. + +#> + +[CmdletBinding()] +Param( + [Parameter(Mandatory = $false)][switch]$WebAppAuth, + [Parameter(Mandatory = $false)][switch]$AppUserAuth, + [Parameter(Mandatory = $true)][PSCredential]$Credentials, + [Parameter(Mandatory = $true)][string]$CspDomain, + [Parameter(Mandatory = $false)][string]$CspClientSecret, + [Parameter(Mandatory = $false)][string]$CspAppId, + [Parameter(Mandatory = $false)][string]$CspWebAppId +) + +# If the module is already imported, remove it. +$x = Get-Module -Name PartnerCenterModule +if ($x -ne $null) { + Write-Output " Removing current PartnerCenterModule version." + Remove-Module -Name PartnerCenterModule -Force +} + +# Import the latest version of the module +Write-Output " Adding in local Partner Center Module for testing" +Import-Module C:\github\Partnercenterpowershellmodule\PartnerCenterModule\PartnerCenterModule.psd1 -Force + +if ($WebAppAuth) { + # App Auth + Add-PCAuthentication -cspAppId $cspWebAppId -cspDomain $cspDomain -cspClientSecret $cspClientSecret -Verbose +} +elseif ($AppUserAuth) { + # App+User Auth + Add-PCAuthentication -cspAppId $cspAppId -cspDomain $cspDomain -credential $credentials -Verbose +} + + diff --git a/tests/Test-PCCmdlets.ps1 b/tests/Test-PCCmdlets.ps1 new file mode 100644 index 0000000..e998bfa --- /dev/null +++ b/tests/Test-PCCmdlets.ps1 @@ -0,0 +1,148 @@ +<# +.SYNOPSIS +Tests all of the cmdlets in the PartnerCenterModule. + +.DESCRIPTION +This will test all of the cmdlets in the module. + +.PARAMETER saToken +Specifies an authentication token with your Partner Center credentials. + +.EXAMPLE +Return a list of assigned licenses for the partner. + +Test-PCCmdlets.ps1 + +.NOTES +You need to have a authentication credential already established before running this cmdlet. + +#> + +<#[CmdletBinding()] + Param( + [Parameter(Mandatory = $false)][Securestring]$credentials, + [Parameter(Mandatory = $false)][string]$cspDomain, + [Parameter(Mandatory = $false)][Securestring]$cspClientSecret, + [Parameter(Mandatory = $false)][string]$cspAppId, + [Parameter(Mandatory = $false)][string]$cspWebAppId + ) +#> + +## Get Verbs +# Get-PCCustomerTests + +Get-PCCustomer -Verbose | Format-Table -AutoSize +Get-PCCustomer -all -Verbose | Format-Table -AutoSize + +$tenant = Get-PCCustomer | Select-Object -Last 1 +Get-PCCustomer -tenantid $tenant.id -Verbose | Format-Table -AutoSize + +Get-PCCustomer -startswith p -ResultSize 2 -Verbose + +# Get-PCAddressRulesByMarket +Get-PCAddressRulesByMarket -CountryId US -Verbose + +# Test an invalid country code +Get-PCAddressRulesByMarket -countryid ZZZ -Verbose + +# Get-PCAuditRecord +Get-PCAuditRecord -startDate 2018-05-10 -Verbose + +#Get-PCAzureRateCard +Get-PCAzureRateCard -Currency USD -Region US -Verbose + +Get-PCAzureResourceMonthlyUsageRecord +Get-PCBillingProfile + +Get-PCCustomerBillingProfile +Get-PCCustomerCompanyProfile +Get-PCCustomerLicenseDeployment +Get-PCCustomerLicenseUsage +Get-PCCustomerServiceCostSummary +Get-PCCustomerUsageSummary +Get-PCCustomerUser +Get-PCCustomerUserRole +Get-PCCustomerRoleMember +Get-PCCustomerRole +Get-PCCustomerRelationship +Get-PCDomainAvailability +Get-PCInvoice +Get-PCInvoiceLineItem +Get-PCLegalBusinessProfile +Get-PCLicenseDeployment +Get-PCLicenseUsage +Get-PCManagedService +Get-PCMpnProfile +Get-PCOffer +Get-PCOfferCategoriesByMarket +Get-PCOrder +Get-PCOrganizationProfile +Get-PCSaToken +Get-PCSpendingBudget +Get-PCSR +Get-PCSRTopic +Get-PCSubscribedSKU +Get-PCSubscription +Get-PCSupportProfile +Get-PCUsage +Get-PCUsage2 +Get-PCManagedServices +Get-PCSRTopics +Get-PCIndirectReseller +Get-PCResellerCustomer + +# Deprecated and no longer tested Get- cmdlets +<# +Get-PCCustomerLicensesDeployment +Get-PCCustomerLicensesUsage +Get-PCInvoiceLineItems +Get-PCResellerCustomers +Get-PCAzureResourceMonthlyUsageRecords +Get-PCCustomerRelationships +Get-PCIndirectResellers +Get-PCLicensesUsage +Get-PCLicensesDeployment +Get-PCAuditRecords +Get-PCSubscribedSKUs +#> + +# This should be used as part of other cmdlets. +#Select-PCCustomer + +# Add tests for these only in the integration sandbox +<# +New-PCAddress + +New-PCCustomerBillingProfile +New-PCCustomerCompanyProfile +New-PCCustomerDefaultAddress + +New-PCOrder +New-PCOrderLineItem +New-PCRelationshipRequest +New-PCSaToken +New-PCSR + +New-PCCustomer +Remove-PCCustomer + +New-PCCustomerUser +Remove-PCCustomerUser + +Add-PCCustomerRoleMember +Remove-PCCustomerRoleMember + +Restore-PCCustomerUser + +Set-PCBillingProfile +Set-PCCustomerBillingProfile +Set-PCCustomerUser +Set-PCLegalBusinessProfile +Set-PCOrganizationProfile +Set-PCSpendingBudget +Set-PCSR +Set-PCSubscription +Set-PCSupportProfile + +Test-PCAddress +#> \ No newline at end of file