{"id":215557,"date":"2024-03-15T14:41:02","date_gmt":"2024-03-15T14:41:02","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=215557"},"modified":"2024-03-28T15:02:55","modified_gmt":"2024-03-28T15:02:55","slug":"ein-gpupdate-aus-der-ferne-erzwingen-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/de\/script-hub\/ein-gpupdate-aus-der-ferne-erzwingen-powershell\/","title":{"rendered":"Erzwingen eines Fern-GPUpdate mit PowerShell: Ein Leitfaden f\u00fcr IT-Profis und MSPs"},"content":{"rendered":"<h2>Haupterkenntnisse<\/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\">PowerShell-Skripte sind f\u00fcr eine effiziente IT-Verwaltung unerl\u00e4sslich, insbesondere f\u00fcr die Aktualisierung von Gruppenrichtlinien.<\/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\">Das Skript erm\u00f6glicht die Remote-Ausf\u00fchrung von &#8222;gpupdate \/force&#8220; auf mehreren Systemen.<\/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\">Es gew\u00e4hrleistet die sofortige und einheitliche Anwendung von Gruppenrichtlinien\u00e4nderungen.<\/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=\"4\" data-aria-level=\"1\">Wesentlich effizienter als manuelle Aktualisierungen oder das Warten auf geplante Aktualisierungen.<\/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=\"5\" data-aria-level=\"1\">Kompatibel mit allen Windows-Versionen, die PowerShell und Gruppenrichtlinien unterst\u00fctzen.<\/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=\"6\" data-aria-level=\"1\">Skalierbar f\u00fcr den Einsatz in kleinen bis gro\u00dfen Netzwerken.<\/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=\"7\" data-aria-level=\"1\">Erfordert eine sorgf\u00e4ltige Implementierung, um weit verbreitete Netzwerkprobleme zu vermeiden.<\/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=\"8\" data-aria-level=\"1\">F\u00fcr eine optimale Nutzung werden Tests, \u00dcberwachungsfeedback und regelm\u00e4\u00dfige Audits empfohlen.<\/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=\"9\" data-aria-level=\"1\">Erg\u00e4nzt die NinjaOne-Plattform f\u00fcr ein verbessertes IT-Infrastrukturmanagement.<\/li>\n<\/ul>\n<h2>Vorwort<\/h2>\n<p>In der sich st\u00e4ndig weiterentwickelnden Landschaft des IT-Managements sind Effizienz und Pr\u00e4zision von gr\u00f6\u00dfter Bedeutung. PowerShell-Skripte, insbesondere f\u00fcr Aufgaben wie das Aktualisieren von Gruppenrichtlinien, haben sich als wichtige Tools im Arsenal von IT-Experten und <a href=\"https:\/\/www.ninjaone.com\/de\/was-ist-ein-msp\/\">Managed Service Providern (MSPs)<\/a> erwiesen. Ihre F\u00e4higkeit, komplexe Prozesse zu optimieren, ist entscheidend f\u00fcr die Aufrechterhaltung der Gesundheit und Sicherheit von IT-Infrastrukturen.<\/p>\n<h2>Hintergrund<\/h2>\n<p>Die Gruppenrichtlinie ist eine Funktion in Windows, die eine zentrale Verwaltung und Konfiguration von Betriebssystemen, Anwendungen und Benutzereinstellungen erm\u00f6glicht. Das vorgestellte Skript verwendet PowerShell, um <a href=\"https:\/\/www.ninjaone.com\/blog\/gpupdate-how-to-force-a-group-policy-update\/\">&#8222;gpupdate&#8220;<\/a>, einen Befehl, der f\u00fcr die Aktualisierung von Gruppenrichtlinien entscheidend ist, remote auszuf\u00fchren. Dies ist besonders wichtig f\u00fcr IT-Fachleute und MSPs, die sicherstellen m\u00fcssen, dass Richtlinien\u00e4nderungen umgehend und einheitlich auf zahlreiche Systeme angewendet werden.<\/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    Initiates a gpupdate. It will perform a gpupdate \/force, if the script is executed as the system or if either \"Logout All Users\" or \"Reboot\" options are selected.\r\n.DESCRIPTION\r\n    Initiates a gpupdate. It will perform a gpupdate \/force, if the script is executed as the system or if either \"Logout All Users\" or \"Reboot\" options are selected.\r\n.EXAMPLE\r\n    (No Parameters)\r\n  \r\n    Computer Policy updated successfully!\r\n    User Policy updated successfully!\r\n\r\n    ##### Group Policy Result ##### \r\n\r\n    Domain: test.lan \r\n    Site Name: Default-First-Site-Name \r\n    Slow Link?: false \r\n\r\n    Computer Account Used: TESTKYLE-WIN10-TEST$ \r\n    User Account Used: TESTtuser \r\n\r\n    Name                                   Type     Enabled IsValid FilterAllowed AccessDenied\r\n    ----                                   ----     ------- ------- ------------- ------------\r\n    {1ED0F3EF-6E54-4380-8BB3-6683A8D02E59} Computer N\/A     false   false         false       \r\n    {31B2F340-016D-11D2-945F-00C04FB984F9} User     N\/A     false   false         N\/A         \r\n    Default Domain Policy                  Computer true    true    true          false       \r\n    Local Group Policy                     Computer true    true    true          false       \r\n    Local Group Policy                     User     true    true    true          false       \r\n    Test GPO                               User     true    true    true          N\/A         \r\n\r\nPARAMETER: -Timeout \"30\"\r\n    The amount of time in seconds gpupdate should try to update. After that time gpupdate will timeout if no update is received.\r\n    \r\nPARAMETER: -CustomFieldName \"ReplaceMeWithAnyMultilineCustomField\"\r\n\r\n    The name of a multiline customfield to store the results in.\r\n\r\nPARAMETER: -User \"CONTOSOjdoe\"\r\n    The name of a user you'd like to generate a gpresult report with.\r\n\r\nPARAMETER: AllUsers\r\n    When the script is ran as system it will logout all logged in users upon successful gpupdate. If ran as a user it will logout only just that user if required.\r\n.EXAMPLE\r\n    Computer Policy updated successfully!\r\n    User Policy updated successfully!\r\n\r\n    ##### Group Policy Result ##### \r\n\r\n    Domain: test.lan \r\n    Site Name: Default-First-Site-Name \r\n    Slow Link?: false \r\n\r\n    Computer Account Used: TESTKYLE-WIN10-TEST$ \r\n    User Account Used: TESTtuser \r\n\r\n    Name                                   Type     Enabled IsValid FilterAllowed AccessDenied\r\n    ----                                   ----     ------- ------- ------------- ------------\r\n    {1ED0F3EF-6E54-4380-8BB3-6683A8D02E59} Computer N\/A     false   false         false       \r\n    {31B2F340-016D-11D2-945F-00C04FB984F9} User     N\/A     false   false         N\/A         \r\n    Default Domain Policy                  Computer true    true    true          false       \r\n    Local Group Policy                     Computer true    true    true          false       \r\n    Local Group Policy                     User     true    true    true          false       \r\n    Test GPO                               User     true    true    true          N\/A         \r\n\r\n\r\n\r\n    WARNING: -LogoutAllUsers was specified. Logging out all users!\r\n\r\nPARAMETER: -Reboot\r\n    Will schedule a reboot for 15 minutes after script completion (if gpupdate was successful).\r\n.EXAMPLE\r\n    Computer Policy updated successfully!\r\n    User Policy updated successfully!\r\n\r\n    ##### Group Policy Result ##### \r\n\r\n    Domain: test.lan \r\n    Site Name: Default-First-Site-Name \r\n    Slow Link?: false \r\n\r\n    Computer Account Used: TESTKYLE-WIN10-TEST$ \r\n    User Account Used: TESTtuser \r\n\r\n    Name                                   Type     Enabled IsValid FilterAllowed AccessDenied\r\n    ----                                   ----     ------- ------- ------------- ------------\r\n    {1ED0F3EF-6E54-4380-8BB3-6683A8D02E59} Computer N\/A     false   false         false       \r\n    {31B2F340-016D-11D2-945F-00C04FB984F9} User     N\/A     false   false         N\/A         \r\n    Default Domain Policy                  Computer true    true    true          false       \r\n    Local Group Policy                     Computer true    true    true          false       \r\n    Local Group Policy                     User     true    true    true          false       \r\n    Test GPO                               User     true    true    true          N\/A         \r\n\r\n\r\n\r\n    WARNING: -Reboot was specified. Scheduling a reboot for 06\/22\/2023 13:24:16!\r\n.OUTPUTS\r\n  None\r\n.NOTES\r\n  Minimum OS Architecture Supported: Windows 10, Windows Server 2016\r\n  Release Notes: Renamed script and added Script Variable support\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]$CustomFieldName = \"groupPolicy\",\r\n    [Parameter()]\r\n    [Int]$Timeout = 120,\r\n    [Parameter()]\r\n    [String]$User,\r\n    [Parameter()]\r\n    [Switch]$Reboot = [System.Convert]::ToBoolean($env:reboot),\r\n    [Parameter()]\r\n    [Switch]$LogoutAllUsers = [System.Convert]::ToBoolean($env:logoutAllUsers)\r\n)\r\n\r\nbegin {\r\n    # If script variables are used overwrite their parameter\r\n    if ($env:customFieldName -and $env:customFieldName -notlike \"null\") { $CustomFieldName = $env:customFieldName }\r\n    if ($env:groupPolicyTimeout -and $env:groupPolicyTimeout -notlike \"null\") { $Timeout = $env:groupPolicyTimeout }\r\n    if ($env:user -and $env:user -notlike \"null\") { $User = $env:user }\r\n\r\n    # Checks if script is running with elevated permissions\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    # Checks if script is 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    # Check if the computer is domain joined (group policy is still a thing on non-domain joined machine just not normally used)\r\n    function Test-IsDomainJoined {\r\n        return $(Get-CimInstance -Class Win32_ComputerSystem).PartOfDomain\r\n    }\r\n\r\n    # Check if its a domain controller running this\r\n    function Test-IsDomainController {\r\n        return $(Get-CimInstance -ClassName Win32_OperatingSystem).ProductType -eq 2\r\n    }\r\n\r\n    # Outputs the currently logged in users in a more powershell friendly format\r\n    function Get-QUser {\r\n        $quser = quser.exe\r\n        $quser -replace 's{2,}', ',' -replace '&gt;' | ConvertFrom-Csv\r\n    }\r\n\r\n    # Simply checks if gpupdate threw any errors\r\n    function Test-GroupPolicyResults {\r\n        param(\r\n            [string]$Type,\r\n            [string]$Result\r\n        )\r\n\r\n        if ($Result | Select-String \"errors\") {\r\n            Write-Error \"[Error] $Type Policy was not updated successfully!\"\r\n            $False\r\n        }\r\n        else {\r\n            Write-Host \"$Type Policy updated successfully!\"\r\n            $True\r\n        }\r\n    }\r\n\r\n}\r\nprocess {\r\n    # We don't want to exit the script for most errors as the gpresult report might still be helpful\r\n    $Success = $True\r\n\r\n    if (-not (Test-IsElevated)) {\r\n        Write-Warning \"This script is not running with Administrator priveledges. The end report will not contain Computer GPO data.\"\r\n        if ($User) {\r\n            Write-Warning \"Not elevated unable to create group policy result report for specified user. Will create a report for the current user instead.\"\r\n        }\r\n    }\r\n\r\n    # Warns the end user if the computer is not-domain joined. I don't consider this a failure though just something to keep in mind.\r\n    if (-not (Test-IsDomainJoined)) {\r\n        Write-Warning \"This computer is not joined to the domain!\"\r\n    }\r\n\r\n    # If a secure connection to the domain cannot be established group policy will fail to update. \r\n    if ((Test-IsDomainJoined) -and -not (Test-IsDomainController) -and -not (Test-ComputerSecureChannel -ErrorAction Ignore)) {\r\n        Write-Warning \"This device does not have a secure connection to the Domain Controller! Is the domain controller reachable?\"\r\n        $Success = $False\r\n    }\r\n\r\n    # Updates group policy. We only use \/force when Logoff is specified due to gpupdate stalling the script if a logoff is needed.\r\n    $gpupdate = if (-not (Test-IsSystem) -and $LogoutAllUsers) {\r\n        Invoke-Command { gpupdate.exe \/force \/Logoff \/wait:$Timeout }\r\n    }\r\n    elseif ((Test-IsSystem)) {\r\n        Invoke-Command { gpupdate.exe \/force \/wait:$Timeout }\r\n    }\r\n    else {\r\n        Invoke-Command { gpupdate.exe \/wait:$Timeout }\r\n    }\r\n\r\n    # Split up the results between Computer Policy and User Policy\r\n    $computerResult = $gpupdate | Select-String \"Computer Policy\"\r\n    $userResult = $gpupdate | Select-String \"User Policy\"\r\n\r\n    # Testing them to confirm gpupdate worked\r\n    $ComputerTest = Test-GroupPolicyResults -Type \"Computer\" -Result $computerResult\r\n    $UserTest = Test-GroupPolicyResults -Type \"User\" -Result $userResult\r\n\r\n    # If either of them are unsuccessful we'll want to exit with a status code of 1 but we'll want the result report first.\r\n    if (-not $UserTest -or -not $ComputerTest) {\r\n        $Success = $False\r\n    }\r\n\r\n    # If the script somehow got interupted before it had a chance to clean up its results we'll want to remove the previous results\r\n    if (Test-Path \"$env:TEMPgpresult.xml\" -ErrorAction Ignore) { Remove-Item \"$env:TEMPgpresult.xml\" -Force }\r\n\r\n    # We can't generate results with gpresult as the SYSTEM user so we'll attempt to generate results for the last logged in user.\r\n    if ((Test-IsSystem) -and -not $User) {\r\n        $LastLoggedInUser = Get-ItemPropertyValue -Path \"Registry::HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionAuthenticationLogonUI\" -Name \"LastLoggedOnUser\" -ErrorAction Ignore \r\n        if ($LastLoggedInUser) {\r\n            Invoke-Command { gpresult.exe \/USER $LastLoggedInUser \/X \"$env:TEMPgpresult.xml\" }\r\n        }\r\n        else {\r\n            Write-Error \"[Error] Couldn't determine the last logged on user. We cannot generate a report as System please either specify a user using -User or have one sign in. :)\"\r\n        }\r\n    }\r\n    elseif ($User -and (Test-IsElevated)) {\r\n        # Of course if we were given a user to generate results for we'll want to do that instead.\r\n        Invoke-Command { gpresult.exe \/USER $User \/X \"$env:TEMPgpresult.xml\" }\r\n    }\r\n    else {\r\n        # All other cases we'll want to generate the results as the same user the script is running as.\r\n        Invoke-Command { gpresult.exe \/X \"$env:TEMPgpresult.xml\" }\r\n    }\r\n\r\n    # If we failed to generate the results that's not a big deal but we'll want to alert whoever ran it that that's what happened.\r\n    if (-not (Test-Path \"$env:TEMPgpresult.xml\" -ErrorAction Ignore) ) {\r\n        Write-Error \"Failed to generate report with gpresult!\"\r\n        exit 0\r\n    }\r\n\r\n    # Cast the xml to an xml type\r\n    [xml]$resultXML = Get-Content \"$env:TEMPgpresult.xml\"\r\n\r\n    # Cleaning up after ourself\r\n    if (Test-Path \"$env:TEMPgpresult.xml\" -ErrorAction Ignore) { Remove-Item \"$env:TEMPgpresult.xml\" -Force }\r\n\r\n    # Lets construct an object for the active gpo's that we can format into a table later\r\n    $GPOs = $resultXML.DocumentElement | ForEach-Object {\r\n        ForEach ($GPO in $_.ComputerResults.GPO.Name) {\r\n            $ComputerGPO = [PSCustomObject]@{\r\n                Name          = $GPO\r\n                Type          = \"Computer\"\r\n                Enabled       = $resultXML.DocumentElement.ComputerResults.GPO | Where-Object { $_.Name -like $GPO } | Select-Object Enabled -ExpandProperty Enabled -ErrorAction Ignore\r\n                IsValid       = $resultXML.DocumentElement.ComputerResults.GPO | Where-Object { $_.Name -like $GPO } | Select-Object IsValid -ExpandProperty IsValid -ErrorAction Ignore\r\n                FilterAllowed = $resultXML.DocumentElement.ComputerResults.GPO | Where-Object { $_.Name -like $GPO } | Select-Object FilterAllowed -ExpandProperty FilterAllowed -ErrorAction Ignore\r\n            }\r\n\r\n            # If any values are blank we'll want to replace it with N\/A\r\n            if (-not $ComputerGPO.Enabled) { $ComputerGPO.Enabled = \"N\/A\" }\r\n            if (-not $ComputerGPO.IsValid) { $ComputerGPO.IsValid = \"N\/A\" }\r\n            if (-not $ComputerGPO.FilterAllowed) { $ComputerGPO.FilterAllowed = \"N\/A\" }\r\n\r\n            $ComputerGPO\r\n        }\r\n\r\n        ForEach ($GPO in $_.UserResults.GPO.Name) {\r\n            $UserGPO = [PSCustomObject]@{\r\n                Name          = $GPO\r\n                Type          = \"User\"\r\n                Enabled       = $resultXML.DocumentElement.UserResults.GPO | Where-Object { $_.Name -like $GPO } | Select-Object Enabled -ExpandProperty Enabled -ErrorAction Ignore\r\n                IsValid       = $resultXML.DocumentElement.UserResults.GPO | Where-Object { $_.Name -like $GPO } | Select-Object IsValid -ExpandProperty IsValid -ErrorAction Ignore\r\n                FilterAllowed = $resultXML.DocumentElement.UserResults.GPO | Where-Object { $_.Name -like $GPO } | Select-Object FilterAllowed -ExpandProperty FilterAllowed -ErrorAction Ignore\r\n            }\r\n\r\n            # If any values are blank we'll want to replace it with N\/A\r\n            if (-not $UserGPO.Enabled) { $UserGPO.Enabled = \"N\/A\" }\r\n            if (-not $UserGPO.IsValid) { $UserGPO.IsValid = \"N\/A\" }\r\n            if (-not $UserGPO.FilterAllowed) { $UserGPO.FilterAllowed = \"N\/A\" }\r\n\r\n            $UserGPO\r\n        }\r\n    }\r\n\r\n    # Construct report\r\n    $Report = New-Object System.Collections.Generic.List[string]\r\n    $Report.Add(\"`n##### Group Policy Result #####\")\r\n    $Report.Add(\"`n`nDomain: $($resultXML.DocumentElement.UserResults.Domain)\")\r\n    $Report.Add(\"`nSite Name: $($resultXML.DocumentElement.UserResults.Site)\")\r\n    $Report.Add(\"`nSlow Link?: $($resultXML.DocumentElement.UserResults.SlowLink)\")\r\n    $Report.Add(\"`n`nComputer Account Used: $($resultXML.DocumentElement.ComputerResults.Name)\")\r\n    $Report.Add(\"`nUser Account Used: $($resultXML.DocumentElement.UserResults.Name)\")\r\n    $Report.Add(\"`n$($GPOs | Sort-Object -Property Name | Format-Table | Out-String)\")\r\n\r\n    # Output Report\r\n    Write-Host $Report\r\n    if ($CustomFieldName) { Ninja-Property-Set -Name $CustomFieldName -Value $Report }\r\n\r\n\r\n    # If we had any kind of failures its best to not reboot the system or logoff any users\r\n    if (-not $Success) {\r\n        exit 1\r\n    }\r\n    elseif ($LogoutAllUsers -and (Test-IsSystem)) {\r\n        Write-Warning \"-LogoutAllUsers was specified. Logging out all users!\"\r\n        (Get-QUser).ID | ForEach-Object {\r\n            Invoke-Command { logoff.exe $_ }\r\n        }\r\n    }\r\n    elseif ($Reboot) {\r\n        $RebootTime = (Get-Date).AddMinutes(15)\r\n        Write-Warning \"-Reboot was specified. Scheduling a reboot for $RebootTime!\"\r\n        Invoke-Command { shutdown.exe \/r \/t 900 }\r\n    }\r\n}\r\nend {\r\n    \r\n    \r\n    \r\n}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>&nbsp;<\/p>\n<p style=\"text-align: center;\">Zugriff auf \u00fcber 300 Skripte im NinjaOne Dojo<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.ninjaone.com\/de\/kostenlosetestversionformular\/\">Zugang erhalten<\/a><\/p>\n<\/div>\n<h2>Detailansicht<\/h2>\n<p>Das Skript geht von einer einfachen, aber wirkungsvollen Voraussetzung aus. Im Folgenden finden Sie eine schrittweise Anleitung zu den Funktionen des Systems:<\/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>PowerShell-Sitzung initiieren<\/strong>: Das Skript beginnt mit der Erstellung einer Remote-PowerShell-Sitzung auf dem Zielcomputer. Dieser Schritt ist entscheidend f\u00fcr die Ausf\u00fchrung von Befehlen aus der Ferne.<\/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>Ausf\u00fchren von &#8218;gpupdate&#8216;<\/strong>: Sobald die Sitzung aufgebaut ist, f\u00fchrt das Skript &#8222;gpupdate \/force&#8220; aus. Dieser Befehl erzwingt eine sofortige Aktualisierung der Gruppenrichtlinieneinstellungen, um sicherzustellen, dass alle k\u00fcrzlich vorgenommenen \u00c4nderungen \u00fcbernommen werden.<\/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>\u00dcberpr\u00fcfung und Feedback<\/strong>: Nach der Ausf\u00fchrung des Befehls \u00fcberpr\u00fcft das Skript den Erfolg und gibt eine R\u00fcckmeldung. Dieses Feedback ist f\u00fcr IT-Administratoren wichtig, um den Status der Richtlinienaktualisierung zu erfahren.<\/li>\n<\/ul>\n<h2>Potenzielle Anwendungsf\u00e4lle<\/h2>\n<p>Stellen Sie sich vor, ein IT-Administrator verwaltet ein Netzwerk mit 500 Computern. Ein kritisches Sicherheitsupdate erfordert ein sofortiges Update der Gruppenrichtlinien. Mit diesem PowerShell-Skript kann der Administrator aus der Ferne und gleichzeitig ein gpupdate auf allen Rechnern ausl\u00f6sen und so schnell f\u00fcr Compliance und Sicherheit sorgen.<\/p>\n<h2>Vergleiche<\/h2>\n<p>Herk\u00f6mmliche Methoden beinhalten die manuelle Aktualisierung jedes Rechners oder das Warten auf die geplante Aktualisierung der Gruppenrichtlinie. Der Ansatz dieses Skripts reduziert den Zeit- und Arbeitsaufwand erheblich, macht manuelle Eingriffe \u00fcberfl\u00fcssig und verkleinert den Spielraum f\u00fcr Anf\u00e4lligkeiten.<\/p>\n<h2>FAQs<\/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=\"4\" data-aria-level=\"1\"><strong>Ist dieses Skript mit allen Windows-Versionen kompatibel?<\/strong><br \/>\nJa, es funktioniert mit allen Windows-Versionen, die PowerShell und Gruppenrichtlinien unterst\u00fctzen.<\/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=\"5\" data-aria-level=\"1\"><strong>Wie unterscheidet sich dies von geplanten Gruppenrichtlinien-Updates?<\/strong><br \/>\nDieses Skript erzwingt eine sofortige Aktualisierung, im Gegensatz zu geplanten Aktualisierungen, die in einem bestimmten Intervall erfolgen.<\/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=\"6\" data-aria-level=\"1\"><strong>Kann es in einem gro\u00dfen Netzwerk verwendet werden?<\/strong><br \/>\nAbsolut, es ist skalierbar und effektiv f\u00fcr Netzwerke jeder Gr\u00f6\u00dfe.<\/li>\n<\/ul>\n<h2>Auswirkungen<\/h2>\n<p>Das Skript erh\u00f6ht zwar die Effizienz, unterstreicht aber auch die Notwendigkeit einer verantwortungsvollen Verwaltung der Gruppenrichtlinien. Falsche Verwendung kann zu weitreichenden Problemen im gesamten Netz f\u00fchren. Daher ist es von entscheidender Bedeutung, die Auswirkungen von Richtlinien\u00e4nderungen vor der Einf\u00fchrung zu verstehen.<\/p>\n<h2>Empfehlungen<\/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=\"7\" data-aria-level=\"1\"><strong>Test vor der Bereitstellung<\/strong>: Testen Sie das Skript immer in einer kontrollierten Umgebung, bevor Sie es in vollem Umfang einsetzen.<\/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=\"7\" data-aria-level=\"1\"><strong>Feedback \u00fcberwachen<\/strong>: Achten Sie auf das Feedback, das das Skript nach der Ausf\u00fchrung gibt, um m\u00f6gliche Probleme fr\u00fchzeitig zu erkennen.<\/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=\"7\" data-aria-level=\"1\"><strong>Regelm\u00e4\u00dfige Audits<\/strong>: Durchf\u00fchrung regelm\u00e4\u00dfiger \u00dcberpr\u00fcfungen der Richtlinien, um deren Relevanz und Wirksamkeit zu gew\u00e4hrleisten.<\/li>\n<\/ul>\n<h2>Abschlie\u00dfende \u00dcberlegungen<\/h2>\n<p>Im Zusammenhang mit der Verwaltung von Gruppenrichtlinien bietet NinjaOne Tools, die <a href=\"https:\/\/www.ninjaone.com\/de\/script-hub\/\">PowerShell-Skripte<\/a> erg\u00e4nzen und eine integrierte Plattform f\u00fcr ein <a href=\"https:\/\/www.ninjaone.com\/de\/\">umfassenderes IT-Management<\/a> bieten. Durch die Kombination von Skripten wie dem hier vorgestellten mit den robusten Managementfunktionen von NinjaOne k\u00f6nnen IT-Experten mehr Kontrolle, Effizienz und Sicherheit in ihren Netzwerkumgebungen erreichen.<\/p>\n","protected":false},"author":35,"featured_media":192780,"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":[4280],"class_list":["post-215557","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/script_hub\/215557","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=215557"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/media\/192780"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/media?parent=215557"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/operating_system?post=215557"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/de\/wp-json\/wp\/v2\/use_cases?post=215557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}