{"id":811710,"date":"2026-05-25T06:59:44","date_gmt":"2026-05-25T06:59:44","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=811710"},"modified":"2026-05-25T06:59:44","modified_gmt":"2026-05-25T06:59:44","slug":"how-to-mount-and-unmount-iso-files-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/pt-br\/script-hub\/how-to-mount-and-unmount-iso-files-powershell\/","title":{"rendered":"Como montar e desmontar dinamicamente arquivos ISO usando o PowerShell"},"content":{"rendered":"<p>Nesta postagem, forneceremos um script do PowerShell que os administradores de TI podem usar para <strong>montar e desmontar arquivos ISO<\/strong> dinamicamente.<\/p>\n<h2>Hist\u00f3rico<\/h2>\n<p>Os arquivos ISO, essencialmente uma c\u00f3pia completa de um disco em formato digital, s\u00e3o amplamente usados para distribuir software<a href=\"https:\/\/thedfirreport.com\/2023\/04\/03\/malicious-iso-file-leads-to-domain-wide-ransomware\/\" target=\"_blank\" rel=\"noopener\">(incluindo malware, infelizmente<\/a>). Os profissionais de TI e <a href=\"https:\/\/www.ninjaone.com\/what-is-an-msp\/\">os provedores de servi\u00e7os gerenciados (MSPs)<\/a> podem preferir bloquear a montagem de arquivos ISO em geral, ou podem\u00a0se deparar com a necessidade de ativar ou desativar a montagem dessas imagens ISO dinamicamente, especialmente em sistemas corporativos. Esse script do PowerShell ajuda a controlar esse recurso com precis\u00e3o, garantindo que a seguran\u00e7a e a ades\u00e3o \u00e0 pol\u00edtica sejam cumpridas com eleg\u00e2ncia.<\/p>\n<h2>O roteiro<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Enables or disables the mounting of ISO images.\r\n.DESCRIPTION\r\n    Enables or disables the mounting of ISO images.\r\n.EXAMPLE\r\n     -Enable\r\n    Enables mounting of ISO images.\r\n.EXAMPLE\r\n     -Disable\r\n    Disables mounting of ISO images.\r\n.OUTPUTS\r\n    None\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Windows 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    [switch]\r\n    $Enable,\r\n    [Parameter()]\r\n    [switch]\r\n    $Disable\r\n)\r\n\r\nbegin {\r\n    function Set-ItemProp {\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        # Do not output errors and continue\r\n        $ErrorActionPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue\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)) {\r\n            # Update property and print out what it was changed from and changed to\r\n            $CurrentValue = Get-ItemProperty -Path $Path -Name $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 $_\r\n            }\r\n            Write-Host \"$Path$Name changed from $CurrentValue to $(Get-ItemProperty -Path $Path -Name $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 $_\r\n            }\r\n            Write-Host \"Set $Path$Name to $(Get-ItemProperty -Path $Path -Name $Name)\"\r\n        }\r\n        $ErrorActionPreference = [System.Management.Automation.ActionPreference]::Continue\r\n    }\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\nprocess {\r\n    if (-not (Test-IsElevated)) {\r\n        Write-Error -Message \"Access Denied. Please run with Administrator privileges.\"\r\n        exit 1\r\n    }\r\n\r\n    if ($env:Action -like \"Enable\") {\r\n        $Enable = $true\r\n    }\r\n    elseif ($env:Action -like \"Disable\") {\r\n        $Disable = $true\r\n    }\r\n\r\n    # Use a unique number that isn't likely to be used\r\n    # \"ninja\" to something close to a number plus 1 at the end: \"41470\" + \"1\"\r\n    $GroupName = \"414701\"\r\n\r\n    # Mount HKEY_CLASSES_ROOT as HKCR: for the current session\r\n    New-PSDrive -PSProvider registry -Root HKEY_CLASSES_ROOT -Name HKCR\r\n\r\n    if ($Enable -and $Disable) {\r\n        Write-Error \"Both Enable and Disable can not be used at the same time.\"\r\n        exit 1\r\n    }\r\n    elseif ($Enable) {\r\n        # Enables the use of ISO mounting by removing registry settings\r\n\r\n        # ErrorAction set to SilentlyContinue for when the registry settings don't exist\r\n        Remove-ItemProperty -Path \"HKLM:SOFTWAREPoliciesMicrosoftWindowsDeviceInstallRestrictionsDenyDeviceIDs\" -Name \"$GroupName\" -ErrorAction SilentlyContinue\r\n        Write-Host \"Removed $GroupName from HKLM:SOFTWAREPoliciesMicrosoftWindowsDeviceInstallRestrictionsDenyDeviceIDs\"\r\n\r\n        Remove-ItemProperty -Path \"HKLM:SOFTWAREPoliciesMicrosoftWindowsDeviceInstallRestrictions\" -Name \"DenyDeviceIDsRetroactive\" -ErrorAction SilentlyContinue\r\n        Write-Host \"Removed DenyDeviceIDsRetroactive from HKLM:SOFTWAREPoliciesMicrosoftWindowsDeviceInstallRestrictionsDenyDeviceIDs\"\r\n\r\n        Remove-ItemProperty -Path \"HKCR:Windows.IsoFileshellmount\" -Name \"ProgrammaticAccessOnly\" -ErrorAction SilentlyContinue\r\n        Write-Host \"Removed ProgrammaticAccessOnly from HKCR:Windows.IsoFileshellmount\"\r\n    }\r\n    elseif ($Disable) {\r\n        # Disables the use of ISO mounting by creating registry settings\r\n\r\n        Set-ItemProp -Path \"HKLM:SOFTWAREPoliciesMicrosoftWindowsDeviceInstallRestrictionsDenyDeviceIDs\" -Name \"$GroupName\" -Value \"SCSICdRomMsft____Virtual_DVD-ROM_\" -PropertyType String\r\n        Set-ItemProp -Path \"HKLM:SOFTWAREPoliciesMicrosoftWindowsDeviceInstallRestrictions\" -Name \"DenyDeviceIDsRetroactive\" -Value \"1\" -PropertyType DWord\r\n        Set-ItemProp -Path \"HKCR:Windows.IsoFileshellmount\" -Name \"ProgrammaticAccessOnly\" -Value \"\" -PropertyType String\r\n    }\r\n    else {\r\n        Write-Error \"Enable or Disable is required.\"\r\n        exit 1\r\n    }\r\n    Write-Host \"Any logged in users will need to log out and back in for changes to take effect.\"\r\n}\r\nend {\r\n    $ScriptVariables = @(\r\n        [PSCustomObject]@{\r\n            name           = \"Action\"\r\n            calculatedName = \"action\"\r\n            required       = $true\r\n            defaultValue   = [PSCustomObject]@{\r\n                type  = \"TEXT\"\r\n                value = \"Disable\"\r\n            }\r\n            valueType      = \"DROPDOWN\"\r\n            valueList      = @(\r\n                [PSCustomObject]@{\r\n                    type  = \"UNDEFINED\"\r\n                    value = \"Disable\"\r\n                },\r\n                [PSCustomObject]@{\r\n                    type  = \"UNDEFINED\"\r\n                    value = \"Enable\"\r\n                }\r\n            )\r\n            description    = \"Used to enable or disable the mounting of ISO images.\"\r\n        }\r\n    )\r\n}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p style=\"text-align: center;\">Acesse mais de 300 scripts no NinjaOne Dojo<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.ninjaone.com\/freetrialform\/\">Obter acesso<\/a><\/p>\n<\/div>\n<h2>Detalhamento<\/h2>\n<p>O script fornecido foi projetado para alternar o recurso de montagem de imagens ISO. Vamos dissecar seus componentes:<\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Par\u00e2metros<\/strong>: O script aceita duas op\u00e7\u00f5es: <strong>$Enable<\/strong> e <strong>$Disable<\/strong>. Eles determinam o comportamento do script, ativando ou desativando a montagem do ISO.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Fun\u00e7\u00e3o Set-ItemProp<\/strong>: Essa fun\u00e7\u00e3o interna lida com a cria\u00e7\u00e3o ou modifica\u00e7\u00e3o de uma propriedade de registro. Ele atende a diferentes tipos de propriedades, garantindo flexibilidade no gerenciamento das chaves do Registro do Windows.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Fun\u00e7\u00e3o Test-IsElevated<\/strong>: Verifica se o script \u00e9 executado com privil\u00e9gios administrativos. Isso garante que as altera\u00e7\u00f5es sejam aplicadas em todo o sistema e n\u00e3o se limitem \u00e0 sess\u00e3o do usu\u00e1rio.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Bloco de processo<\/strong>: O cora\u00e7\u00e3o do roteiro. Aqui reside a l\u00f3gica:<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\">Verifica os direitos administrativos.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\">Determina a a\u00e7\u00e3o com base nos par\u00e2metros ou vari\u00e1veis de ambiente fornecidos.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\">Remove (ativa\u00e7\u00e3o) ou define (desativa\u00e7\u00e3o) chaves de registro espec\u00edficas para controlar o recurso de montagem de ISO.<\/li>\n<\/ul>\n<h2>Casos de uso em potencial<\/h2>\n<p>Considere um estudo de caso: O departamento de TI da Acme Corp envia uma atualiza\u00e7\u00e3o de software por meio de arquivos ISO para todos os sistemas dos funcion\u00e1rios. Ap\u00f3s a conclus\u00e3o da atualiza\u00e7\u00e3o, eles pretendem desativar temporariamente o recurso de montagem de ISO. Ao implementar esse script em toda a empresa, eles podem controlar essa funcionalidade, garantindo que ISOs n\u00e3o oficiais ou n\u00e3o sancionadas n\u00e3o sejam montadas por usu\u00e1rios curiosos.<\/p>\n<h2>Compara\u00e7\u00f5es<\/h2>\n<p>Embora a interven\u00e7\u00e3o manual ou as ferramentas baseadas em GUI possam gerenciar as permiss\u00f5es de montagem ISO, elas s\u00e3o ineficientes para opera\u00e7\u00f5es em grande escala. Nosso script oferece um m\u00e9todo automatizado, sem complica\u00e7\u00f5es e robusto quando comparado a processos manuais demorados.<\/p>\n<h2>Implica\u00e7\u00f5es<\/h2>\n<p>O gerenciamento da capacidade de montar arquivos ISO pode ter profundas implica\u00e7\u00f5es de seguran\u00e7a. ISOs n\u00e3o autorizadas podem introduzir malware ou software indesejado. Com o controle desse recurso, os departamentos de TI podem garantir que somente ISOs sancionadas sejam montadas, reduzindo as poss\u00edveis amea\u00e7as.<\/p>\n<h2>Recomenda\u00e7\u00f5es<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\">Sempre fa\u00e7a backup das configura\u00e7\u00f5es do registro antes de fazer altera\u00e7\u00f5es.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\">Teste o script em um ambiente controlado antes da implementa\u00e7\u00e3o em toda a empresa.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\">Monitore os comportamentos do sistema ap\u00f3s a implanta\u00e7\u00e3o para identificar quaisquer resultados inesperados.<\/li>\n<\/ul>\n<h2>Considera\u00e7\u00f5es finais<\/h2>\n<p>Para plataformas como a <a href=\"https:\/\/www.ninjaone.com\/pt-br\/\">NinjaOne<\/a>, que atende a <a href=\"https:\/\/www.ninjaone.com\/pt-br\/rmm\/software-de-gerenciamento-de-operacoes-de-ti\/\">opera\u00e7\u00f5es e gerenciamento de TI<\/a>, scripts como esses s\u00e3o inestim\u00e1veis. Eles demonstram a versatilidade e o alinhamento da plataforma com as necessidades contempor\u00e2neas de TI. Ao utilizar essas ferramentas, os profissionais de TI podem aproveitar todo o potencial do PowerShell, tornando o gerenciamento do sistema eficiente e seguro.<\/p>\n","protected":false},"author":35,"featured_media":144836,"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":[12460],"class_list":["post-811710","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/script_hub\/811710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/comments?post=811710"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media\/144836"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media?parent=811710"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/operating_system?post=811710"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/use_cases?post=811710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}