revert copilot policies
This commit is contained in:
@@ -247,6 +247,9 @@ function Disable-Registry-Keys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# =========================
|
||||||
|
# prob not worth trying to restore shouldnt break any functionality if the rest is restored
|
||||||
|
# =========================
|
||||||
function Remove-Copilot-Nudges-Keys {
|
function Remove-Copilot-Nudges-Keys {
|
||||||
#prefire copilot nudges package by deleting the registry keys
|
#prefire copilot nudges package by deleting the registry keys
|
||||||
Write-Status -msg 'Removing Copilot Nudges Registry Keys...'
|
Write-Status -msg 'Removing Copilot Nudges Registry Keys...'
|
||||||
@@ -296,7 +299,7 @@ function Disable-Copilot-Policies {
|
|||||||
#disable copilot policies in region policy json
|
#disable copilot policies in region policy json
|
||||||
$JSONPath = "$env:windir\System32\IntegratedServicesRegionPolicySet.json"
|
$JSONPath = "$env:windir\System32\IntegratedServicesRegionPolicySet.json"
|
||||||
if (Test-Path $JSONPath) {
|
if (Test-Path $JSONPath) {
|
||||||
Write-Host 'Disabling CoPilot Policies in ' -NoNewline
|
Write-Host "$(@('Disabling','Enabling')[$revert]) CoPilot Policies in " -NoNewline -ForegroundColor Cyan
|
||||||
Write-Host "[$JSONPath]" -ForegroundColor Yellow
|
Write-Host "[$JSONPath]" -ForegroundColor Yellow
|
||||||
|
|
||||||
#takeownership
|
#takeownership
|
||||||
@@ -308,11 +311,11 @@ function Disable-Copilot-Policies {
|
|||||||
try {
|
try {
|
||||||
$copilotPolicies = $jsonContent.policies | Where-Object { $_.'$comment' -like '*CoPilot*' }
|
$copilotPolicies = $jsonContent.policies | Where-Object { $_.'$comment' -like '*CoPilot*' }
|
||||||
foreach ($policies in $copilotPolicies) {
|
foreach ($policies in $copilotPolicies) {
|
||||||
$policies.defaultState = 'disabled'
|
$policies.defaultState = @('disabled', 'enabled')[$revert]
|
||||||
}
|
}
|
||||||
$newJSONContent = $jsonContent | ConvertTo-Json -Depth 100
|
$newJSONContent = $jsonContent | ConvertTo-Json -Depth 100
|
||||||
Set-Content $JSONPath -Value $newJSONContent -Force
|
Set-Content $JSONPath -Value $newJSONContent -Force
|
||||||
Write-Status -msg "$($copilotPolicies.count) CoPilot Policies Disabled"
|
Write-Status -msg "$($copilotPolicies.count) CoPilot Policies $(@('Disabled','Enabled')[$revert])"
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Status -msg 'CoPilot Not Found in IntegratedServicesRegionPolicySet' -errorOutput $true
|
Write-Status -msg 'CoPilot Not Found in IntegratedServicesRegionPolicySet' -errorOutput $true
|
||||||
|
|||||||
Reference in New Issue
Block a user