Efficiently Manage Windows Spotlight and Start Menu Suggestions with PowerShell

Key takeaways

  • Streamlines customization: The script efficiently manages Windows Spotlight and Start Menu suggestions across multiple user profiles.
  • Administrative privileges required: Running this script necessitates administrative rights due to its modifications to the registry.
  • Covers various user profiles: It addresses Azure AD, Domain, and local user accounts, ensuring comprehensive application.
  • OS-Specific features: Tailored to accommodate differences between Windows 10 and Windows 11, especially in enterprise editions.
  • Automates tedious tasks: Replaces the need for manual registry edits or group policy configurations.
  • Privacy and user experience balance: Offers control over personalized content and suggestions, aligning with privacy standards and user preferences.
  • Essential for MSPs and IT pros: A valuable tool for Managed Service Providers and IT professionals in managing networked environments.
  • Testing and backup recommended: Advises testing the script in a controlled setting and backing up registry settings before implementation.
  • Enhanced with NinjaOne: The script’s capabilities can be augmented when used in conjunction with NinjaOne’s IT management platform.

The Windows operating system offers a range of customizable features to enhance user experience, one of which is Windows Spotlight and Start Menu suggestions. This blog delves into a PowerShell script designed for configuring these features, highlighting its significance for IT professionals and Managed Service Providers (MSPs).

Background

With the evolving Windows interface, managing and customizing user experience has become more pertinent. Spotlight and Start Menu suggestions are key features in Windows 10 and 11, providing personalized content and app recommendations. However, for various reasons including privacy and user preference, IT professionals and MSPs often seek to control these features across multiple user profiles. This PowerShell script offers a solution, enabling or disabling these features systematically.

The script:

 

#Requires -Version 5.1

<#
.SYNOPSIS
    Enable or Disable Spotlight and Suggestions in the Start Menu.
.DESCRIPTION
    Enable or Disable Spotlight and Suggestions in the Start Menu.
.EXAMPLE
    (No Parameters)

    On Windows 11, only recommendations for tips, shortcuts, and new apps are disabled/enabled from the Start Menu.
    Attempting to Disable Spotlight and Start Menu Suggestions
    Registry::HKEY_USERS\S-1-11-1-1111111111-1111111111-1111111111-1111111111\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SubscribedContent-338389Enabled changed from 0 to 0
    Registry::HKEY_USERS\S-1-11-1-1111111111-1111111111-1111111111-1111111111\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SubscribedContent-338388Enabled changed from 0 to 0
    Registry::HKEY_USERS\S-1-11-1-1111111111-1111111111-1111111111-1111111111\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SystemPaneSuggestionsEnabled changed from 0 to 0
    Registry::HKEY_USERS\S-1-11-1-1111111111-1111111111-1111111111-1111111111\SOFTWARE\Policies\Microsoft\Windows\CloudContent\DisableWindowsSpotlightFeatures changed from 1 to 1
    Registry::HKEY_USERS\S-1-11-1-1111111111-1111111111-1111111111-1111111111\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_IrisRecommendations changed from 0 to 0
    Registry::HKEY_USERS\S-1-11-1-1111111111-1111111111-1111111111-1111111111\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SubscribedContent-338389Enabled changed from 0 to 0
    Registry::HKEY_USERS\S-1-11-1-1111111111-1111111111-1111111111-1111111111\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SubscribedContent-338388Enabled changed from 0 to 0
    Registry::HKEY_USERS\S-1-11-1-1111111111-1111111111-1111111111-1111111111\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SystemPaneSuggestionsEnabled changed from 0 to 0
    Registry::HKEY_USERS\S-1-11-1-1111111111-1111111111-1111111111-1111111111\SOFTWARE\Policies\Microsoft\Windows\CloudContent\DisableWindowsSpotlightFeatures changed from 1 to 1
    Registry::HKEY_USERS\S-1-11-1-1111111111-1111111111-1111111111-1111111111\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_IrisRecommendations changed from 0 to 0

PARAMETER: -Enable
    Enables Spotlight and Suggestions in the Start Menu.
