The goal of this script is to enable or disable Control Panel on Windows 8.
Sometimes administrators want to prevent the access to Control Panel for ensuring security.
This script contains one advanced functions Set-OSCControlPanel, you can use this script in the following way:
Method:
1. Rename scriptname.ps1 to scriptname.psm1 (PowerShell Module file).
2. Run Import-Module cmdlet to import this module file (Run PowerShell as administrator).
Import-Module filepath\scriptname.psm1
Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.
If($Model -eq "Disable")
{
#create item property
New-ItemProperty -Path -Name "NoControlPanel" -PropertyType DWord -ErrorAction SilentlyContinue
Set-ItemProperty -Path $RegPath -Name "NoControlPanel" -Value 1
Write-Host "Disable control panel successfully."
}
Else
{
#remove the item property
If(Get-ItemProperty -Path $RegPath -Name "NoControlPanel" -ErrorAction SilentlyContinue)
{
Remove-ItemProperty -Path $RegPath -Name "NoControlPanel" -ErrorAction SilentlyContinue
Write-Host "Enable control panel successfully."
}
}
If($Model -eq "Disable") { #create item property New-ItemProperty -Path -Name "NoControlPanel" -PropertyType DWord -ErrorAction SilentlyContinue Set-ItemProperty -Path $RegPath -Name "NoControlPanel" -Value 1 Write-Host "Disable control panel successfully."} Else { #remove the item property If(Get-ItemProperty -Path $RegPath -Name "NoControlPanel" -ErrorAction SilentlyContinue) { Remove-ItemProperty -Path $RegPath -Name "NoControlPanel" -ErrorAction SilentlyContinue Write-Host "Enable control panel successfully."}}
Example 1: Disable control panel in local.
Command: Set-OSCControlPanel -Model Disable
Screenshot:

Example 2: Enable control panel in another computer.
Command: $cre =Get-Credential admin
Set-OSCControlPanel -Model enable -Computer testclient8 -Credential $cre
Screenshot:

Windows 8