I’ve updated this post with the newer MSCommerce PowerShell module
Self-service is a great idea in several instances but in my opinion when it comes to users signing up for trials and purchasing licenses, it seems to be causing unexpected issues especially while answering to the purchasing team.
Most organizations these days have procurement processes in place to meet regulatory, security, compliance and governance needs. And the need to ensure that all licenses are approved and managed according to defined processes is very important. And when you take expenses, privacy or security into consideration, it is a good idea to disable self-service sign-up and purchases.
To disable all self-service sign-ups
This can be achieved using the MSOL PowerShell module. Type below command to check current settings:
Get-MsolCompanyInformation | fl AllowAdHocSubscriptions
To disable all self-service sign-ups,
Set-MsolCompanySettings -AllowAdHocSubscriptions:$false
When users try to sign-up, they’ll see the below message,
Prevent users from purchasing their own Pro license
To install and connect the MSCommerce module, start PowerShell as an administrator to install the module,
Install-Module -Name MSCommerce
Import-Module -Name MSCommerce
Connect-MSCommerce
Get-Command *-mscommerce*
To determine current setting,
Get-MSCommercePolicy -PolicyId AllowSelfServicePurchase
View a list of all available self-service purchase products and the status,
Get-MSCommerceProductPolicies -PolicyId AllowSelfServicePurchase
Disable the policy setting for a specific product, Below example: ‘Power BI Pro’
Update-MSCommerceProductPolicy -PolicyId AllowSelfServicePurchase -ProductId CFQ7TTC0L3PB -Enabled $False
Below is an example script on how your can disable AllowSelfServicePurchase by getting the ProductID for ‘Power BI Pro’
$p = Read-Host "Enter product name"
$product = Get-MSCommerceProductPolicies -PolicyId AllowSelfServicePurchase | where {$_.ProductName -match $p }
Update-MSCommerceProductPolicy -PolicyId AllowSelfServicePurchase -ProductId $product.ProductID -Enabled $false
In scenarios where there are more than one values for the product, Below example: ‘Power Automate’
$p = Read-Host "Enter product name"
$product = Get-MSCommerceProductPolicies -PolicyId AllowSelfServicePurchase | where {$_.ProductName -match $p }
Update-MSCommerceProductPolicy -PolicyId AllowSelfServicePurchase -ProductId $product[0].ProductID -Enabled $false
Update-MSCommerceProductPolicy -PolicyId AllowSelfServicePurchase -ProductId $product[1].ProductID -Enabled $false
To disable AllowSelfServicePurchase for all products,
Get-MSCommerceProductPolicies -PolicyId AllowSelfServicePurchase | ? {$_.PolicyValue -eq "Enabled" } | ForEach {Update-MSCommerceProductPolicy -PolicyId AllowSelfServicePurchase -ProductId $_.ProductId -Enabled $False }
Thanks for stopping by.✌