disable self purchasing office365 code example

Example: disable self purchasing office365

#Install Module from PSGallery
Install-Module -Name MSCommerce

#Connect 
Connect-MSCommerce

#Get Policy ID
$PolicyID = (Get-MSCommercePolicies).PolicyID

#Get all Product Policies
$Products = Get-MSCommerceProductPolicies -PolicyId $PolicyID

#Disable Self Service Purchase for each Product
foreach ($P in $Products){

    Update-MSCommerceProductPolicy -PolicyId $PolicyID -ProductId $P.ProductID -Enabled $False

}

#Sanity Check
 Get-MSCommerceProductPolicies -PolicyId $PolicyID

Tags:

Misc Example