Die wichtigsten Erkenntnisse
- Automatisierte Kontrolle: Das Skript automatisiert die Verwaltung der Funktion ‘Nachrichten und Interessen’ in Windows 10 und ‘Widgets’ in Windows 11.
- Verwaltung mehrerer Benutzer:innen: Das Skript ermöglicht Änderungen in allen Benutzerprofilen eines Systems, die verschiedene Kontotypen abdecken.
- Erfordert Administratorrechte: Das Ausführen des Skripts setzt Administratorrechte voraus, um Systemeinstellungen zu ändern.
- Änderungen des Registrierungsschlüssels: Die zentrale Funktion des Skripts besteht darin, dass es bestimmte Registrierungsschlüssel auf der Grundlage der Betriebssystemversion ändern kann.
- Sofortige Wirkung: Das Skript kann den Windows Explorer neu starten, um Änderungen sofort anzuwenden und so einen Systemneustart zu vermeiden.
- Vielseitigkeit im Einsatz: Ideal für Unternehmensumgebungen, um Einheitlichkeit zu gewährleisten und Ablenkungen auf allen Computern des Unternehmens zu minimieren.
- Überlegen gegenüber manuellen Methoden: Bietet einen effizienteren Ansatz im Vergleich zu herkömmlichen manuellen Bearbeitungen oder Anpassungen von Gruppenrichtlinien.
- Umkehrbarkeit: Durch das Skript vorgenommene Änderungen können rückgängig gemacht werden, was eine flexible Verwaltung der Systemeinstellungen ermöglicht.
- Empfohlene Sicherheitsmaßnahmen: Vorsichtsmaßnahmen wie gründliche Tests, Backups der Registrierung und eine klare Dokumentation sind für eine sichere und effektive Verwendung des Skripts ratsam.
- Verbessertes IT-Management mit Tools: Die Integration dieses Skripts in Plattformen wie NinjaOne kann die IT-Verwaltungsaufgaben weiter rationalisieren.
PowerShell-Skripte sind zu einem unverzichtbaren Tool in der Toolbox von IT-Expert:innen geworden und bieten ein leistungsstarkes Mittel zur Automatisierung und Verwaltung verschiedener Aspekte von Windows-Systemen. Eine solche Aufgabe ist die Konfiguration der Funktion ‘Nachrichten und Interessen’ in Windows 10 und der Registerkarte ‘Widgets’ in Windows 11. Diese Funktion ist zwar für einige Anwender:innen nützlich, kann aber für andere eine Ablenkung oder ein unerwünschtes Element sein, insbesondere in einem professionellen Umfeld. Das Verständnis der effizienten Verwaltung dieser Funktion ist der Schlüssel zur Aufrechterhaltung eines optimalen und konzentrationsfördernden Arbeitsklimas.
Kontext
Das thematisierte Skript soll Administrator:innen die Kontrolle über die Anzeige der Registerkarte ‘Nachrichten und Interessen’, bzw. der Registerkarte ‘Widgets’ in Windows 11, in der Taskleiste ermöglichen. Dies ist besonders wichtig für IT-Expert:innen und Managed Service Provider (MSPs), die mehrere Benutzerumgebungen verwalten. Die Möglichkeit, diese Funktionen per Fernzugriff zu aktivieren, zu deaktivieren oder Änderungen daran zu verhindern, gewährleistet eine einheitliche Benutzerumgebung, was sowohl für die Sicherheit als auch für die einfache Verwaltung von entscheidender Bedeutung ist.
Das Skript zur Automatisierung der Konfiguration von ‘Nachrichten und Interessen’
#Requires -Version 5.1 <# .SYNOPSIS Hides or shows the 'News and Interests' tab in the taskbar. On Windows 11, it hides or shows the widgets tab. .DESCRIPTION Hides or shows the 'News and Interests' tab in the taskbar. On Windows 11, it hides or shows the widgets tab. .EXAMPLE (No Parameters) WARNING: Hiding News and Interests from the taskbar for all users! Registry::HKEY_USERS\S-1-12-1-2117605486-1182246982-3318994623-3070967164\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskbarDa changed from 1 to 0 Registry::HKEY_USERS\S-1-5-21-4122835015-3639794443-155648563-1001\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskbarDa changed from 1 to 0 WARNING: This script will take effect the next time the user completes a full sign-in or restarts. PARAMETER: -Enable Reveals the 'News and Interests' tab in the taskbar. .EXAMPLE -Enable Revealing News and Interests for all users! Registry::HKEY_USERS\S-1-12-1-2117605486-1182246982-3318994623-3070967164\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskbarDa changed from 0 to 1 Registry::HKEY_USERS\S-1-5-21-4122835015-3639794443-155648563-1001\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskbarDa changed from 0 to 1 WARNING: This script will take effect the next time the user completes a full sign-in or restarts. PARAMETER: -PreventChanges Should the end-user be able to modify this setting after it's been set with this script? .EXAMPLE -PreventChanges WARNING: Hiding News and Interests from the taskbar for all users! Set Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Dsh\AllowNewsAndInterests to 0 WARNING: This script will take effect the next time the user completes a full sign-in or restarts. PARAMETER: -RestartExplorer In order for this script to take immediate effect, explorer.exe will need to be restarted. .EXAMPLE -RestartExplorer WARNING: Hiding News and Interests from the taskbar for all users! Registry::HKEY_USERS\S-1-12-1-2117605486-1182246982-3318994623-3070967164\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskbarDa changed from 1 to 0 Registry::HKEY_USERS\S-1-5-21-4122835015-3639794443-155648563-1001\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskbarDa changed from 1 to 0 WARNING: Restarting Explorer.exe .OUTPUTS None .NOTES Minimum Supported OS: 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, [Parameter()] [Switch]$PreventChanges = [System.Convert]::ToBoolean($env:preventChanges), [Parameter()] [Switch]$RestartExplorer = [System.Convert]::ToBoolean($env:restartExplorer) ) begin { # Grabbing dynamic script variables if ($env:showOrHide -and $env:showOrHide -notlike "null") { if ($env:showOrHide -eq "Show") { $Enable = $True } } # Check if script is running with local admin privileges. 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 below error!" 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 below error!" Write-Error $_ exit 1 } Write-Host "Set $Path\$Name to $($(Get-ItemProperty -Path $Path -Name $Name -ErrorAction Ignore).$Name)" } } # Restarts explorer.exe function Reset-Explorer { Write-Warning "Restarting Explorer.exe" Start-Sleep -Seconds 1 Get-Process explorer | Stop-Process -Force Start-Sleep -Seconds 1 if (-not (Get-Process explorer)) { Start-Process explorer.exe } } # 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 { if (-not (Test-IsElevated)) { Write-Error -Message "Access Denied." -RecommendedAction "Please run with Administrator privileges." -Exception (New-Object -TypeName System.UnauthorizedAccessException) -Category PermissionDenied exit 1 } # The registry key is different depending on if its Windows 10 or Windows 11 if ($OSName -Like "*11*") { $AllUserPath = (Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Dsh" -ErrorAction Ignore).AllowNewsAndInterests } else { $AllUserPath = (Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Feeds" -ErrorAction Ignore).EnableFeeds } # Issues a warning prior to removing the registry key that prevents changes from end-users if ($AllUserPath -ge 0) { $EnableOrDisable = switch ($AllUserPath) { 1 { "revealed" } default { "hidden" } } if (-not ($PreventChanges)) { Write-Warning "News and Interests is currently $EnableOrDisable for all users. Removing 'Prevent Changes' setting to replace it with individual user setting as requested." if ($OSName -Like "*11*") { Remove-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Dsh" -Name "AllowNewsAndInterests" } else { Remove-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Feeds" -Name "EnableFeeds" } } } if ($OSName -Like "*11*") { $KeyPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Dsh" $KeyName = "AllowNewsAndInterests" $Value = if ($Enable) { 1 }else { 0 } } else { $KeyPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Feeds" $KeyName = "EnableFeeds" $Value = if ($Enable) { 1 }else { 0 } } # Sets a per user registry key if the end-user lock isn't set if (-not ($PreventChanges)) { $UserProfiles = Get-UserHives -Type "All" $KeyPath = New-Object System.Collections.Generic.List[string] $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 } if ($OSName -Like "*11*") { $KeyPath.Add("Registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced") } else { $KeyPath.Add("Registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Feeds") } } if ($OSName -Like "*11*") { $KeyName = "TaskbarDa" $Value = if ($Enable) { 1 }else { 0 } } else { $KeyName = "ShellFeedsTaskbarViewMode" $Value = if ($Enable) { 0 }else { 2 } } } # Change the message depending on if we're hiding or showing the menu if ($Enable) { Write-Host "Revealing News and Interests for all users!" } else { Write-Warning "Hiding News and Interests from the taskbar for all users!" } # Setting the registry key $KeyPath | ForEach-Object { Set-RegKey -Path $_ -Name $KeyName -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 } # Restart explorer.exe if ($RestartExplorer) { Reset-Explorer } else { Write-Warning "This script will take effect the next time the user completes a full sign-in or restarts." } } end { }
Greifen Sie auf über 300 Skripte im NinjaOne Dojo zu.
Detaillierte Aufschlüsselung
- Initialisierung und Parametereinstellung: Das Skript beginnt mit dem Einrichten von Parametern zum Aktivieren der Funktion, zum Verhindern von Änderungen durch Endbenutzer:innen und zum Entscheiden, ob Windows Explorer bei sofortigen Änderungen neu gestartet werden soll. Es passt sich auch dynamisch an die Umgebungsvariablen an.
- Überprüfung auf Administratorrechte: Ein kritischer Schritt ist die Überprüfung auf Administratorrechte. Das Skript prüft, ob es mit den erforderlichen Berechtigungen ausgeführt wird, um sicherzustellen, dass keine unbefugten Änderungen vorgenommen werden.
- Behandlung von Benutzerprofilen: Es identifiziert alle Benutzerprofile auf dem System, was für die Anwendung von Einstellungen auf mehrere Benutzer:innen unerlässlich ist. Dazu gehört die Behandlung verschiedener Kontotypen wie Azure AD, Domain oder lokale Konten.
- Änderung des Registrierungsschlüssels: Das Skript greift dann auf die Windows-Registrierung zu und ändert sie. Hier wird die Funktion ‘Nachrichten und Interessen’ oder ‘Widgets’ aktiviert oder deaktiviert. Je nach Betriebssystemversion (Windows 10 oder 11) zielt es auf unterschiedliche Registrierungsschlüssel ab.
- Explorer-Prozess neu starten: Optional kann das Skript den Windows Explorer-Prozess neu starten, um Änderungen sofort anzuwenden, ohne dass eine Benutzeranmeldung oder ein Systemneustart erforderlich ist.
Mögliche Anwendungsfälle
Stellen Sie sich eine Unternehmensumgebung vor, in der die IT-Abteilung ein standardisiertes und ablenkungsfreies Arbeitsklima auf allen Unternehmenscomputern sicherstellen muss. Mit diesem Skript können sie die Funktion ‘Nachrichten und Interessen’ auf allen Rechnern effizient deaktivieren, um ein einheitliches Benutzererlebnis zu gewährleisten und die Ablenkung zu minimieren.
Vergleiche
Bisher mussten solche Änderungen manuell in der Registrierung vorgenommen oder Gruppenrichtlinien angepasst werden. Dieses Skript rationalisiert den Prozess und ermöglicht es, Änderungen schnell und skaliert vorzunehmen, im Gegensatz zu den zeitaufwändigeren manuellen Methoden.
FAQs
Q1: Funktioniert dieses Skript unter allen Windows-Versionen?
A1: Das Skript ist für Windows 10 und höhere Versionen konzipiert.
Q2: Sind Administratorrechte für die Ausführung dieses Skripts erforderlich?
A2: Ja, um Änderungen an der Registrierung vorzunehmen, sind Administratorrechte erforderlich.
Q3: Kann dieses Skript Änderungen bei Bedarf rückgängig machen?
A3: Ja, das Skript kann die Funktion aktivieren oder deaktivieren, sodass eine Umkehrung möglich ist.
Folgen
Dieses Skript ist zwar von großem Nutzen, aber es ist wichtig, seine Auswirkungen zu bedenken. Die unbefugte Verwendung kann zu unerwünschten Systemkonfigurationen führen, und unbeabsichtigte Fehler bei der Skriptausführung können zu einer Instabilität des Systems führen.
Empfehlungen
- Gründlich testen: Führen Sie das Skript vor dem Einsatz in einer Staging-Umgebung aus.
- Backup der Registrierung: Sichern Sie immer Registrierungseinstellungen, bevor Sie Änderungen vornehmen.
- Klare Dokumentation: Führen Sie eine klare Dokumentation der mit diesem Skript vorgenommenen Änderungen, damit Sie später darauf zurückgreifen können.
Abschließende Überlegungen
Im Bereich des IT-Managements spielen Tools wie NinjaOne eine zentrale Rolle. Sie bieten eine einheitliche Plattform für die Überwachung und Automatisierung von IT-Aufgaben, einschließlich der Skriptbereitstellung. Dieses PowerShell-Skript kann in Kombination mit einem robusten Verwaltungs-Tool wie NinjaOne die Fähigkeit von IT-Expert:innen, ihre digitale Umgebung zu verwalten und zu pflegen, erheblich verbessern und so zu mehr Effizienz und Kontrolle führen.