Last active
April 18, 2019 12:10
-
-
Save techdecline/a88d5fd35eebe7f3c321e137c1179185 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| #> | |
| $namespaceName = "root\cimv2\mdm\dmmap" | |
| $className = "MDM_Policy_Config01_Bluetooth02" | |
| $instance = "Bluetooth" | |
| $property = "AllowDiscoverableMode" | |
| $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;AllowAdvertising=$value} | |
| } | |
| 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 | |
| } | |
| } | |
| $namespaceName = "root\cimv2\mdm\dmmap" | |
| $className = "MDM_Policy_Config01_Bluetooth02" | |
| $instance = "Bluetooth" | |
| $property = "AllowAdvertising" | |
| $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;AllowAdvertising=$value} | |
| } | |
| 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 | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment