Overblog
Editer l'article Suivre ce blog Administration + Créer mon blog

[Powershell] [Windows 10] Disable Action Center

Publié le par damcuvelier

# Run as administrator
function DisableActionCenter{
param($Hive)

Write-Host "Disabling Action Center..."
If (!(Test-Path "$Hive\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications")) {New-Item -Path "$Hive\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications" | Out-Null}
Copy-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications" -Destination "$Hive\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications" -Recurse -Force -Passthru
 Set-ItemProperty -Path "$Hive\Software\Microsoft\Windows\CurrentVersion\PushNotifications" -Name "ToastEnabled" -Type DWord -Value 0
 Set-ItemProperty -Path "$Hive\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications" -Name "ToastEnabled" -Type DWord -Value 0

If (!(Test-Path "$Hive\Software\Policies\Microsoft\Windows\Explorer")) {New-Item -Path "$Hive\Software\Policies\Microsoft\Windows\Explorer" | Out-Null}
 Set-ItemProperty -Path "$Hive\Software\Policies\Microsoft\Windows\Explorer" -Name "DisableNotificationCenter" -Type DWord -Value 1


If (!(Test-Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center')) {New-Item -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center' | Out-Null}
If (!(Test-Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Notifications')) {New-Item -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Notifications' | Out-Null}
 Set-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Notifications' -Name "DisableEnhancedNotifications" -Type DWord -Value 1
}


#Get hku user hive
$username = $env:username
$usercheck = "NTUSER.DAT"
$HKUs = Get-Item -Path Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\hivelist | Select-Object -ExpandProperty Property
foreach($HKU in $HKUs)
{
$Value = Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\hivelist -Name $HKU
if($Value -match $username -and $Value -match $usercheck){$result = $HKU.split("\")[3]}
}
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
$HKUuserHive = "HKU:\$result"
if(Test-Path -Path $HKUuserHive){DisableActionCenter -Hive $HKUuserHive}
Remove-PSDrive -Name HKU
Write-Host "Close/Open User Session to apply configuration"

 

Commenter cet article