Introducing the MSCommerce PowerShell module

Microsoft’s Message Center Major Change Update Notification – (MC245825)

On March 23rd Microsoft added two new products to the self-service purchasing feature in M365. These are:

  1. Power BI Premium per user
  2. Power Automate per user plan with attended RPA

As administrators you probably want to limit these capabilities seeing that it could set you back $60 for both products per month.

You can now do this on a per-product basis via the MSCommerce PowerShell module.

The module includes a PolicyID parameter value for AllowSelfServicePurchase that lets you control whether users in your organization can make self-service purchases.

You can use the MSCommerce PowerShell module to:

  • View the default state of the AllowSelfServicePurchase parameter value — whether it’s enabled or disabled
  • View a list of applicable products and whether self-service purchase is enabled or disabled
  • View or modify the current setting for a specific product to either enable or disable it

Requirements

To use the MSCommerce PowerShell module, you need:

  • A Windows 10 device
  • Administrator permission for the device
  • Global or Billing Admin role for your tenant

Install the MSCommerce PowerShell module

To install the MSCommerce PowerShell module with PowerShellGet, run the following command:

Install-Module -Name MSCommerce

Import MSCommerce into the PowerShell session

After you install the module on your Windows 10 device, you then import it into each PowerShell session that you start. To import it into a PowerShell session, run the following command:

Import-Module -Name MSCommerce

Connect to MSCommerce with your credentials

To connect to the PowerShell module with your credentials, run the following command.

Connect-MSCommerce

This command connects the current PowerShell session to an Azure Active Directory tenant. The command prompts you for a username and password for the tenant you want to connect to. If multi-factor authentication is enabled for your credentials, you use the interactive option to log in.

View details for AllowSelfServicePurchase

To view a description of the AllowSelfServicePurchase parameter value and the default status, based on your organization, run the following command:

Get-MSCommercePolicy -PolicyId AllowSelfServicePurchase

View a list of self-service purchase products and their status

To view a list of all available self-service purchase products and the status of each, run the following command:

Get-MSCommerceProductPolicies -PolicyId AllowSelfServicePurchase

The following table lists the available products and their ProductId.

View or set the status for AllowSelfServicePurchase

After you view the list of products available for self-service purchase, you can view or modify the setting for a specific product.

To get the policy setting for a specific product, run the following command:

Get-MSCommerceProductPolicy -PolicyId AllowSelfServicePurchase -ProductId CFQ7TTC0KXG7

To enable the policy setting for a specific product, run the following command:

Update-MSCommerceProductPolicy -PolicyId AllowSelfServicePurchase -ProductId CFQ7TTC0KXG7 -Enabled $True

To disable the policy setting for a specific product, run the following command:

Update-MSCommerceProductPolicy -PolicyId AllowSelfServicePurchase -ProductId CFQ7TTC0KXG7 -Enabled $False

Example script to disable AllowSelfServicePurchase

The following example walks you through how to import the MSCommerce module, sign in with your account, get the ProductId for Power Automate, and then disable AllowSelfServicePurchase for that product.

Import-Module -Name MSCommerce

Connect-MSCommerce #sign-in with your global or billing administrator account when prompted

$product = Get-MSCommerceProductPolicies -PolicyId AllowSelfServicePurchase | where {$_.ProductName -match ‘Power Automate’}

Update-MSCommerceProductPolicy -PolicyId AllowSelfServicePurchase -ProductId $product.ProductID -Enabled $false

Reference material: Use AllowSelfServicePurchase for the MSCommerce PowerShell module

Back to Top