Home
Disable self-service purchases in Microsoft 365
Office 365 (Self-Service) Wednesday, 28 July 2021 by paul

With the recent addition of Windows 365 there are more products which can be purchased by end users using self-service.

The following PowerShell script will disable all the self-service purchase policies.

# For all self-service purchase products set to disabled
Import-Module -Name MSCommerce

# Get list of all product self-service policies where purchase is enabled
try { 
        $products = Get-MSCommerceProductPolicies -PolicyId AllowSelfServicePurchase | where {$_.PolicyValue -eq 'Enabled'}
    } 
catch { 
        # Connect to service
        Write-Host "Connecting to service" -foreground yellow
        Connect-MSCommerce
        $products = Get-MSCommerceProductPolicies -PolicyId AllowSelfServicePurchase | where {$_.PolicyValue -eq 'Enabled'}
}
   
foreach($product in $products){
    # disable self-service purchase
    Update-MSCommerceProductPolicy -PolicyId AllowSelfServicePurchase -ProductId $product.ProductID -Enabled $false    
}
# List products to confirm all disabled
Write-Host "Check policies are set to disabled" -foreground green
Get-MSCommerceProductPolicies -PolicyId AllowSelfServicePurchase

 


Add Comment
No Comments.