From 445c6776ebd3b22b2832efc7884a388af7807028 Mon Sep 17 00:00:00 2001 From: AdminDroid <49208841+admindroid-community@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:28:52 +0530 Subject: [PATCH] Disable self-service capability in Microsoft 365 Disable self-service capability in Microsoft 365 --- .../DisableSelfServicePurchase.ps1 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Disable Self-service Purchase in M365/DisableSelfServicePurchase.ps1 diff --git a/Disable Self-service Purchase in M365/DisableSelfServicePurchase.ps1 b/Disable Self-service Purchase in M365/DisableSelfServicePurchase.ps1 new file mode 100644 index 0000000..8b8dbe5 --- /dev/null +++ b/Disable Self-service Purchase in M365/DisableSelfServicePurchase.ps1 @@ -0,0 +1,15 @@ +<# +============================================================================================= +Name: Disable self-service purchase for Microsoft 365 products +Description: This script disables self-service purchase/ trial capability for all the supported M365 products +Script written by: AdminDroid community team +Website: admindroid.com +===================================================================================== +#> + +Install-Module -Name MSCommerce -Scope CurrentUser #once you install you should remove this line +Import-Module -Name MSCommerce +Connect-MSCommerce #sign-in with your global or billing administrator account when prompted +Get-MSCommerceProductPolicies -PolicyId AllowSelfServicePurchase | Where { $_.PolicyValue -eq “Enabled”} | forEach { + Update-MSCommerceProductPolicy -PolicyId AllowSelfServicePurchase -ProductId $_.ProductID -Enabled $false +} \ No newline at end of file