Last active
December 26, 2019 13:57
-
-
Save techdecline/24570399dc89db6c854a3dcaa5a613f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
This script allows modification of local MDM policies. | |
It is based on Microsoft Documentation: https://docs.microsoft.com/en-us/windows/client-management/mdm/using-powershell-scripting-with-the-wmi-bridge-provider | |
Author: Cornelius Schuchardt, SoftEd Systems GmbH | |
Must be executed using SYSTEM account. | |
#> | |
$namespaceName = "root\cimv2\mdm\dmmap" | |
$className = "MDM_Policy_Config01_Connectivity02" | |
$instance = "Connectivity" | |
$property = "AllowBluetooth" | |
$value = 0 | |
# Enumerate all instances available for classname | |
$obj = Get-CimInstance -Namespace $namespaceName -ClassName $className | |
if (-not ($obj)) { | |
New-CimInstance -Namespace $namespaceName -ClassName $className -Property @{ParentID="./Vendor/MSFT/Policy/Config";InstanceID=$instance;$property=0} | |
} | |
else { | |
$currentValue = $obj.$property | |
if ($currentValue -eq $value) { | |
Write-Verbose "MDM setting is in consistent state: $property is $value" | |
} | |
else { | |
Write-Verbose "MDM setting must be changed: $property is $currentValue; Should be $value" | |
$obj.$property=$value | |
Set-CimInstance -CimInstance $obj | |
} | |
} |
Windows 7 will require a complete different approach as the MDM Providers do not exist. For Windows 8, there is probably another Configuration Service Provider. You could dig in using WMI Explorer and search for Bluetooth on a test device in the relevant namespace (root\cimv2\mdm\dmmap).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very useful script. It seems to only work on Windows 10. Do you know how to do the same thing on Windows 7 & 8? Thanks!