Skip to content

mtwelve/Partner-Center-PowerShell

 
 

Repository files navigation

Microsoft Partner Center PowerShell

Build status

PartnerCenter GitHub issues GitHub pull-requests

This repository contains a set of PowerShell commands for administrators and developers to manage Cloud Solution Provider program resources.

Installation

Run the following command in an elevated PowerShell session to install the Partner Center module:

Install-Module -Name PartnerCenter

If you have an earlier version of the Partner Center PowerShell modules installed from the PowerShell Gallery and would like to update to the latest version, run the following commands from an elevated PowerShell session.

Note: Update-Module installs the new version, however, it does not remove the old version.

# Install the latest version of the Partner Center PowerShell module
Update-Module -Name PartnerCenter

Usage

Connecting to Partner Center

To connect to Partner Center, use the Connect-PartnerCenter command.

Service Principal

The following example demonstrates how to connect using a service principal. Using this approach will leverage the app only authentication flow. It is important to note that not all Partner Center operations support this type of authentication. If you have not already created an Azure AD application then please follow the steps documented in the Web App section below.

# Service principal login
$appId = '<Web-AAD-AppId-for-PartnerCenter>'
$appSecret = '<Web-AAD-AppSecret>' | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential $appId $appSecret

Connect-PartnerCenter -Credential $credential -ServicePrincipal -TenantId '<TenantId>

User Credentials

The following examples demonstrate how to connect using user credentials. Using this approach will leverage the app + user authentication flow. If you have not already configured an Azure AD application for use with this command then please see the steps documented in the Native App section below.

# Interactive login - a dialog box will appear for you to provide your Partner Center credentials
Connect-PartnerCenter -ApplicationId '<Native-AAD-AppId-for-PartnerCenter>'

# Non-interactive login
$PSCredential = Get-Credential
Connect-PartnerCenter -ApplicationId '<Native-AAD-AppId-for-PartnerCenter>' -Credential $PSCredential

Access Token

The following example demonstrates how to connect using an access token. It is important to note that this type of authentication can leverage either the app only or app + user authentication flows. The example below shows how you can obtain an access token using the app only authentication flow.

$appId = '<AAD-AppId-for-PartnerCenter>'
$appSecret = '<AAD-AppSecret>' | ConvertTo-SecureString -AsPlainText -Force
$PSCredential = New-Object System.Management.Automation.PSCredential $appId $appSecret

$token = New-PartnerAccessToken -Credential $PSCredential -ServicePrincipal -TenantId '<TenantId>'

Connect-PartnerCenter -AccessToken $token.AccessToken -AccessTokenExpiresOn $token.ExpiresOn -ApplicationId '<AAD-AppId-for-PartnerCenter>' -TenantId '<TenantId>'

Sovereign Cloud

To log into a specific cloud (ChinaCloud, GlobalCloud, GermanCloud, USGovernment), use the Environment parameter:

# Log into a specific cloud - in this case, the German cloud
Connect-PartnerCenter -Environment GermanCloud

Discovering Commands

Use the Get-Command cmdlet to discover cmdlets within a specific module, or cmdlets that follow a specific search pattern:

# View all cmdlets in the Partner Center module
Get-Command -Module PartnerCenter

# View all cmdlets that contain "Customer" in the PartnerCenter module
Get-Command -Module PartnerCenter -Name "*Customer*"

Cmdlet help and examples

To view the cmdlet help content, use the Get-Help cmdlet:

# View the basic help content for Get-PartnerCustomer
Get-Help -Name Get-PartnerCustomer

# View the examples for Get-PartnerCustomer
Get-Help -Name Get-PartnerCustomer -Examples

# View the full help content for Get-PartnerCustomer
Get-Help -Name Get-PartnerCustomer -Full

Configuring Azure AD Application

Native App

  1. Sign in to the Partner Center using credentials that have Admin Agent and Global Admin privileges
  2. Click on Dashboard at the top of the page, then click on the cog icon in the upper right, and then click the Partner settings.
  3. Add a new native application if one does not exist already.
  4. Sign in to the Azure management portal using the same credentials from step 1.
  5. Click on the Azure Active Directory icon in the toolbar.
  6. Click App registrations -> Select All apps from the drop down -> Click on the application created in step 3.
  7. Click Settings and then click Redirect URIs
  8. Add urn:ietf:wg:oauth:2.0:oob as one of the available Redirect URIs. Be sure to click the Save button to ensure the changes are saved.

Web App

  1. Sign in to the Partner Center using credentials that have Admin Agent and Global Admin privileges
  2. Click on Dashboard at the top of the page, then click on the cog icon in the upper right, and then click the Partner settings.
  3. Add a new web application if one does not exist already.

About

PowerShell module for managing Partner Center resources.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 95.0%
  • PowerShell 5.0%