Da Unternehmen zunehmend digitale Lösungen integrieren, wird die Verwaltung und Bereitstellung von Software immer wichtiger. Innerhalb dieses Rahmens ist der Windows Store von Microsoft ein zentrales Element, das eine große Auswahl an Anwendungen und Diensten bietet. Es ist wichtig zu verstehen, wie der Microsoft Store für alle Benutzer aktiviert werden kann, insbesondere für große IT-Unternehmen.
Hintergrund
Der Windows Store von Microsoft wurde eingeführt, um den Prozess der Anwendungsbereitstellung zu vereinfachen. Es kann jedoch Szenarien geben, in denen der Windows Store entweder standardmäßig oder durch bestimmte Richtlinien deaktiviert ist. Für IT-Fachleute und Managed Service Provider (MSPs) ist die Möglichkeit, diese Funktion für mehrere Benutzerprofile zu aktivieren, nicht nur ein Vorteil, sondern eine Notwendigkeit. Dafür gibt es das vorgestellte Skript, ein leistungsstarkes Tool, das darauf zugeschnitten ist, den Windows Store für alle Benutzer zu aktivieren, sowohl für bestehende als auch für neu erstellte.
Das Skript:
#Requires -Version 5.1 <# .SYNOPSIS Enables the Windows Store for all users and newly created users. .DESCRIPTION Enables the Windows Store for all users and newly created users. No parameters needed Enables the Windows Store for all users and newly created users. .EXAMPLE (No Parameters) Enables the Windows Store for all users and newly created users. .OUTPUTS None .NOTES Minimum OS Architecture Supported: Windows 10, Server 2016 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/de/nutzungsbedingungen 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 () begin { function Test-IsElevated { $id = [System.Security.Principal.WindowsIdentity]::GetCurrent() $p = New-Object System.Security.Principal.WindowsPrincipal($id) $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator) } function Test-IsSystem { $id = [System.Security.Principal.WindowsIdentity]::GetCurrent() return $id.Name -like "NT AUTHORITY*" -or $id.IsSystem } if (!(Test-IsElevated) -and !(Test-IsSystem)) { Write-Error -Message "Access Denied. Please run with Administrator privileges." exit 1 } # Setting up some functions to be used later. function Set-HKProperty { 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)" } } # This will get all the registry path's for all actual users (not system or network service account but actual users.) 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 patter 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 users registry hive. So we grab it if their account sid matches the above pattern. $UserProfiles = Foreach ($Pattern in $Patterns) { Get-ItemProperty "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionProfileList*" | Where-Object { $_.PSChildName -match $Pattern } | Select-Object @{Name = "SID"; Expression = { $_.PSChildName } }, @{Name = "UserHive"; Expression = { "$($_.ProfileImagePath)NTuser.dat" } }, @{Name = "UserName"; Expression = { "$($_.ProfileImagePath | Split-Path -Leaf)" } } } # There are some situations where grabbing the .Default user's info is needed. switch ($IncludeDefault) { $True { $DefaultProfile = "" | Select-Object UserName, SID, UserHive $DefaultProfile.UserName = "Default" $DefaultProfile.SID = "DefaultProfile" $DefaultProfile.Userhive = "$env:SystemDriveUsersDefaultNTUSER.DAT" # It was easier to write-output twice than combine the two objects. $DefaultProfile | Where-Object { $ExcludedUsers -notcontains $_.UserName } | Write-Output } } $UserProfiles | Where-Object { $ExcludedUsers -notcontains $_.UserName } | Write-Output } } process { $Path = "SoftwarePoliciesMicrosoftWindowsStore" $Name = "RemoveWindowsStore" $Value = 0 # Get each user profile SID and Path to the profile. If there are any exclusions we'll have to take them into account. $UserProfiles = Get-UserHives -IncludeDefault # If the Disable-WindowsStore script was used we'll need to check applocker [xml]$AppLockerXML = Get-AppLockerPolicy -Local -Xml if ($AppLockerXML.AppLockerPolicy.RuleCollection.FilePublisherRule) { $AppLockerXML.AppLockerPolicy.RuleCollection.FilePublisherRule | ForEach-Object { if (($_.Action -eq "Deny") -and ($_.Conditions.FilePublisherCondition.ProductName -like "*Microsoft.WindowsStore*")) { Write-Warning "Removing AppLocker file publishing rules for the Windows Store!" [Void]$_.ParentNode.RemoveChild($_) } } if($AppLockerXML.AppLockerPolicy.RuleCollection.FilePublisherRule.id.Count -eq "1" -and $AppLockerXML.AppLockerPolicy.RuleCollection.FilePublisherRule.Name -eq "(Default Rule) All signed packaged apps"){ $AppLockerXML.AppLockerPolicy.RuleCollection.FilePublisherRule | ForEach-Object { if($_.ParentNode){ [Void]$_.ParentNode.RemoveChild($_) } } $AppLockerXML.AppLockerPolicy.RuleCollection | ForEach-Object { if($_.Type -eq "Appx"){ $_.EnforcementMode = "NotConfigured" } } } $AppLockerXML.Save("$env:TEMPapplocker.xml") Set-AppLockerPolicy -XmlPolicy "$env:TEMPapplocker.xml" Remove-Item "$env:TEMPapplocker.xml" } $script:DisabledWinRun = $true $failedUsers = @() # Loop through each profile on the machine Foreach ($UserProfile in $UserProfiles) { # Load User ntuser.dat if it's not already loaded If (($ProfileWasLoaded = Test-Path Registry::HKEY_USERS$($UserProfile.SID)) -eq $false) { Start-Process -FilePath "cmd.exe" -ArgumentList "/C reg.exe LOAD HKU$($UserProfile.SID) `"$($UserProfile.UserHive)`"" -Wait -WindowStyle Hidden } # Manipulate the registry $key = "Registry::HKEY_USERS$($UserProfile.SID)$($Path)" Set-HKProperty -Path $key -Name $Name -Value $Value -PropertyType DWord if ($(Get-ItemProperty -Path $key -Name $Name -ErrorAction Ignore).$Name -ne $Value) { $script:DisabledWinRun = $false $failedUsers += $UserProfile.UserName } # Unload NTuser.dat If ($ProfileWasLoaded -eq $false) { [gc]::Collect() Start-Sleep 1 Start-Process -FilePath "cmd.exe" -ArgumentList "/C reg.exe UNLOAD HKU$($UserProfile.SID)" -Wait -WindowStyle Hidden | Out-Null } } Start-Sleep -Seconds 30 if ($script:DisabledWinRun) { # All $UserProfiles updated exit 0 } else { $failedUsers | ForEach-Object { Write-Error "Failed to update user `"$_`"" } Write-Error "One or more user profiles failed to update" exit 1 } } end {}
|
#Requires -Version 5.1 <# .SYNOPSIS Enables the Windows Store for all users and newly created users. .DESCRIPTION Enables the Windows Store for all users and newly created users. No parameters needed Enables the Windows Store for all users and newly created users. .EXAMPLE (No Parameters) Enables the Windows Store for all users and newly created users. .OUTPUTS None .NOTES Minimum OS Architecture Supported: Windows 10, Server 2016 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 () begin { function Test-IsElevated { $id = [System.Security.Principal.WindowsIdentity]::GetCurrent() $p = New-Object System.Security.Principal.WindowsPrincipal($id) $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator) } function Test-IsSystem { $id = [System.Security.Principal.WindowsIdentity]::GetCurrent() return $id.Name -like "NT AUTHORITY*" -or $id.IsSystem } if (!(Test-IsElevated) -and !(Test-IsSystem)) { Write-Error -Message "Access Denied. Please run with Administrator privileges." exit 1 } # Setting up some functions to be used later. function Set-HKProperty { 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)" } } # This will get all the registry path's for all actual users (not system or network service account but actual users.) 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 patter 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 users registry hive. So we grab it if their account sid matches the above pattern. $UserProfiles = Foreach ($Pattern in $Patterns) { Get-ItemProperty "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionProfileList*" | Where-Object { $_.PSChildName -match $Pattern } | Select-Object @{Name = "SID"; Expression = { $_.PSChildName } }, @{Name = "UserHive"; Expression = { "$($_.ProfileImagePath)NTuser.dat" } }, @{Name = "UserName"; Expression = { "$($_.ProfileImagePath | Split-Path -Leaf)" } } } # There are some situations where grabbing the .Default user's info is needed. switch ($IncludeDefault) { $True { $DefaultProfile = "" | Select-Object UserName, SID, UserHive $DefaultProfile.UserName = "Default" $DefaultProfile.SID = "DefaultProfile" $DefaultProfile.Userhive = "$env:SystemDriveUsersDefaultNTUSER.DAT" # It was easier to write-output twice than combine the two objects. $DefaultProfile | Where-Object { $ExcludedUsers -notcontains $_.UserName } | Write-Output } } $UserProfiles | Where-Object { $ExcludedUsers -notcontains $_.UserName } | Write-Output } } process { $Path = "SoftwarePoliciesMicrosoftWindowsStore" $Name = "RemoveWindowsStore" $Value = 0 # Get each user profile SID and Path to the profile. If there are any exclusions we'll have to take them into account. $UserProfiles = Get-UserHives -IncludeDefault # If the Disable-WindowsStore script was used we'll need to check applocker [xml]$AppLockerXML = Get-AppLockerPolicy -Local -Xml if ($AppLockerXML.AppLockerPolicy.RuleCollection.FilePublisherRule) { $AppLockerXML.AppLockerPolicy.RuleCollection.FilePublisherRule | ForEach-Object { if (($_.Action -eq "Deny") -and ($_.Conditions.FilePublisherCondition.ProductName -like "*Microsoft.WindowsStore*")) { Write-Warning "Removing AppLocker file publishing rules for the Windows Store!" [Void]$_.ParentNode.RemoveChild($_) } } if($AppLockerXML.AppLockerPolicy.RuleCollection.FilePublisherRule.id.Count -eq "1" -and $AppLockerXML.AppLockerPolicy.RuleCollection.FilePublisherRule.Name -eq "(Default Rule) All signed packaged apps"){ $AppLockerXML.AppLockerPolicy.RuleCollection.FilePublisherRule | ForEach-Object { if($_.ParentNode){ [Void]$_.ParentNode.RemoveChild($_) } } $AppLockerXML.AppLockerPolicy.RuleCollection | ForEach-Object { if($_.Type -eq "Appx"){ $_.EnforcementMode = "NotConfigured" } } } $AppLockerXML.Save("$env:TEMPapplocker.xml") Set-AppLockerPolicy -XmlPolicy "$env:TEMPapplocker.xml" Remove-Item "$env:TEMPapplocker.xml" } $script:DisabledWinRun = $true $failedUsers = @() # Loop through each profile on the machine Foreach ($UserProfile in $UserProfiles) { # Load User ntuser.dat if it's not already loaded If (($ProfileWasLoaded = Test-Path Registry::HKEY_USERS$($UserProfile.SID)) -eq $false) { Start-Process -FilePath "cmd.exe" -ArgumentList "/C reg.exe LOAD HKU$($UserProfile.SID) `"$($UserProfile.UserHive)`"" -Wait -WindowStyle Hidden } # Manipulate the registry $key = "Registry::HKEY_USERS$($UserProfile.SID)$($Path)" Set-HKProperty -Path $key -Name $Name -Value $Value -PropertyType DWord if ($(Get-ItemProperty -Path $key -Name $Name -ErrorAction Ignore).$Name -ne $Value) { $script:DisabledWinRun = $false $failedUsers += $UserProfile.UserName } # Unload NTuser.dat If ($ProfileWasLoaded -eq $false) { [gc]::Collect() Start-Sleep 1 Start-Process -FilePath "cmd.exe" -ArgumentList "/C reg.exe UNLOAD HKU$($UserProfile.SID)" -Wait -WindowStyle Hidden | Out-Null } } Start-Sleep -Seconds 30 if ($script:DisabledWinRun) { # All $UserProfiles updated exit 0 } else { $failedUsers | ForEach-Object { Write-Error "Failed to update user `"$_`"" } Write-Error "One or more user profiles failed to update" exit 1 } } end {}
Zugriff auf über 300 Skripte im NinjaOne Dojo
Detailansicht
Das Skript arbeitet in einer klaren Reihenfolge:
Initialisierung:
- Zwei Funktionen, Test-IsElevated und Test-IsSystem, prüfen, ob das Skript die erforderlichen Berechtigungen besitzt.
- Das Skript richtet dann eine weitere Funktion, Set-HKProperty, ein, um Registrierungsvorgänge zu erleichtern.
- Eine komplexere Funktion, Get-UserHives, ruft die Registrierungspfade für alle aktuellen Benutzer ab.
Prozess:
- Legt den Pfad, den Namen und den Wert für die Aktivierung des Windows Stores fest.
- Ruft Benutzerprofile ab und prüft, ob es App Locker-Regeln gibt, die den Zugriff auf den Windows Store verhindern könnten, und nimmt gegebenenfalls Änderungen vor.
- Durchläuft jedes Benutzerprofil und manipuliert die Registrierung, um sicherzustellen, dass der Windows Store aktiviert ist.
- Bestätigt den Erfolg der Operation.
Beendigung:
- Das Skript endet mit einer Statusrückmeldung.
Potenzielle Anwendungsfälle
Fallstudie: Stellen Sie sich vor, eine große Bildungseinrichtung migriert ihre Software-Infrastruktur. Sie haben sich vor kurzem in das Microsoft-Ökosystem integriert, mussten aber feststellen, dass der Windows Store für Studenten und Lehrkräfte unzugänglich ist. Anstatt Tausende von Profilen einzeln zu konfigurieren, kümmert sich unser Skript nahtlos und auf einen Schlag um das Problem und gewährleistet so den rechtzeitigen Zugang zu den erforderlichen Anwendungen für alle.
Vergleiche
Manuelle Konfigurationen oder der Einsatz separater Tools sind zwar möglich, können aber umständlich und fehleranfällig sein, vor allem in größerem Umfang. Dieses Skript automatisiert und optimiert den Prozess, wodurch die Wahrscheinlichkeit von Fehlern erheblich reduziert und gleichzeitig Zeit gespart wird.
FAQs
- Sind für die Ausführung dieses Skripts Administratorrechte erforderlich?
Ja, es erfordert administrative Rechte. - Funktioniert dieses Skript auch unter älteren Windows-Versionen?
Es ist für Windows 10 und Server 2016 aufwärts konzipiert. - Können bestimmte Benutzer ausgeschlossen werden?
Ja, Ausschlüsse können über die Parameter der Funktion Get-UserHives behandelt werden.
Auswirkungen
Das Skript vereinfacht zwar die Aktivierung des Windows Store erheblich, aber der unkontrollierte Zugriff kann dazu führen, dass Benutzer ungeprüfte Anwendungen verwenden. IT-Fachleute sollten für ein ausgewogenes Verhältnis zwischen Zugänglichkeit und Sicherheit sorgen und mögliche Schwachstellen berücksichtigen.
Empfehlungen
- Sichern Sie immer die aktuellen Einstellungen, bevor Sie solche Skripte einsetzen.
- Überprüfen Sie regelmäßig die aktivierten Anwendungen im Windows Store, um sicherzustellen, dass sie den Unternehmensrichtlinien entsprechen.
- Klären Sie die Benutzer regelmäßig über sichere Anwendungspraktiken auf.
Abschließende Überlegungen
NinjaOne ergänzt mit seinem ganzheitlichen IT-Ansatz Tools wie dieses Skript und bietet eine optimierte Verwaltung und einen umfassenderen Überblick. Durch die Integration beider Systeme können IT-Experten nicht nur den Microsoft Store nahtlos aktivieren, sondern auch seine optimale und sichere Nutzung gewährleisten.