For most Windows 10 deployments, organizations are removing most of the built-in apps that ships with the operating system. However, in situations when this is not dealt with, for various reasons, you might get some unwanted notifications in the Action Center. Get Office is such an app that will periodically notify the end user with various suggestions. These notifications can be turned off in the Notification and Actions part of the new Settings app in Windows 10, with a single click. That will not work though when you’re deploying operating systems, instead you’d need some script to perform that action.
In this blog post, I’ll share a script that I’ve put together based on Jörgen Nilssons original idea leveraging Active Setup for operating system deployments, in order to amend or configure registry settings. This is necessary though, due to the fact that these notification settings resides in the current user hive of the registry.
Script
<# .SYNOPSIS Configure Notification Actions in Windows 10. .DESCRIPTION This script serves as a template to successfully configure different settings related to Notification Actions in Windows 10, that requires manipulation of the registry. Active Setup is leveraged to perform a run once experience per user. There are three different run modes supported by this script: - Stage This mode is the initial mode that should be invoked e.g. during operating system deployment with MDT or ConfigMgr. Script is copied to C:\Windows and Active Setup is prepared. - CreateProcess This mode makes sure that the script is re-launched during Active Setup in order not to prolong the logon experience for the end user. - Execute This mode performs the actual configuration notifications in Windows 10. Use only the Stage run mode to prepare the system for Active Setup and notification action configuration changes. .EXAMPLE .\Set-NotificationActions.ps1 -RunMode Stage .NOTES Version history: 1.0.0 - (2016-11-15) Script created .NOTES FileName: Set-NotificationActions.ps1 Author: Nickolaj Andersen Contact: @NickolajA Created: 2016-11-15 Updated: 2016-11-15 Version: 1.0.0 #> [CmdletBinding(SupportsShouldProcess=$true)] param(
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()] [ValidateSet(“Stage”,”Execute”, “CreateProcess”)] [string]$RunMode ) Process { # Functions function Invoke-Process { param(
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()] [string]$Name,
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()] [string]$Arguments,
[parameter(Mandatory=$false)]
[switch]$Hidden,
[parameter(Mandatory=$false)]
[switch]$Wait ) # Construct new ProcessStartInfo object $ProcessStartInfo = New-Object -TypeName System.Diagnostics.ProcessStartInfo $ProcessStartInfo.FileName = $Name $ProcessStartInfo.Arguments = $Arguments # Hide the process window if ($Hidden -eq $true) { $ProcessStartInfo.WindowStyle = “Hidden” $ProcessStartInfo.CreateNoWindow = $true } # Instatiate new process $Process = [System.Diagnostics.Process]::Start($ProcessStartInfo) # Wait for process to terminate if ($Wait -eq $true) { $Process.WaitForExit() } # Return exit code from process return $Process.ExitCode } switch ($RunMode) { “Stage” { if (-not(Test-Path -Path (Join-Path -Path $env:SystemRoot -ChildPath $MyInvocation.MyCommand.Name) -PathType Leaf)) { # Stage script in system root directory for ActiveSetup try { Copy-Item $MyInvocation.MyCommand.Definition -Destination $env:SystemRoot -ErrorAction Stop } catch [System.Exception] { Write-Warning -Message “Unable to stage script in system root directory for ActiveSetup. Error message: $($_.Exception.Message)” ; exit } } # Prepare ActiveSetup try { New-Item -Path “HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\OSD” -type Directory -Force -ErrorAction Stop New-ItemProperty “HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\OSD” -Name Version -Value 1 -PropertyType String -Force -ErrorAction Stop New-ItemProperty “HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\OSD” -Name StubPath -Value “powershell.exe -ExecutionPolicy ByPass -NoProfile -File $(Join-Path -Path $env:SystemRoot -ChildPath $MyInvocation.MyCommand.Name) -RunMode CreateProcess” -PropertyType ExpandString -Force -ErrorAction Stop } catch [System.Exception] { Write-Warning -Message “Unable to prepare ActiveSetup key. Error message: $($_.Exception.Message)” } } “CreateProcess” { # Invoke script for Active Setup Invoke-Process -Name “powershell.exe” -Arguments “-ExecutionPolicy Bypass -NoProfile -File $($env:SystemRoot)\$($MyInvocation.MyCommand.Name) -RunMode Execute” -Hidden } “Execute” { # Validate that the notification settings key exists do { Start-Sleep -Seconds 3 } while (-not(Test-Path -Path “HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings”)) # Create OfficeHub key try { New-Item -Path “HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe!Microsoft.MicrosoftOfficeHub” -type Directory -Force -ErrorAction Stop } catch [System.Exception] { Write-Warning -Message “Unable to create OfficeHub key. Error message: $($_.Exception.Message)” } # Add Enabled value try { New-ItemProperty -Path “HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe!Microsoft.MicrosoftOfficeHub” -Name Enabled -PropertyType DWORD -Value 0 -Force -ErrorAction Stop } catch [System.Exception] { Write-Warning -Message “Unable to create Enabled value. Error message: $($_.Exception.Message)” } } } }
Save the above script as e.g. Set-NotificationActions.ps1.
Using the script in a Task Sequence
In order to leverage the script for your operating system deployment of Windows 10, below is a list of required steps that you need to take:
1. Create a Package in ConfigMgr pointing to the content source where the Set-NotificationActions.ps1 script has been stored. Do not create a Program for this package.
2. In your task sequence used to deploy Windows 10, add a Run PowerShell Script step at some point after the Setup Windows and ConfigMgr step called e.g. Disable Office Hub Notifications.
3. Select the package recently created and configure the step as shown in the picture below:
Hi Bud,
Just have to say this is an awesome script. Like the out of the box thinking! 🙂
And thanks for sharing!
Cheers,
Richie
128 lines to do the same in 3 lines 🙂
Reg.exe Load HKEY_LOCAL_MACHINE\DefaultUser C:\Users\Default\NTUser.dat
Reg.exe Add “HKLM\DefaultUser\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe!Microsoft.MicrosoftOfficeHub” /v Enabled /d 0 /t REG_DWORD /f
Reg.exe Unload HKEY_LOCAL_MACHINE\DefaultUser
Hi,
Yes, it can be done exactly like you state, however I’m not a legacy type of guy 🙂
Regards,
Nickolaj
Not trying to be pedantic, but if the solution posted by KIIS works, it would be considered the preferred method by Microsoft.
Microsoft has stated in the past that ActiveSetup will be going away in a future Windows 10 release, so it probably isn’t a good idea to rely on it.