{"id":353622,"date":"1970-01-01T00:00:00","date_gmt":"1970-01-01T00:00:00","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=353622"},"modified":"2024-10-29T08:43:57","modified_gmt":"2024-10-29T08:43:57","slug":"standardbrowser-mit-powershell-festlegen","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/de\/script-hub\/standardbrowser-mit-powershell-festlegen\/","title":{"rendered":"So legen Sie mit PowerShell einen Standardbrowser f\u00fcr alle Benutzer:innen fest &#8211; Ein Schritt-f\u00fcr-Schritt-Guide"},"content":{"rendered":"<p>Die Verwaltung des Standardbrowsers f\u00fcr mehrere Benutzerprofile auf einem Windows-System kann eine schwierige Aufgabe sein, insbesondere in Unternehmensumgebungen, in denen Konsistenz und Compliance entscheidend sind. Die Automatisierung dieses Prozesses mit einem <a href=\"https:\/\/www.ninjaone.com\/it-hub\/endpoint-management\/what-is-powershell\/\" target=\"_blank\" rel=\"noopener\">PowerShell-Skript<\/a> vereinfacht die Aufgabe und stellt sicher, dass alle Benutzer:innen auf dem System denselben Browser verwenden.<\/p>\n<p>In diesem Blogbeitrag wird\u00a0<strong>ein PowerShell-Skript vorgestellt, mit dem der Standardbrowser f\u00fcr alle Benutzer:innen<\/strong> auf einem Windows-Computer\u00a0<strong>festgelegt werden kann<\/strong>. Damit steht IT-Experten und <a href=\"https:\/\/www.ninjaone.com\/de\/was-ist-ein-msp\" target=\"_blank\" rel=\"noopener\">Managed Service Providern (MSPs)<\/a> ein leistungsstarkes Tool zur Verf\u00fcgung, mit dem sie die Kontrolle \u00fcber ihre Umgebungen behalten.<\/p>\n<h2>Kontext<\/h2>\n<p>In einer IT-Umgebung, insbesondere in Unternehmen oder bei MSPs, ist die Aufrechterhaltung einer konsistenten Benutzererfahrung entscheidend. Bei mehreren Benutzer:innen auf einem einzigen Rechner oder in einem Netzwerk kann die manuelle Einstellung des Standardbrowsers f\u00fcr jedes Profil arbeitsintensiv und fehleranf\u00e4llig sein. Ein PowerShell-Skript, das diesen Prozess automatisiert, spart nicht nur Zeit, sondern sorgt auch f\u00fcr Einheitlichkeit, was f\u00fcr die Compliance und den Benutzersupport entscheidend sein kann.<\/p>\n<p>Bei diesem Skript handelt es sich um eine modifizierte Version eines Skripts von Danysys, das dazu dient, den Standardbrowser f\u00fcr alle Benutzer:innen durch Aktualisierung der Registrierungsschl\u00fcssel zu \u00e4ndern. Das Skript ist sehr anpassungsf\u00e4hig und unterst\u00fctzt g\u00e4ngige Browser wie Mozilla Firefox, Google Chrome und Microsoft Edge. Durch den Einsatz des Skripts k\u00f6nnen IT-Administratoren sicherstellen, dass alle Benutzer:innen den richtigen Browser als Standard eingestellt haben, unabh\u00e4ngig von der Anzahl der Profile oder dem Zustand des Systems.<\/p>\n<h2>Das Skript:<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Sets the default browser for all users.\r\n.DESCRIPTION\r\n    Sets the default browser for all users.\r\n.EXAMPLE\r\n    -Browser \"Mozilla Firefox\" -RestartExplorer\r\n\r\n    Setting default browser of Mozilla Firefox for Administrator.\r\n    Setting \r\n    Registry::HKEY_USERS\\S-1-5-21-528047445-1317477324-4168425688-500\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice\\Hash changed from 2q7+uVxu0\/A= to FKcuHm4FMN4=\r\n    Registry::HKEY_USERS\\S-1-5-21-528047445-1317477324-4168425688-500\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice\\ProgId changed from ChromeHTML to FirefoxURL-308046B0AF4A39CB\r\n    Setting \r\n    Registry::HKEY_USERS\\S-1-5-21-528047445-1317477324-4168425688-500\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\https\\UserChoice\\Hash changed from zR3ANZC6jVI= to clMyDtJdxck=\r\n    Registry::HKEY_USERS\\S-1-5-21-528047445-1317477324-4168425688-500\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\https\\UserChoice\\ProgId changed from ChromeHTML to FirefoxURL-308046B0AF4A39CB\r\n    Setting \r\n    Registry::HKEY_USERS\\S-1-5-21-528047445-1317477324-4168425688-500\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\htm\\UserChoice\\Hash changed from IQfza9L6Tfw= to t8+HFkmUAd0=\r\n    Registry::HKEY_USERS\\S-1-5-21-528047445-1317477324-4168425688-500\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\htm\\UserChoice\\ProgId changed from ChromeHTML to FirefoxHTML-308046B0AF4A39CB\r\n    Registry::HKEY_USERS\\S-1-5-21-528047445-1317477324-4168425688-500\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.htm\\UserChoice\\Hash changed from IQfza9L6Tfw= to t8+HFkmUAd0=\r\n    Registry::HKEY_USERS\\S-1-5-21-528047445-1317477324-4168425688-500\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.htm\\UserChoice\\ProgId changed from ChromeHTML to FirefoxHTML-308046B0AF4A39CB\r\n    Setting \r\n    Registry::HKEY_USERS\\S-1-5-21-528047445-1317477324-4168425688-500\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\html\\UserChoice\\Hash changed from 7CcRlkLW3ik= to q0Eix6jwLFg=\r\n    Registry::HKEY_USERS\\S-1-5-21-528047445-1317477324-4168425688-500\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\html\\UserChoice\\ProgId changed from ChromeHTML to FirefoxHTML-308046B0AF4A39CB\r\n    Registry::HKEY_USERS\\S-1-5-21-528047445-1317477324-4168425688-500\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.html\\UserChoice\\Hash changed from 7CcRlkLW3ik= to q0Eix6jwLFg=\r\n    Registry::HKEY_USERS\\S-1-5-21-528047445-1317477324-4168425688-500\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.html\\UserChoice\\ProgId changed from ChromeHTML to FirefoxHTML-308046B0AF4A39CB\r\n    Setting \r\n    Registry::HKEY_USERS\\S-1-5-21-528047445-1317477324-4168425688-500\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\xhtml\\UserChoice\\Hash changed from IC7TXk1anlM= to y2gIOuiaLb0=\r\n    Registry::HKEY_USERS\\S-1-5-21-528047445-1317477324-4168425688-500\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\xhtml\\UserChoice\\ProgId changed from ChromeHTML to FirefoxHTML-308046B0AF4A39CB\r\n    Registry::HKEY_USERS\\S-1-5-21-528047445-1317477324-4168425688-500\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.xhtml\\UserChoice\\Hash changed from IC7TXk1anlM= to y2gIOuiaLb0=\r\n    Registry::HKEY_USERS\\S-1-5-21-528047445-1317477324-4168425688-500\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.xhtml\\UserChoice\\ProgId changed from ChromeHTML to FirefoxHTML-308046B0AF4A39CB\r\n    Restarting Explorer.exe\r\n\r\nPARAMETER: -Browser \"Mozilla Firefox\"\r\n    Set the default browser to either \"Mozilla Firefox\", \"Google Chrome\" or \"Microsoft Edge\".\r\n\r\nPARAMETER: -Restart Explorer\r\n    Restarts Explorer.exe so that the desktop icons for .html files refresh immediately.\r\n    \r\nLICENSE:\r\n    Modified version from: https:\/\/github.com\/DanysysTeam\/PS-SFTA\/blob\/22a32292e576afc976a1167d92b50741ef523066\/SFTA.ps1\r\n    This script incorporates the `Get-HexDateTime` and `Get-Hash` functions from Danysys, without which it would not be possible.\r\n    \r\n    LICENSE: https:\/\/github.com\/DanysysTeam\/PS-SFTA\/blob\/22a32292e576afc976a1167d92b50741ef523066\/SFTA.ps1\r\n    MIT License\r\n    \r\n    Copyright (c) 2022 Danysys. &lt;danysys.com&gt;\r\n\r\n    Permission is hereby granted, free of charge, to any person obtaining a copy\r\n    of this software and associated documentation files (the \"Software\"), to deal\r\n    in the Software without restriction, including without limitation the rights\r\n    to use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\r\n    copies of the Software, and to permit persons to whom the Software is\r\n    furnished to do so, subject to the following conditions:\r\n\r\n    The above copyright notice and this permission notice shall be included in all\r\n    copies or substantial portions of the Software.\r\n\r\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n    SOFTWARE.\r\n\r\n.OUTPUTS\r\n    None\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10+\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]$Browser,\r\n    [Parameter()]\r\n    [Switch]$RestartExplorer = [System.Convert]::ToBoolean($env:restartExplorer)\r\n)\r\n\r\nbegin {\r\n    if ($env:browser -and $env:browser -notlike \"null\") {\r\n        $Browser = $env:browser\r\n    }\r\n\r\n    # If no browser is selected, terminate with an error message.\r\n    if (-not $Browser) {\r\n        Write-Host \"[Error] Please select at least one browser!\"\r\n        Exit 1\r\n    }\r\n\r\n    # Test if running as Administrator\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    # Test if running as System\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    function Get-HexDateTime {\r\n        # This function was created by DanySys at https:\/\/github.com\/DanysysTeam\/PS-SFTA\r\n        [OutputType([string])]\r\n    \r\n        $now = [DateTime]::Now\r\n        $dateTime = [DateTime]::New($now.Year, $now.Month, $now.Day, $now.Hour, $now.Minute, 0)\r\n        $fileTime = $dateTime.ToFileTime()\r\n        $hi = ($fileTime -shr 32)\r\n        $low = ($fileTime -band 0xFFFFFFFFL)\r\n        ($hi.ToString(\"X8\") + $low.ToString(\"X8\")).ToLower()\r\n    }\r\n\r\n    function Get-Hash {\r\n        # This function was created by DanySys at https:\/\/github.com\/DanysysTeam\/PS-SFTA\r\n        [CmdletBinding()]\r\n        param (\r\n            [Parameter( Position = 0, Mandatory = $True )]\r\n            [string]\r\n            $BaseInfo\r\n        )\r\n    \r\n        function local:Get-ShiftRight {\r\n            [CmdletBinding()]\r\n            param (\r\n                [Parameter( Position = 0, Mandatory = $true)]\r\n                [long] $iValue, \r\n                \r\n                [Parameter( Position = 1, Mandatory = $true)]\r\n                [int] $iCount \r\n            )\r\n        \r\n            if ($iValue -band 0x80000000) {\r\n                Write-Output (( $iValue -shr $iCount) -bxor 0xFFFF0000)\r\n            }\r\n            else {\r\n                Write-Output ($iValue -shr $iCount)\r\n            }\r\n        }\r\n    \r\n        function local:Get-Long {\r\n            [CmdletBinding()]\r\n            param (\r\n                [Parameter( Position = 0, Mandatory = $true)]\r\n                [byte[]] $Bytes,\r\n        \r\n                [Parameter( Position = 1)]\r\n                [int] $Index = 0\r\n            )\r\n        \r\n            Write-Output ([BitConverter]::ToInt32($Bytes, $Index))\r\n        }\r\n    \r\n        function local:Convert-Int32 {\r\n            param (\r\n                [Parameter( Position = 0, Mandatory = $true)]\r\n                [long] $Value\r\n            )\r\n        \r\n            [byte[]] $bytes = [BitConverter]::GetBytes($Value)\r\n            return [BitConverter]::ToInt32( $bytes, 0) \r\n        }\r\n    \r\n        [Byte[]] $bytesBaseInfo = [System.Text.Encoding]::Unicode.GetBytes($baseInfo) \r\n        $bytesBaseInfo += 0x00, 0x00  \r\n        \r\n        $MD5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider\r\n        [Byte[]] $bytesMD5 = $MD5.ComputeHash($bytesBaseInfo)\r\n        \r\n        $lengthBase = ($baseInfo.Length * 2) + 2 \r\n        $length = (($lengthBase -band 4) -le 1) + (Get-ShiftRight $lengthBase 2) - 1\r\n        $base64Hash = \"\"\r\n    \r\n        if ($length -gt 1) {\r\n        \r\n            $map = @{PDATA = 0; CACHE = 0; COUNTER = 0 ; INDEX = 0; MD51 = 0; MD52 = 0; OUTHASH1 = 0; OUTHASH2 = 0;\r\n                R0 = 0; R1 = @(0, 0); R2 = @(0, 0); R3 = 0; R4 = @(0, 0); R5 = @(0, 0); R6 = @(0, 0); R7 = @(0, 0)\r\n            }\r\n        \r\n            $map.CACHE = 0\r\n            $map.OUTHASH1 = 0\r\n            $map.PDATA = 0\r\n            $map.MD51 = (((Get-Long $bytesMD5) -bor 1) + 0x69FB0000L)\r\n            $map.MD52 = ((Get-Long $bytesMD5 4) -bor 1) + 0x13DB0000L\r\n            $map.INDEX = Get-ShiftRight ($length - 2) 1\r\n            $map.COUNTER = $map.INDEX + 1\r\n        \r\n            while ($map.COUNTER) {\r\n                $map.R0 = Convert-Int32 ((Get-Long $bytesBaseInfo $map.PDATA) + [long]$map.OUTHASH1)\r\n                $map.R1[0] = Convert-Int32 (Get-Long $bytesBaseInfo ($map.PDATA + 4))\r\n                $map.PDATA = $map.PDATA + 8\r\n                $map.R2[0] = Convert-Int32 (($map.R0 * ([long]$map.MD51)) - (0x10FA9605L * ((Get-ShiftRight $map.R0 16))))\r\n                $map.R2[1] = Convert-Int32 ((0x79F8A395L * ([long]$map.R2[0])) + (0x689B6B9FL * (Get-ShiftRight $map.R2[0] 16)))\r\n                $map.R3 = Convert-Int32 ((0xEA970001L * $map.R2[1]) - (0x3C101569L * (Get-ShiftRight $map.R2[1] 16) ))\r\n                $map.R4[0] = Convert-Int32 ($map.R3 + $map.R1[0])\r\n                $map.R5[0] = Convert-Int32 ($map.CACHE + $map.R3)\r\n                $map.R6[0] = Convert-Int32 (($map.R4[0] * [long]$map.MD52) - (0x3CE8EC25L * (Get-ShiftRight $map.R4[0] 16)))\r\n                $map.R6[1] = Convert-Int32 ((0x59C3AF2DL * $map.R6[0]) - (0x2232E0F1L * (Get-ShiftRight $map.R6[0] 16)))\r\n                $map.OUTHASH1 = Convert-Int32 ((0x1EC90001L * $map.R6[1]) + (0x35BD1EC9L * (Get-ShiftRight $map.R6[1] 16)))\r\n                $map.OUTHASH2 = Convert-Int32 ([long]$map.R5[0] + [long]$map.OUTHASH1)\r\n                $map.CACHE = ([long]$map.OUTHASH2)\r\n                $map.COUNTER = $map.COUNTER - 1\r\n            }\r\n    \r\n            [Byte[]] $outHash = @(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)\r\n            [byte[]] $buffer = [BitConverter]::GetBytes($map.OUTHASH1)\r\n            $buffer.CopyTo($outHash, 0)\r\n            $buffer = [BitConverter]::GetBytes($map.OUTHASH2)\r\n            $buffer.CopyTo($outHash, 4)\r\n        \r\n            $map = @{PDATA = 0; CACHE = 0; COUNTER = 0 ; INDEX = 0; MD51 = 0; MD52 = 0; OUTHASH1 = 0; OUTHASH2 = 0;\r\n                R0 = 0; R1 = @(0, 0); R2 = @(0, 0); R3 = 0; R4 = @(0, 0); R5 = @(0, 0); R6 = @(0, 0); R7 = @(0, 0)\r\n            }\r\n        \r\n            $map.CACHE = 0\r\n            $map.OUTHASH1 = 0\r\n            $map.PDATA = 0\r\n            $map.MD51 = ((Get-Long $bytesMD5) -bor 1)\r\n            $map.MD52 = ((Get-Long $bytesMD5 4) -bor 1)\r\n            $map.INDEX = Get-ShiftRight ($length - 2) 1\r\n            $map.COUNTER = $map.INDEX + 1\r\n    \r\n            while ($map.COUNTER) {\r\n                $map.R0 = Convert-Int32 ((Get-Long $bytesBaseInfo $map.PDATA) + ([long]$map.OUTHASH1))\r\n                $map.PDATA = $map.PDATA + 8\r\n                $map.R1[0] = Convert-Int32 ($map.R0 * [long]$map.MD51)\r\n                $map.R1[1] = Convert-Int32 ((0xB1110000L * $map.R1[0]) - (0x30674EEFL * (Get-ShiftRight $map.R1[0] 16)))\r\n                $map.R2[0] = Convert-Int32 ((0x5B9F0000L * $map.R1[1]) - (0x78F7A461L * (Get-ShiftRight $map.R1[1] 16)))\r\n                $map.R2[1] = Convert-Int32 ((0x12CEB96DL * (Get-ShiftRight $map.R2[0] 16)) - (0x46930000L * $map.R2[0]))\r\n                $map.R3 = Convert-Int32 ((0x1D830000L * $map.R2[1]) + (0x257E1D83L * (Get-ShiftRight $map.R2[1] 16)))\r\n                $map.R4[0] = Convert-Int32 ([long]$map.MD52 * ([long]$map.R3 + (Get-Long $bytesBaseInfo ($map.PDATA - 4))))\r\n                $map.R4[1] = Convert-Int32 ((0x16F50000L * $map.R4[0]) - (0x5D8BE90BL * (Get-ShiftRight $map.R4[0] 16)))\r\n                $map.R5[0] = Convert-Int32 ((0x96FF0000L * $map.R4[1]) - (0x2C7C6901L * (Get-ShiftRight $map.R4[1] 16)))\r\n                $map.R5[1] = Convert-Int32 ((0x2B890000L * $map.R5[0]) + (0x7C932B89L * (Get-ShiftRight $map.R5[0] 16)))\r\n                $map.OUTHASH1 = Convert-Int32 ((0x9F690000L * $map.R5[1]) - (0x405B6097L * (Get-ShiftRight ($map.R5[1]) 16)))\r\n                $map.OUTHASH2 = Convert-Int32 ([long]$map.OUTHASH1 + $map.CACHE + $map.R3) \r\n                $map.CACHE = ([long]$map.OUTHASH2)\r\n                $map.COUNTER = $map.COUNTER - 1\r\n            }\r\n        \r\n            $buffer = [BitConverter]::GetBytes($map.OUTHASH1)\r\n            $buffer.CopyTo($outHash, 8)\r\n            $buffer = [BitConverter]::GetBytes($map.OUTHASH2)\r\n            $buffer.CopyTo($outHash, 12)\r\n        \r\n            [Byte[]] $outHashBase = @(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)\r\n            $hashValue1 = ((Get-Long $outHash 8) -bxor (Get-Long $outHash))\r\n            $hashValue2 = ((Get-Long $outHash 12) -bxor (Get-Long $outHash 4))\r\n        \r\n            $buffer = [BitConverter]::GetBytes($hashValue1)\r\n            $buffer.CopyTo($outHashBase, 0)\r\n            $buffer = [BitConverter]::GetBytes($hashValue2)\r\n            $buffer.CopyTo($outHashBase, 4)\r\n            $base64Hash = [Convert]::ToBase64String($outHashBase) \r\n        }\r\n    \r\n        $base64Hash\r\n    }\r\n\r\n    # Helper function for setting registry keys\r\n    function Set-RegKey {\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 SilentlyContinue)) {\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 SilentlyContinue).$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-Host \"[Error] Unable to set registry key for $Name at $Path please see below error!\"\r\n                Write-Host \"[Error] $($_.Exception.Message)\"\r\n                exit 1\r\n            }\r\n            Write-Host \"$Path\\$Name changed from $CurrentValue to $($(Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue).$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-Host \"[Error] Unable to set registry key for $Name at $Path please see below error!\"\r\n                Write-Host \"[Error] $($_.Exception.Message)\"\r\n                exit 1\r\n            }\r\n            Write-Host \"Set $Path\\$Name to $($(Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue).$Name)\"\r\n        }\r\n    }\r\n\r\n    # Retrieves all accounts on a system.\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 -Path \"Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\*\" |\r\n                Where-Object { $_.PSChildName -match $Pattern } | \r\n                Select-Object @{Name = \"SID\"; Expression = { $_.PSChildName } },\r\n                @{Name = \"UserName\"; Expression = { \"$($_.ProfileImagePath | Split-Path -Leaf)\" } }, \r\n                @{Name = \"UserHive\"; Expression = { \"$($_.ProfileImagePath)\\NTuser.dat\" } }, \r\n                @{Name = \"Path\"; Expression = { $_.ProfileImagePath } }\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, Path\r\n                $DefaultProfile.UserName = \"Default\"\r\n                $DefaultProfile.SID = \"DefaultProfile\"\r\n                $DefaultProfile.Userhive = \"$env:SystemDrive\\Users\\Default\\NTUSER.DAT\"\r\n                $DefaultProfile.Path = \"C:\\Users\\Default\"\r\n    \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    # This is used to check that the browser is installed.\r\n    function Find-UninstallKey {\r\n        [CmdletBinding()]\r\n        param (\r\n            [Parameter(ValueFromPipeline = $True)]\r\n            [String]$DisplayName,\r\n            [Parameter()]\r\n            [Switch]$UninstallString\r\n        )\r\n        process {\r\n            $UninstallList = New-Object System.Collections.Generic.List[Object]\r\n    \r\n            $Result = Get-ChildItem -Path Registry::HKEY_LOCAL_MACHINE\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\* | Get-ItemProperty | Where-Object { $_.DisplayName -like \"*$DisplayName*\" }\r\n            if ($Result) { $UninstallList.Add($Result) }\r\n    \r\n            $Result = Get-ChildItem -Path Registry::HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\* | Get-ItemProperty | Where-Object { $_.DisplayName -like \"*$DisplayName*\" }\r\n            if ($Result) { $UninstallList.Add($Result) }\r\n    \r\n            # Programs don't always have an uninstall string listed here so to account for that I made this optional.\r\n            if ($UninstallString) {\r\n                $UninstallList | Select-Object -ExpandProperty UninstallString -ErrorAction SilentlyContinue\r\n            }\r\n            else {\r\n                $UninstallList\r\n            }\r\n        }\r\n    }\r\n}\r\nprocess {\r\n    if (-not (Test-IsElevated)) {\r\n        Write-Host \"[Error] Access Denied. Please run with Administrator privileges.\"\r\n        exit 1\r\n    }\r\n\r\n    # Protocols and file associations to set\r\n    $Protocols = \"http\", \"https\"\r\n    $Files = \"htm\", \"html\", \"xhtml\"\r\n\r\n    # Handlers for each product\r\n    switch ($Browser) {\r\n        \"Google Chrome\" {\r\n            $DisplayName = \"Chrome\"\r\n            $urlID = \"ChromeHTML\"\r\n            $htmlID = \"ChromeHTML\"\r\n        }\r\n        \"Microsoft Edge\" {\r\n            $DisplayName = \"Edge\"\r\n            $urlID = \"MSEdgeHTM\"\r\n            $htmlID = \"MSEdgeHTM\"\r\n        }\r\n        \"Mozilla Firefox\" {\r\n            $DisplayName = \"Firefox\"\r\n            $urlID = \"FirefoxURL-308046B0AF4A39CB\"\r\n            $htmlID = \"FirefoxHTML-308046B0AF4A39CB\"\r\n        }\r\n        default {\r\n            Write-Host \"[Error] Only the following browsers can be made the default. 'Google Chrome','Microsoft Edge' or 'Mozilla Firefox'.\"\r\n            exit 1\r\n        }\r\n    }\r\n\r\n    if (-not (Find-UninstallKey -DisplayName \"$DisplayName\")) {\r\n        Write-Host \"[Error] $Browser is not installed. Please ensure it's installed System-Wide prior to running this script.\"\r\n        exit 1\r\n    }\r\n\r\n    $UserProfiles = Get-UserHives -Type \"All\"\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        # The hex date and user experience don't really change\r\n        $userExperience = \"User Choice set via Windows User Experience {D18B6DD5-6124-4341-9318-804003BAFA0B}\"\r\n        $hexDateTime = Get-HexDateTime\r\n\r\n\r\n        Write-Host \"`nSetting default browser of $Browser for $($UserProfile.UserName).\"\r\n\r\n        # Set protocol association registry keys\r\n        $Protocols | ForEach-Object {\r\n            Write-Host \"Setting \"\r\n            $Protocol = $_\r\n\r\n            $ToBeHashed = \"$Protocol$($UserProfile.SID)$urlID$hexDateTime$userExperience\".ToLower()\r\n            $Hash = Get-Hash -BaseInfo $ToBeHashed\r\n\r\n            Set-RegKey -Path \"Registry::HKEY_USERS\\$($UserProfile.SID)\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\$Protocol\\UserChoice\" -Name \"Hash\" -Value $Hash -PropertyType String\r\n            Set-RegKey -Path \"Registry::HKEY_USERS\\$($UserProfile.SID)\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\$Protocol\\UserChoice\" -Name \"ProgId\" -Value $urlID -PropertyType String\r\n        }\r\n\r\n        # Set file association registry keys\r\n        $Files | ForEach-Object {\r\n            Write-Host \"Setting \"\r\n            $File = $_\r\n\r\n            $ToBeHashed = \".$File$($UserProfile.SID)$htmlID$hexDateTime$userExperience\".ToLower()\r\n            $Hash = Get-Hash -BaseInfo $ToBeHashed\r\n\r\n            Set-RegKey -Path \"Registry::HKEY_USERS\\$($UserProfile.SID)\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\$File\\UserChoice\" -Name \"Hash\" -Value $Hash -PropertyType String\r\n            Set-RegKey -Path \"Registry::HKEY_USERS\\$($UserProfile.SID)\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\$File\\UserChoice\" -Name \"ProgId\" -Value $htmlID -PropertyType String\r\n            Set-RegKey -Path \"Registry::HKEY_USERS\\$($UserProfile.SID)\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.$File\\UserChoice\" -Name \"Hash\" -Value $Hash -PropertyType String\r\n            Set-RegKey -Path \"Registry::HKEY_USERS\\$($UserProfile.SID)\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.$File\\UserChoice\" -Name \"ProgId\" -Value $htmlID -PropertyType String\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    # Restart explorer if requested\r\n    if ($RestartExplorer) {\r\n        Write-Host \"`nRestarting Explorer.exe as requested.\"\r\n\r\n        # Stop all instances of Explorer\r\n        Get-Process explorer | Stop-Process -Force\r\n        \r\n        Start-Sleep -Seconds 1\r\n\r\n        # Restart Explorer if not running as System and Explorer is not already running\r\n        if (!(Test-IsSystem) -and !(Get-Process -Name \"explorer\")) {\r\n            Start-Process explorer.exe\r\n        }\r\n    }\r\n}\r\nend {\r\n    \r\n    \r\n    \r\n}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"blog-cta-new blog-cta-style-1\"><div class=\"cta-left\"><h2><\/h2><p><\/p><\/div><div class=\"cta-right\"><a class=\"button\" href=\"\"><\/a><\/div><\/div>\n<h2>Detailansicht<\/h2>\n<p>Das Skript interagiert mit der Windows-Registrierung und zielt insbesondere auf die benutzerspezifischen Registrierungs-Hives ab, in denen die Standardanwendungseinstellungen gespeichert sind. Im Folgenden wird Schritt f\u00fcr Schritt erkl\u00e4rt, wie das Skript funktioniert:<\/p>\n<h3>1. Skript-Initialisierung:<\/h3>\n<ul>\n<li>Das Skript beginnt mit der \u00dcberpr\u00fcfung, ob es mit Administratorrechten ausgef\u00fchrt wird. Ist dies nicht der Fall, bricht das Skript ab um zu gew\u00e4hrleisten, dass nur autorisiertes Personal systemweite \u00c4nderungen vornehmen kann.<\/li>\n<\/ul>\n<h3>2. Behandlung der Parameter:<\/h3>\n<ul>\n<li>Es werden zwei Parameter akzeptiert: den Browser, der als Standard eingestellt werden soll, und einen Switch zum Neustart des Prozesses &#8218;Explorer.exe&#8216;. Der Browser-Parameter akzeptiert &#8218;Mozilla Firefox&#8216;, &#8218;Google Chrome&#8216; oder &#8218;Microsoft Edge&#8216; und ist standardm\u00e4\u00dfig auf die Umgebungsvariable eingestellt, wenn er nicht direkt angegeben wird.<\/li>\n<\/ul>\n<h3>3. Browser-Validierung:<\/h3>\n<ul>\n<li>Bevor das Skript fortf\u00e4hrt, pr\u00fcft es, ob der angegebene Browser auf dem System installiert ist, indem es in der Registrierung nach seinem Deinstallationsschl\u00fcssel sucht. Wenn der Browser nicht installiert ist, wird das Skript mit einer Fehlermeldung beendet.<\/li>\n<\/ul>\n<h3>4. Profil-Management:<\/h3>\n<ul>\n<li>Das Skript ruft eine Liste aller Benutzerprofile auf dem Rechner ab, indem es die Registrierung auf benutzerspezifische Einstellungen untersucht. Er identifiziert die SID (Security Identifier) eines jeden Benutzers und l\u00e4dt dessen Registrierungsstruktur, um die Standard-Browsereinstellungen zu \u00e4ndern.<\/li>\n<\/ul>\n<h3>5. Standardprotokoll und Dateizuordnungen einstellen:<\/h3>\n<ul>\n<li>F\u00fcr jedes Benutzerprofil \u00e4ndert das Skript die Registrierung, um den ausgew\u00e4hlten Browser als Standardprogramm f\u00fcr die Dateitypen HTTP, HTTPS, HTM, HTML und XHTML festzulegen. Dabei wird ein spezifischer Hash f\u00fcr die Einstellungen generiert, um sicherzustellen, dass sie von Windows als g\u00fcltig und sicher erkannt werden.<\/li>\n<\/ul>\n<h3>6. Neustart des Explorers (optional):<\/h3>\n<ul>\n<li>Wenn der Switch -RestartExplorer verwendet wird, h\u00e4lt das Skript den Prozess &#8218;Explorer.exe&#8216; an und startet ihn neu. Dieser Schritt ist notwendig, um die \u00c4nderungen sofort zu \u00fcbernehmen und die Desktop-Symbole f\u00fcr die betroffenen Dateitypen zu aktualisieren.<\/li>\n<\/ul>\n<h2>Potenzielle Anwendungsf\u00e4lle<\/h2>\n<p>Stellen Sie sich einen IT-Administrator vor, der ein gro\u00dfes Unternehmensnetzwerk mit Hunderten von Benutzer:innen verwaltet. Das Unternehmen hat sich vor kurzem f\u00fcr Firefox als Standardbrowser entschieden, da dieser \u00fcber verbesserte Sicherheitsfunktionen verf\u00fcgt.<\/p>\n<p>Anstatt Firefox manuell als Standardbrowser im Profil jedes Benutzers einzustellen, kann der Administrator dieses Skript im gesamten Netzwerk ausf\u00fchren. So wird garantiert, dass jeder Benutzer, unabh\u00e4ngig von der H\u00e4ufigkeit seiner Anmeldung oder dem Status seines Profils, standardm\u00e4\u00dfig Firefox verwendet. Dies spart nicht nur Zeit, sondern verringert auch die Wahrscheinlichkeit von Benutzerfehlern oder der Nichteinhaltung von Unternehmensrichtlinien.<\/p>\n<h2>Vergleiche<\/h2>\n<p>Wie schon gesehen, kann man den Standardbrowser mit PowerShell festlegen und dies bietet zwar einen optimierten Ansatz, aber es gibt auch andere Methoden, um das gleiche Ergebnis zu erzielen, z. B. die Verwendung von Gruppenrichtlinien oder die Bereitstellung eines Software-Management-Tools. Gruppenrichtlinien bieten eine zentralere M\u00f6glichkeit zur Durchsetzung von Browser-Einstellungen, k\u00f6nnen aber kompliziert zu konfigurieren sein und decken m\u00f6glicherweise nicht alle Szenarien ab, insbesondere bei benutzerspezifischen Profilen.<\/p>\n<p>Software-Management-Tools hingegen sind oft mit zus\u00e4tzlichen Kosten verbunden und erfordern eine gewisse Einarbeitungszeit. Dieses Skript bietet eine anpassbare, kostenlose L\u00f6sung, die sich direkt in die bestehende Windows-Umgebung integrieren l\u00e4sst.<\/p>\n<h2>FAQs<\/h2>\n<h3>F: Kann dieses Skript auf Systemen mit \u00e4lteren Windows-Versionen als Windows 10 verwendet werden?<\/h3>\n<p>A: Das Skript ist f\u00fcr Windows 10 und sp\u00e4tere Versionen konzipiert. Es nutzt spezifische Registrierungsstrukturen und Protokolle, die in \u00e4lteren Windows-Versionen m\u00f6glicherweise nicht verf\u00fcgbar sind.<\/p>\n<h3>F: Was passiert, wenn Benutzer:innen einen neuen Browser installieren, nachdem das Skript ausgef\u00fchrt wurde?<\/h3>\n<p>A: Wenn ein neuer Browser installiert wird, nachdem das Skript ausgef\u00fchrt wurde, kann er versuchen, sich als Standardbrowser festzulegen. In solchen F\u00e4llen werden die gew\u00fcnschten Einstellungen durch erneutes Ausf\u00fchren des Skripts wieder angewendet.<\/p>\n<h3>F: Kann das Skript so ge\u00e4ndert werden, dass es auch andere, nicht in den Parametern aufgef\u00fchrte Browser ber\u00fccksichtigt?<\/h3>\n<p>A: Ja, das Skript kann so angepasst werden, dass es auch andere Browser unterst\u00fctzt, indem die entsprechenden Protokoll- und Standardprogramm-Kennungen hinzugef\u00fcgt werden.<\/p>\n<h2>Folgen<\/h2>\n<p>Mit diesem Skript k\u00f6nnen IT-Experten die Browser-Konsistenz in allen Benutzerprofilen durchsetzen, was f\u00fcr die Sicherheit und die Compliance unerl\u00e4sslich ist. Administratoren m\u00fcssen sich jedoch \u00fcber die m\u00f6glichen Auswirkungen im Klaren sein, wie z. B. das \u00dcberschreiben von Benutzereinstellungen und die Notwendigkeit, vor der Ausf\u00fchrung des Skripts sicherzustellen, dass alle erforderlichen Browser systemweit installiert sind.<\/p>\n<h2>Empfehlungen<\/h2>\n<ul>\n<li><strong>Testen Sie es in einer kontrollierten Umgebung<\/strong>: Bevor Sie dieses Skript in einem ganzen Netzwerk einsetzen, sollten Sie es in einer kontrollierten Umgebung testen, um sicher zu sein, dass es sich wie erwartet verh\u00e4lt.<\/li>\n<li><strong>Vergewissern Sie sich, dass alle Browser installiert sind<\/strong>: Pr\u00fcfen Sie, dass der ausgew\u00e4hlte Standardbrowser auf allen Systemen installiert ist, auf denen das Skript ausgef\u00fchrt werden soll.<\/li>\n<li><strong>Kommunizieren Sie mit den Anwender:innen<\/strong>: Informieren Sie die Benutzer:innen \u00fcber die \u00c4nderung, insbesondere wenn ihre Standard-Browser-Einstellungen \u00fcberschrieben werden.<\/li>\n<\/ul>\n<h2>Abschlie\u00dfende \u00dcberlegungen<\/h2>\n<p>F\u00fcr IT-Experten und MSPs ist das effiziente Management von Benutzerumgebungen entscheidend. Dieses PowerShell-Skript bietet eine zuverl\u00e4ssige L\u00f6sung zum Standardisieren des Browsers f\u00fcr alle Benutzerprofile auf einem Windows-System. <a href=\"https:\/\/www.ninjaone.com\/de\/\" target=\"_blank\" rel=\"noopener\">NinjaOne<\/a> bietet komplette Tools f\u00fcr das Endpunkt-Management, einschlie\u00dflich der Softwarebereitstellung und des Managements von Benutzerprofilen. Dieses Skript kann eine hervorragende Erg\u00e4nzung sein, da es detaillierte Kontrolle \u00fcber die Browsereinstellungen bietet.<\/p>\n","protected":false},"author":35,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","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":[4307],"class_list":["post-353622","script_hub","type-script_hub","status-publish","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub\/353622","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/comments?post=353622"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/media?parent=353622"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/operating_system?post=353622"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/use_cases?post=353622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}