.OUTPUTS
    None
.NOTES
    Minimum OS Architecture Supported: Windows 10
    Release Notes: Initial Release
By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https://www.ninjaone.com/terms-of-use.
    Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. 
    Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. 
    Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. 
    Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. 
    Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. 
    Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. 
    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).
#>

[CmdletBinding()]
param (
    [Parameter()]
    [Switch]$Enable
)

begin {
    # Retrieve Dynamic Script Form Values
    if ($env:enableOrDisable -and $env:enableOrDisable -notlike "null") {
        if ($env:enableOrDisable -eq "Enable") { $Enable = $True }
    }

    # Local Admin Privileges are required to set other users' registry keys
    function Test-IsElevated {
        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
        $p = New-Object System.Security.Principal.WindowsPrincipal($id)
        $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
    }

    # Get a list of all the user profiles for when the script is run as System.
    function Get-UserHives {
        param (
            [Parameter()]
            [ValidateSet('AzureAD', 'DomainAndLocal', 'All')]
            [String]$Type = "All",
            [Parameter()]
            [String[]]$ExcludedUsers,
            [Parameter()]
            [switch]$IncludeDefault
        )
    
        # User account SID's follow a particular pattern depending on if they're Azure AD or a Domain account or a local "workgroup" account.
        $Patterns = switch ($Type) {
            "AzureAD" { "S-1-12-1-(\d+-?){4}$" }
            "DomainAndLocal" { "S-1-5-21-(\d+-?){4}$" }
            "All" { "S-1-12-1-(\d+-?){4}$" ; "S-1-5-21-(\d+-?){4}$" } 
        }
    
        # We'll need the NTuser.dat file to load each user's registry hive. So we grab it if their account sid matches the above pattern. 
        $UserProfiles = Foreach ($Pattern in $Patterns) { 
            Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\*" |
                Where-Object { $_.PSChildName -match $Pattern } | 
                Select-Object @{Name = "SID"; Expression = { $_.PSChildName } },
                @{Name = "UserName"; Expression = { "$($_.ProfileImagePath | Split-Path -Leaf)" } }, 
                @{Name = "UserHive"; Expression = { "$($_.ProfileImagePath)\NTuser.dat" } }, 
                @{Name = "Path"; Expression = { $_.ProfileImagePath } }
        }
    
        # There are some situations where grabbing the .Default user's info is needed.
        switch ($IncludeDefault) {
            $True {
                $DefaultProfile = "" | Select-Object UserName, SID, UserHive, Path
                $DefaultProfile.UserName = "Default"
                $DefaultProfile.SID = "DefaultProfile"
                $DefaultProfile.Userhive = "$env:SystemDrive\Users\Default\NTUSER.DAT"
                $DefaultProfile.Path = "C:\Users\Default"
    
                $DefaultProfile | Where-Object { $ExcludedUsers -notcontains $_.UserName }
            }
        }
    
        $UserProfiles | Where-Object { $ExcludedUsers -notcontains $_.UserName }
    }

    # Helper function for setting registry keys
    function Set-RegKey {
        param (
            $Path,
            $Name,
            $Value,
            [ValidateSet("DWord", "QWord", "String", "ExpandedString", "Binary", "MultiString", "Unknown")]
            $PropertyType = "DWord"
        )
        if (-not $(Test-Path -Path $Path)) {
            # Check if path does not exist and create the path
            New-Item -Path $Path -Force | Out-Null
        }
        if ((Get-ItemProperty -Path $Path -Name $Name -ErrorAction Ignore)) {
            # Update property and print out what it was changed from and changed to
            $CurrentValue = (Get-ItemProperty -Path $Path -Name $Name -ErrorAction Ignore).$Name
            try {
                Set-ItemProperty -Path $Path -Name $Name -Value $Value -Force -Confirm:$false -ErrorAction Stop | Out-Null
            }
            catch {
                Write-Error "[Error] Unable to Set registry key for $Name please see the error below!"
                Write-Error $_
                exit 1
            }
            Write-Host "$Path\$Name changed from $CurrentValue to $($(Get-ItemProperty -Path $Path -Name $Name -ErrorAction Ignore).$Name)"
        }
        else {
            # Create property with value
            try {
                New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force -Confirm:$false -ErrorAction Stop | Out-Null
            }
            catch {
                Write-Error "[Error] Unable to Set registry key for $Name please see the error below!"
                Write-Error $_
                exit 1
            }
            Write-Host "Set $Path\$Name to $($(Get-ItemProperty -Path $Path -Name $Name -ErrorAction Ignore).$Name)"
        }
    }

    # Gets the OS Name, e.g., Windows 10 Enterprise or Windows 11 Enterprise
    function Get-OSName {
        systeminfo | findstr /B /C:"OS Name"
    }

    $OSName = Get-OSName
}
process {

    # Error out if the script doesn't have local administrator privileges
    if (-not (Test-IsElevated)) {
        Write-Error -Message "Access Denied. Please run with Administrator privileges." -Exception (New-Object -TypeName System.UnauthorizedAccessException) -Category PermissionDenied
        exit 1
    }

    # Get the registry hive for all users
    $UserProfiles = Get-UserHives -Type "All"

    # Initialize generic list for the keys we're going to set
    $Keys = New-Object System.Collections.Generic.List[Object]
    $LoadedProfiles = New-Object System.Collections.Generic.List[Object]

    Foreach ($UserProfile in $UserProfiles) {
        # Load User ntuser.dat if it's not already loaded
        if ((Test-Path "Registry::HKEY_USERS\$($UserProfile.SID)" -ErrorAction Ignore) -eq $false) {
            $LoadedProfiles.Add($UserProfile)
            Start-Process -FilePath "cmd.exe" -ArgumentList "/C reg.exe LOAD HKU\$($UserProfile.SID) `"$($UserProfile.UserHive)`"" -Wait -WindowStyle Hidden
        }

        $Keys.Add(
            [PSCustomObject]@{
                Path  = "Registry::HKEY_USERS\$($UserProfile.SID)\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
                Name  = "SubscribedContent-338389Enabled"
                Value = if ($Enable) { 1 }Else { 0 }
            }
        )

        $Keys.Add(
            [PSCustomObject]@{
                Path  = "Registry::HKEY_USERS\$($UserProfile.SID)\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
                Name  = "SubscribedContent-338388Enabled"
                Value = if ($Enable) { 1 }Else { 0 }
            }
        )

        $Keys.Add(
            [PSCustomObject]@{
                Path  = "Registry::HKEY_USERS\$($UserProfile.SID)\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"
                Name  = "SystemPaneSuggestionsEnabled"
                Value = if ($Enable) { 1 }Else { 0 }
            }
        )

        # This key only works on Windows 10/11 Enterprise
        if ($OSName -Like "*Enterprise*") {
            $Keys.Add(
                [PSCustomObject]@{
                    Path  = "Registry::HKEY_USERS\$($UserProfile.SID)\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
                    Name  = "DisableWindowsSpotlightFeatures"
                    Value = if ($Enable) { 0 }Else { 1 }
                }
            )
        }
        else {
            Write-Warning "Disabling Spotlight is only possible on an Enterprise edition of Windows." 
        }

        # The recommended section in Windows 11 is slightly helpful; this will simply remove the ads but keep the useful frequently used section.
        if ($OSName -Like "*11*") {
            $Keys.Add(
                [PSCustomObject]@{
                    Path  = "Registry::HKEY_USERS\$($UserProfile.SID)\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
                    Name  = "Start_IrisRecommendations"
                    Value = if ($Enable) { 1 }Else { 0 }
                }
            )
        }
    }

    if($OSName -Like "*11*"){
        Write-Host "On Windows 11, only recommendations for tips, shortcuts, and new apps are disabled/enabled from the Start Menu."
    }
    
    if ($Enable) {
        Write-Host "Attempting to Enable Spotlight and Start Menu Suggestions"
    }
    else {
        Write-Host "Attempting to Disable Spotlight and Start Menu Suggestions"
    }

    # Set all the registry keys
    $Keys | ForEach-Object { Set-RegKey -Path $_.Path -Name $_.Name -Value $_.Value }

    # Unload any profiles we loaded up earlier (if any)
    Foreach ($LoadedProfile in $LoadedProfiles) {
        [gc]::Collect()
        Start-Sleep 1
        Start-Process -FilePath "cmd.exe" -ArgumentList "/C reg.exe UNLOAD HKU\$($LoadedProfile.SID)" -Wait -WindowStyle Hidden | Out-Null
    }
}
end {
    
    
    
}

 

Access 300+ scripts in the NinjaOne Dojo

Get Access

Detailed breakdown

The script begins with a synopsis and description, indicating its purpose – toggling Windows Spotlight and Start Menu suggestions. It leverages PowerShell’s capabilities to modify system registry settings for individual user profiles, including Azure AD and Domain accounts.

  • Initialization: The script starts by checking the environment variable $env:enableOrDisable to determine if it should enable or disable the features.
  • Administrative Check: It includes a function Test-IsElevated to verify if the script is running with administrative privileges, essential for modifying registry keys.
  • User Profile Handling: Get-UserHives function is used to fetch user profiles. It filters Azure AD, Domain, and local accounts, ensuring that the script targets the necessary user profiles.
  • Registry Modification: The script constructs a list of registry keys to be modified. These keys control various aspects of Spotlight and Start Menu suggestions. Depending on the $Enable switch, it sets these keys to enable or disable the features.
  • OS Specific Handling: The script also includes checks for the operating system version, catering to specificities in Windows 10 and Windows 11.
  • Execution and Cleanup: Finally, the script applies the changes to each user profile and unloads any loaded hives, ensuring no residual impact on system performance.

Potential use cases

Consider an MSP managing a corporate network. They need to disable Start Menu suggestions across all user profiles for privacy reasons. Using this script, the MSP can systematically apply these changes without manually configuring each profile, saving time and reducing the risk of inconsistencies.

Comparisons

Traditionally, such changes would require manual registry edits or group policy adjustments. This script simplifies the process, providing a more efficient and less error-prone method. Additionally, it covers user profiles that may not be affected by group policies, offering a more comprehensive solution.

FAQs

  • Q: Can this script be used on non-enterprise versions of Windows?
    • A: Yes, but some features like disabling Windows Spotlight are specific to Enterprise editions.
  • Q: Is administrative privilege mandatory for running this script?
    • A: Yes, modifying registry keys requires administrative rights.

Implications

While this script offers powerful customization, it also carries implications for user experience and privacy. Disabling Spotlight and suggestions may impact how users interact with their OS and find new features or apps. IT admins should weigh these considerations against organizational policies and user needs.

Recommendations

  • Test thoroughly: Run the script in a controlled environment before deployment.
  • Backup registries: Always backup registry settings before making changes.
  • Inform users: If deploying in a corporate environment, inform users about the changes for transparency.

Final thoughts

In the context of this script, NinjaOne provides a platform that can further streamline such IT management tasks. Its ability to deploy scripts across a network can make implementing changes like these more manageable and efficient, reinforcing its value as a comprehensive IT management solution.

Next Steps

Building an efficient and effective IT team requires a centralized solution that acts as your core service deliver tool. NinjaOne enables IT teams to monitor, manage, secure, and support all their devices, wherever they are, without the need for complex on-premises infrastructure.

Learn more about NinjaOne Remote Script Deployment, check out a live tour, or start your free trial of the NinjaOne platform.

Categories:

You might also like

×

See NinjaOne in action!

By submitting this form, I accept NinjaOne's privacy policy.

NinjaOne Terms & Conditions

By clicking the “I Accept” button below, you indicate your acceptance of the following legal terms as well as our Terms of Use:

  • Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms.
  • Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party.
  • Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library belonging to or under the control of any other software provider.
  • Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations.
  • Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks.
  • Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script.
  • EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).