{"id":849553,"date":"2026-08-04T14:26:15","date_gmt":"2026-08-04T14:26:15","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=849553"},"modified":"2026-08-04T14:26:15","modified_gmt":"2026-08-04T14:26:15","slug":"desactivar-microsoft-store-en-tu-red","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/es\/script-hub\/desactivar-microsoft-store-en-tu-red\/","title":{"rendered":"Automatizaci\u00f3n de TI: un script para deshabilitar Microsoft Store en toda tu red"},"content":{"rendered":"<p>Gestionar los permisos de los usuarios y el acceso a las aplicaciones en una red empresarial puede ser una tarea laboriosa. Sin embargo, los scripts que automatizan estas tareas pueden ser de gran ayuda para los profesionales de TI y los <a href=\"https:\/\/www.ninjaone.com\/es\/msp\/que-es-un-msp\/\">proveedores de servicios gestionados (MSP)<\/a>. Hoy nos centraremos en un <strong>script de PowerShell dise\u00f1ado para deshabilitar Microsoft Store<\/strong> para todos los usuarios, incluidos los que se creen posteriormente, mediante <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/security\/application-security\/application-control\/windows-defender-application-control\/applocker\/applocker-overview\" target=\"_blank\" rel=\"noopener\">AppLocker<\/a>. Este script est\u00e1 dise\u00f1ado para Windows 10 y Windows Server 2016 y ofrece varias opciones configurables, como excluir a usuarios concretos o aplicarlo \u00fanicamente a los usuarios existentes.<\/p>\n<p>En este art\u00edculo analizaremos los distintos aspectos del script y explicaremos por qu\u00e9 puede convertirse en una herramienta muy valiosa para tu equipo de TI.<\/p>\n<h2>El script<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Disables the Windows Store for all users and newly created users using AppLocker. Can be given a comma separated list\r\n    of users to exclude.\r\n.DESCRIPTION\r\n    Disables the Windows Store for all users and newly created users using AppLocker. Can be given a comma separated list\r\n    of users to exclude.\r\n.EXAMPLE\r\n    (No Parameters)\r\n    \r\n    WARNING: Creating AppLocker rule for user or group \"Interactive\"...\r\n    Registry::HKEY_USERSDefaultProfileSoftwarePoliciesMicrosoftWindowsStoreRemoveWindowsStore changed from 0 to 1\r\n    Registry::HKEY_USERSS-1-5-21-3870645062-3653562310-3850680542-1001SoftwarePoliciesMicrosoftWindowsStoreRemoveWindowsStore changed from 0 to 1\r\n    Registry::HKEY_USERSS-1-5-21-3870645062-3653562310-3850680542-1002SoftwarePoliciesMicrosoftWindowsStoreRemoveWindowsStore changed from 0 to 1\r\n\r\nPARAMETER: -ExcludeUsers \"Test1,Test2\"\r\n    A comma seperated list of users to exclude. Please note newly created users will not have the windows store disabled.\r\n.EXAMPLE\r\n    -ExcludeUsers \"Test1,Test2\"\r\n\r\n    WARNING: The Following Users and newly created users will not have the windows store disabled. Test1 Test2\r\n    Registry::HKEY_USERSS-1-5-21-3870645062-3653562310-3850680542-1002SoftwarePoliciesMicrosoftWindowsStoreRemoveWindowsStore changed from 0 to 1\r\n    WARNING: Creating AppLocker rule for user or group \"tuser\"...\r\n\r\nPARAMETER: -ExistingUsersOnly\r\n    This will disable the Windows store for existing users only.\r\n.EXAMPLE\r\n    -ExistingUsersOnly\r\n\r\n    WARNING: Only existing users will have the windows store disabled!\r\n    Set Registry::HKEY_USERSS-1-5-21-3870645062-3653562310-3850680542-1001SoftwarePoliciesMicrosoftWindowsStoreRemoveWindowsStore to 1\r\n    WARNING: Creating AppLocker rule for user or group \"kbohlander\"...\r\n    Set Registry::HKEY_USERSS-1-5-21-3870645062-3653562310-3850680542-1002SoftwarePoliciesMicrosoftWindowsStoreRemoveWindowsStore to 1\r\n    WARNING: Creating AppLocker rule for user or group \"tuser\"...\r\n.OUTPUTS\r\n    None\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Server 2016\r\n    Release Notes:\r\n    Initial Release\r\nBy 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.\r\n    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. \r\n    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. \r\n    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. \r\n    Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, 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. \r\n    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. \r\n    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. \r\n    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n#&gt;\r\n\r\n[CmdletBinding()]\r\nparam (\r\n    [Parameter()]\r\n    [String[]]$ExcludeUsers,\r\n    [Parameter()]\r\n    [Switch]$ExistingUsersOnly\r\n)\r\n\r\nbegin {\r\n    function Test-IsElevated {\r\n        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n        $p = New-Object System.Security.Principal.WindowsPrincipal($id)\r\n        $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)\r\n    }\r\n\r\n    function Test-IsSystem {\r\n        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n        return $id.Name -like \"NT AUTHORITY*\" -or $id.IsSystem\r\n    }\r\n\r\n    if (!(Test-IsElevated) -and !(Test-IsSystem)) {\r\n        Write-Error -Message \"Access Denied. Please run with Administrator privileges.\"\r\n        exit 1\r\n    }\r\n    \r\n    # Setting up some functions to be used later.\r\n    function Set-HKProperty {\r\n        param (\r\n            $Path,\r\n            $Name,\r\n            $Value,\r\n            [ValidateSet('DWord', 'QWord', 'String', 'ExpandedString', 'Binary', 'MultiString', 'Unknown')]\r\n            $PropertyType = 'DWord'\r\n        )\r\n        if (-not $(Test-Path -Path $Path)) {\r\n            # Check if path does not exist and create the path\r\n            New-Item -Path $Path -Force | Out-Null\r\n        }\r\n        if ((Get-ItemProperty -Path $Path -Name $Name -ErrorAction Ignore)) {\r\n            # Update property and print out what it was changed from and changed to\r\n            $CurrentValue = (Get-ItemProperty -Path $Path -Name $Name -ErrorAction Ignore).$Name\r\n            try {\r\n                Set-ItemProperty -Path $Path -Name $Name -Value $Value -Force -Confirm:$false -ErrorAction Stop | Out-Null\r\n            }\r\n            catch {\r\n                Write-Error \"[Error] Unable to Set registry key for $Name please see below error!\"\r\n                Write-Error $_\r\n                exit 1\r\n            }\r\n            Write-Host \"$Path$Name changed from $CurrentValue to $($(Get-ItemProperty -Path $Path -Name $Name -ErrorAction Ignore).$Name)\"\r\n        }\r\n        else {\r\n            # Create property with value\r\n            try {\r\n                New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force -Confirm:$false -ErrorAction Stop | Out-Null\r\n            }\r\n            catch {\r\n                Write-Error \"[Error] Unable to Set registry key for $Name please see below error!\"\r\n                Write-Error $_\r\n                exit 1\r\n            }\r\n            Write-Host \"Set $Path$Name to $($(Get-ItemProperty -Path $Path -Name $Name -ErrorAction Ignore).$Name)\"\r\n        }\r\n    }\r\n\r\n    # This will get all the registry path's for all actual users (not system or network service account but actual users.)\r\n    function Get-UserHives {\r\n        param (\r\n            [Parameter()]\r\n            [ValidateSet('AzureAD', 'DomainAndLocal', 'All')]\r\n            [String]$Type = \"All\",\r\n            [Parameter()]\r\n            [String[]]$ExcludedUsers,\r\n            [Parameter()]\r\n            [switch]$IncludeDefault\r\n        )\r\n\r\n        # User account SID's follow a particular patter depending on if they're azure AD or a Domain account or a local \"workgroup\" account.\r\n        $Patterns = switch ($Type) {\r\n            \"AzureAD\" { \"S-1-12-1-(d+-?){4}$\" }\r\n            \"DomainAndLocal\" { \"S-1-5-21-(d+-?){4}$\" }\r\n            \"All\" { \"S-1-12-1-(d+-?){4}$\" ; \"S-1-5-21-(d+-?){4}$\" } \r\n        }\r\n\r\n        # 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. \r\n        $UserProfiles = Foreach ($Pattern in $Patterns) { \r\n            Get-ItemProperty \"HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionProfileList*\" |\r\n                Where-Object { $_.PSChildName -match $Pattern } | \r\n                Select-Object @{Name = \"SID\"; Expression = { $_.PSChildName } }, \r\n                @{Name = \"UserHive\"; Expression = { \"$($_.ProfileImagePath)NTuser.dat\" } }, \r\n                @{Name = \"UserName\"; Expression = { \"$($_.ProfileImagePath | Split-Path -Leaf)\" } }\r\n        }\r\n\r\n        # There are some situations where grabbing the .Default user's info is needed.\r\n        switch ($IncludeDefault) {\r\n            $True {\r\n                $DefaultProfile = \"\" | Select-Object UserName, SID, UserHive\r\n                $DefaultProfile.UserName = \"Default\"\r\n                $DefaultProfile.SID = \"DefaultProfile\"\r\n                $DefaultProfile.Userhive = \"$env:SystemDriveUsersDefaultNTUSER.DAT\"\r\n                $DefaultProfile | Where-Object { $ExcludedUsers -notcontains $_.UserName }\r\n            }\r\n        }\r\n\r\n        $UserProfiles | Where-Object { $ExcludedUsers -notcontains $_.UserName }\r\n    }\r\n\r\n    function New-WindowStoreBlock {\r\n        param(\r\n            [Parameter()]\r\n            [String]$User\r\n        )\r\n\r\n        Write-Warning \"Creating AppLocker rule for user or group `\"$User`\"...\"\r\n        [xml]$AppLockerTemplate = Get-AppXPackage -AllUsers -Name \"Microsoft.WindowsStore\" | Get-AppLockerFileInformation | New-AppLockerPolicy -User \"$User\" -Optimize -Xml\r\n        $AppLockerTemplate.AppLockerPolicy.RuleCollection.EnforcementMode = \"Enabled\"\r\n        $AppLockerTemplate.AppLockerPolicy.RuleCollection.FilePublisherRule.Action = \"Deny\"\r\n        $AppLockerTemplate.AppLockerPolicy.RuleCollection.FilePublisherRule.Conditions.FilePublisherCondition.BinaryVersionRange.LowSection = \"*\"\r\n        $AppLockerTemplate.Save(\"$env:TEMPapplocker.xml\")\r\n        Set-AppLockerPolicy -XmlPolicy \"$env:TEMPapplocker.xml\" -Merge\r\n        Remove-Item \"$env:TEMPapplocker.xml\"\r\n    }\r\n}\r\nprocess {\r\n    if ($env:ExistingUsersOnly) { $ExistingUsersOnly = $env:ExistingUsersOnly }\r\n    # This registry key only works sometimes. It's worth setting if its an older windows build or has an older version of the store installed.\r\n    $Path = \"SoftwarePoliciesMicrosoftWindowsStore\"\r\n    $Name = \"RemoveWindowsStore\"\r\n    $Value = 1\r\n    \r\n    # Get each user profile SID and Path to the profile. If there are any exclusions we'll have to take them into account.\r\n    if ($ExcludeUsers -or $env:ExcludeUsers -or $ExistingUsersOnly) {\r\n        if ($env:ExcludeUsers) {\r\n            $ToBeExcluded = @()\r\n            $ToBeExcluded += $env:ExcludeUsers.split(\",\").trim()\r\n        }\r\n\r\n        if ($ExcludeUsers) {\r\n            $ToBeExcluded = @()\r\n            $ToBeExcluded += $ExcludeUsers.split(\",\").trim()\r\n        }\r\n\r\n        if ($ToBeExcluded) { \r\n            Write-Warning \"The Following Users and newly created users will not have the windows store disabled. $ToBeExcluded\"\r\n            $UserProfiles = Get-UserHives -ExcludedUsers $ToBeExcluded \r\n        }\r\n        elseif ($ExistingUsersOnly) { \r\n            Write-Warning \"Only existing users will have the windows store disabled!\"\r\n            $UserProfiles = Get-UserHives \r\n        }\r\n    }\r\n    else {\r\n        $UserProfiles = Get-UserHives -IncludeDefault\r\n    }\r\n\r\n    [xml]$AppLockerXML = '&lt;AppLockerPolicy Version=\"1\"&gt;&lt;RuleCollection Type=\"Appx\" EnforcementMode=\"Enabled\"&gt;&lt;FilePublisherRule Id=\"a9e18c21-ff8f-43cf-b9fc-db40eed693ba\" Name=\"(Default Rule) All signed packaged apps\" Description=\"Allows members of the Everyone group to run packaged apps that are signed.\" UserOrGroupSid=\"S-1-1-0\" Action=\"Allow\"&gt;&lt;Conditions&gt;&lt;FilePublisherCondition PublisherName=\"*\" ProductName=\"*\" BinaryName=\"*\"&gt;&lt;BinaryVersionRange LowSection=\"0.0.0.0\" HighSection=\"*\" \/&gt;&lt;\/FilePublisherCondition&gt;&lt;\/Conditions&gt;&lt;\/FilePublisherRule&gt;&lt;\/RuleCollection&gt;&lt;\/AppLockerPolicy&gt;'\r\n    $AppLockerXML.Save(\"$env:TEMPapplocker.xml\")\r\n    Set-AppLockerPolicy -XmlPolicy \"$env:TEMPapplocker.xml\" -Merge\r\n    Remove-Item \"$env:TEMPapplocker.xml\"\r\n\r\n    if (!$ToBeExcluded -and !$ExistingUsersOnly) {\r\n        New-WindowStoreBlock -User \"Interactive\"\r\n    }\r\n\r\n    $script:DisabledWinRun = $true\r\n    $failedUsers = @()\r\n    # Loop through each profile on the machine\r\n    Foreach ($UserProfile in $UserProfiles) {\r\n        # Load User ntuser.dat if it's not already loaded\r\n        If (($ProfileWasLoaded = Test-Path Registry::HKEY_USERS$($UserProfile.SID)) -eq $false) {\r\n            Start-Process -FilePath \"cmd.exe\" -ArgumentList \"\/C reg.exe LOAD HKU$($UserProfile.SID) `\"$($UserProfile.UserHive)`\"\" -Wait -WindowStyle Hidden\r\n        }\r\n\r\n        # Manipulate the registry\r\n        $key = \"Registry::HKEY_USERS$($UserProfile.SID)$($Path)\"\r\n        Set-HKProperty -Path $key -Name $Name -Value $Value -PropertyType DWord\r\n\r\n        # This will be our applocker policy we'll need to tweak it prior to running it\r\n        if ($UserProfile.SID -notlike \"DefaultProfile\") {\r\n            if ($ToBeExcluded -or $ExistingUsersOnly) {\r\n                New-WindowStoreBlock -User \"$($UserProfile.UserName)\"\r\n            }\r\n        }\r\n\r\n        if ($(Get-ItemProperty -Path $key -Name $Name -ErrorAction Ignore).$Name -ne $Value) {\r\n            $script:DisabledWinRun = $false\r\n            $failedUsers += $UserProfile.UserName\r\n        }\r\n        \r\n        # Unload NTuser.dat\r\n        If ($ProfileWasLoaded -eq $false) {\r\n            [gc]::Collect()\r\n            Start-Sleep 1\r\n            Start-Process -FilePath \"cmd.exe\" -ArgumentList \"\/C reg.exe UNLOAD HKU$($UserProfile.SID)\" -Wait -WindowStyle Hidden | Out-Null\r\n        }\r\n    }\r\n    \r\n    Start-Process -FilePath \"cmd.exe\" -ArgumentList \"\/C sc config `\"AppIDSvc`\" start=auto &amp; net start `\"AppIDSvc`\"\" -WindowStyle Hidden | Out-Null\r\n    Start-Sleep -Seconds 30\r\n    if ($script:DisabledWinRun) {\r\n        # All $UserProfiles updated\r\n        exit 0\r\n    }\r\n    else {\r\n        $failedUsers | ForEach-Object { Write-Error \"Failed to update user `\"$_`\"\" }\r\n        Write-Error \"One or more user profiles failed to update\"\r\n        exit 1\r\n    }\r\n}\r\nend {}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>Accede a m\u00e1s de 300 scripts en el Dojo de NinjaOne<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/freetrialform\/\">Obt\u00e9n acceso<\/a><\/p>\n<\/div>\n<h2>Principales caracter\u00edsticas del script<\/h2>\n<h3>Comprobaci\u00f3n de permisos elevados<\/h3>\n<p>Antes de realizar cambios, el script comprueba si se est\u00e1 ejecutando con permisos de administrador. Esto es esencial para aplicar cambios en la configuraci\u00f3n del sistema y en las cuentas de usuario.<\/p>\n<h3>Flexibilidad en la exclusi\u00f3n de usuarios<\/h3>\n<p>Si no quieres aplicar la configuraci\u00f3n a todos los usuarios, tienes la opci\u00f3n de especificar una lista separada por comas de los usuarios que quieres excluir.<\/p>\n<h3>Opci\u00f3n solo para usuarios existentes<\/h3>\n<p>Si prefieres que no afecte a las cuentas reci\u00e9n creadas, tambi\u00e9n hay un par\u00e1metro para ello.<\/p>\n<h3>Modificaci\u00f3n del Registro<\/h3>\n<p>El script utiliza el <a href=\"https:\/\/www.ninjaone.com\/es\/blog\/registro-de-windows\/\" target=\"_blank\" rel=\"noopener\">Registro de Windows<\/a> para aplicar los cambios de directiva de forma persistente, de modo que se mantengan tras los reinicios del sistema.<\/p>\n<h3>Integraci\u00f3n de AppLocker<\/h3>\n<p>El script no se limita a modificar el Registro: tambi\u00e9n crea una regla de AppLocker para bloquear Microsoft Store y a\u00f1adir as\u00ed una capa adicional de seguridad.<\/p>\n<h2>Qu\u00e9 ventajas tiene para los MSP<\/h2>\n<h3>Personalizaci\u00f3n espec\u00edfica para cada cliente<\/h3>\n<p>Gracias a la opci\u00f3n de excluir a usuarios espec\u00edficos, los MSP pueden adaptar el comportamiento del script en funci\u00f3n de las necesidades \u00fanicas de cada cliente.<\/p>\n<h3>Escalabilidad<\/h3>\n<p>Tanto si gestionas la red de una peque\u00f1a empresa como la de una multinacional, este script se adapta f\u00e1cilmente a cualquier escala gracias a sus funciones de automatizaci\u00f3n.<\/p>\n<h3>Cumplimiento<\/h3>\n<p>Muchos sectores est\u00e1n sujetos a estrictos requisitos de cumplimiento que limitan el uso de aplicaciones. Este script ayuda a cumplir esos requisitos al bloquear el acceso a aplicaciones no autorizadas de Microsoft Store.<\/p>\n<h3>Servicio de valor a\u00f1adido<\/h3>\n<p>Los MSP pueden incorporar este script a su paquete de seguridad y hacer as\u00ed que sus servicios resulten m\u00e1s atractivos para los clientes potenciales.<\/p>\n<h2>Conclusiones<\/h2>\n<p>La seguridad y el cumplimiento son dos caras de la misma moneda en la <a href=\"https:\/\/www.ninjaone.com\/es\/gestion-ti-empresarial\/\">gesti\u00f3n de TI<\/a>. Este script de PowerShell facilita ambos objetivos al automatizar la deshabilitaci\u00f3n de Microsoft Store en varias cuentas de usuario y ofrecer opciones personalizables para distintos casos de uso. <a href=\"https:\/\/www.ninjaone.com\/es\/eficiencia\/\">Tanto los profesionales de TI como los MSP pueden ahorrar mucho tiempo<\/a>, mejorar la seguridad y agilizar la gesti\u00f3n si incorporan este script a sus flujos de trabajo habituales.<\/p>\n","protected":false},"author":35,"featured_media":142132,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4212],"use_cases":[4267],"class_list":["post-849553","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/script_hub\/849553","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/comments?post=849553"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/media\/142132"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/media?parent=849553"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/operating_system?post=849553"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/use_cases?post=849553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}