{"id":534766,"date":"2025-09-30T18:33:30","date_gmt":"2025-09-30T18:33:30","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=534766"},"modified":"2025-09-30T18:33:30","modified_gmt":"2025-09-30T18:33:30","slug":"configurer-les-informations-d-assistance-windows-avec-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/fr\/script-hub\/configurer-les-informations-d-assistance-windows-avec-powershell\/","title":{"rendered":"Comment configurer les informations d&rsquo;assistance Windows avec PowerShell"},"content":{"rendered":"<p>Le script PowerShell examin\u00e9 ici fournit un moyen complet et automatis\u00e9 de<strong> configurer les informations d&rsquo;assistance Windows avec PowerShell<\/strong>, y compris la suppression optionnelle des valeurs vides pour nettoyer les m\u00e9tadonn\u00e9es obsol\u00e8tes. Le marquage des terminaux avec des informations de support organisationnel est souvent n\u00e9glig\u00e9, alors qu&rsquo;il s&rsquo;agit d&rsquo;une \u00e9tape simple qui peut am\u00e9liorer de mani\u00e8re significative les exp\u00e9riences de support des utilisateurs finaux. L&rsquo;affichage de d\u00e9tails tels que le fabricant, l&rsquo;URL d&rsquo;assistance, le num\u00e9ro de t\u00e9l\u00e9phone et les heures d&rsquo;ouverture directement dans les param\u00e8tres Windows ou le panneau de configuration rationalise l&rsquo;acc\u00e8s des utilisateurs aux ressources d&rsquo;aide essentielles. Pour les <a href=\"https:\/\/www.ninjaone.com\/fr\/quest-ce-quun-msp\/\">fournisseurs de services g\u00e9r\u00e9s (MSP)<\/a> et les \u00e9quipes informatiques internes qui g\u00e8rent de grandes flottes d&rsquo;appareils Windows, l&rsquo;automatisation de ce processus \u00e0 l&rsquo;aide de <a href=\"https:\/\/www.ninjaone.com\/it-hub\/endpoint-management\/what-is-powershell\/\">PowerShell<\/a> peut garantir la coh\u00e9rence et le professionnalisme des d\u00e9ploiements.<\/p>\n<h2>Contexte<\/h2>\n<p>Microsoft a introduit la possibilit\u00e9 d&rsquo;afficher des informations d&rsquo;assistance et OEM (fabricant d&rsquo;\u00e9quipement d&rsquo;origine) dans l&rsquo;application Param\u00e8tres et le Panneau de configuration en modifiant les valeurs de la cl\u00e9 de registre HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\OEMInformation. Cette fonction est utile \u00e0 la fois pour les fabricants d&rsquo;\u00e9quipements d&rsquo;origine et pour les services informatiques qui personnalisent les constructions d&rsquo;entreprise. Si des outils tels que Group Policy ou Configuration Manager offrent des m\u00e9thodes de d\u00e9ploiement, PowerShell reste l&rsquo;approche la plus directe et la plus scriptable.<\/p>\n<h2>Le script\u00a0:<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Set the support contact and website information for a device as well as the model and manufacturer. This information is displayed in the \"About\" or \"PC Info\" section in the Settings app, and in the \"System\" section of the Control Panel. \r\n\r\n.DESCRIPTION\r\n    Set the support contact and website information for a device as well as the model and manufacturer. This information is displayed in the \"About\" or \"PC Info\" section in the Settings app, and in the \"System\" section of the Control Panel. \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\r\n.PARAMETER -Manufacturer\r\n    Enter the desired manufacturer label for the device. Input is limited to 255 characters. Note that in the Settings app, either Support URL or Support Phone must be populated in order for the Manufacturer setting to display. \"\r\n\r\n.PARAMETER -SupportPhone\r\n    Enter the support phone number. Input is limited to 20 characters.\r\n\r\n.PARAMETER -SupportURL\r\n    Enter the support URL. Must be an HTTPS URL.\r\n\r\n.PARAMETER -SupportHours\r\n    Enter the hours that support is available. Input is limited to 255 characters. Note that in the Settings app, either Support URL or Support Phone must be populated in order for the Support Hours setting to display. \"\r\n\r\n.PARAMETER -Model\r\n    Enter the desired model label for the device. Input is limited to 255 characters.\r\n\r\n.PARAMETER -RemoveIfBlank\r\n    Check this box to remove any of the above script variables that are left blank.\r\n\r\n.EXAMPLE\r\n    -Manufacturer \"Test\" -Model \"Test\" -SupportURL \"https:\/\/google.com\"\r\n    \r\n    [Info] Setting Manufacturer to 'Test'.\r\n    Set HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\OEMInformation\\Manufacturer to 'Test'.\r\n\r\n    [Info] Setting SupportURL to 'https:\/\/google.com'.\r\n    Set HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\OEMInformation\\SupportURL to 'https:\/\/google.com'.\r\n\r\n    [Info] Setting Model to 'Test'.\r\n    Set HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\OEMInformation\\Model to 'Test'.\r\n\r\n.EXAMPLE\r\n    -Manufacturer \"\" -Model \"Test\" -SupportURL \"\" -SupportHours \"\" -SupportPhone \"\" -RemoveIfBlank\r\n\r\n    [Info] Removing blank items from HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\OEMInformation registry key.\r\n\r\n    [Info] Current value of HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\OEMInformation\\Manufacturer: 'Test'\r\n    [Info] Removing the registry value for Manufacturer.\r\n    [Info] Successfully removed the registry value for Manufacturer!\r\n\r\n    [Info] Current value of HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\OEMInformation\\SupportHours: 'Test'\r\n    [Info] Removing the registry value for Support Hours.\r\n    [Info] Successfully removed the registry value for Support Hours!\r\n\r\n    [Info] Current value of HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\OEMInformation\\SupportURL: 'https:\/\/google.com'\r\n    [Info] Removing the registry value for Support URL.\r\n    [Info] Successfully removed the registry value for Support URL!\r\n\r\n    [Info] Current value of HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\OEMInformation\\SupportPhone: 'Test'\r\n    [Info] Removing the registry value for Support Phone.\r\n    [Info] Successfully removed the registry value for Support Phone!\r\n\r\n    [Info] Finished removing blank items.\r\n\r\n    [Info] Setting the registry value for Model to 'Test'.\r\n    HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\OEMInformation\\Model is already the value 'Test'.\r\n\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Windows Server 2016\r\n    Release Notes: Initial Release\r\n#&gt;\r\n\r\n[CmdletBinding()]\r\nparam (\r\n    [Parameter()]\r\n    [string]$Manufacturer,\r\n\r\n    [Parameter()]\r\n    [string]$SupportPhone,\r\n\r\n    [Parameter()]\r\n    [string]$SupportURL,\r\n\r\n    [Parameter()]\r\n    [string]$SupportHours,\r\n\r\n    [Parameter()]\r\n    [string]$Model,\r\n\r\n    [Parameter()]\r\n    [switch]$RemoveIfBlank = [System.Convert]::ToBoolean($env:removeIfBlank)\r\n)\r\n\r\nbegin {\r\n    function Test-IsElevated {\r\n        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n        $p = New-Object System.Security.Principal.WindowsPrincipal($id)\r\n        $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)\r\n    }\r\n\r\n    if (-not [string]::IsNullOrWhiteSpace($env:Manufacturer)){\r\n        $Manufacturer = $env:Manufacturer\r\n    }\r\n\r\n    if (-not [string]::IsNullOrWhiteSpace($env:SupportPhone)){\r\n        $SupportPhone = $env:SupportPhone\r\n    }\r\n\r\n    if (-not [string]::IsNullOrWhiteSpace($env:SupportURL)){\r\n        $SupportURL = $env:SupportURL\r\n    }\r\n\r\n    if (-not [string]::IsNullOrWhiteSpace($env:SupportHours)){\r\n        $SupportHours = $env:SupportHours\r\n    }\r\n\r\n    if (-not [string]::IsNullOrWhiteSpace($env:Model)){\r\n        $Model = $env:Model\r\n    }\r\n\r\n    $ExitCode = 0\r\n\r\n    if ($Manufacturer){\r\n        # test for character limit\r\n        $characterCount = (Measure-Object -InputObject $Manufacturer -Character).Characters \r\n        if ($characterCount -gt 255){\r\n            Write-Host \"[Error] The input value for Manufacturer is limited to 255 characters. Your input is $characterCount characters long.\"\r\n            $Manufacturer = $null\r\n            $ExitCode = 1\r\n        }\r\n    }\r\n\r\n    if ($SupportPhone){\r\n        # test for character limit\r\n        $characterCount = (Measure-Object -InputObject $SupportPhone -Character).Characters \r\n        if ($characterCount -gt 20){\r\n            Write-Host \"[Error] The input value for Support Phone is limited to 20 characters. Your input is $characterCount characters long.\"\r\n            $SupportPhone = $null\r\n            $ExitCode = 1\r\n        }\r\n    }\r\n\r\n    if ($SupportHours){\r\n        # test for character limit\r\n        $characterCount = (Measure-Object -InputObject $SupportHours -Character).Characters \r\n        if ($characterCount -gt 255){\r\n            Write-Host \"[Error] The input value for Support Hours is limited to 255 characters. Your input is $characterCount characters long.\"\r\n            $SupportHours = $null\r\n            $ExitCode = 1\r\n        }\r\n    }\r\n\r\n    if ($Model){\r\n        # test for character limit\r\n        $characterCount = (Measure-Object -InputObject $Model -Character).Characters \r\n        if ($characterCount -gt 255){\r\n            Write-Host \"[Error] The input value for Model is limited to 255 characters. Your input is $characterCount characters long.\"\r\n            $Model = $null\r\n            $ExitCode = 1\r\n        }\r\n    }\r\n\r\n    if (-not $Manufacturer -and -not $Model -and -not $SupportPhone -and -not $SupportHours -and -not $SupportURL -and -not $RemoveIfBlank){\r\n        Write-Host \"[Error] At least one option needs to be selected.\"\r\n        exit 1\r\n    }\r\n\r\n    if ($SupportURL -and $SupportURL -notmatch \"^https:\/\/\"){\r\n        Write-Host \"[Error] Invalid Support URL detected: '$SupportURL'. This script requires an HTTPS URL.\"\r\n        exit 1\r\n    }\r\n\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    \r\n        # Check if the specified registry path exists\r\n        if (!(Test-Path -Path $Path)) {\r\n            try {\r\n                # If the path does not exist, create it\r\n                New-Item -Path $Path -Force -ErrorAction Stop | Out-Null\r\n            }\r\n            catch {\r\n                # If there is an error creating the path, output an error message and exit\r\n                Write-Host \"[Error] Unable to create the registry path $Path for $Name. Please see the error below!\"\r\n                Write-Host \"[Error] $($_.Exception.Message)\"\r\n                exit 1\r\n            }\r\n        }\r\n    \r\n        # Check if the registry key already exists at the specified path\r\n        if (Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue) {\r\n            # Retrieve the current value of the registry key\r\n            $CurrentValue = (Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue).$Name\r\n            if ($CurrentValue -eq $Value) {\r\n                Write-Host \"$Path\\$Name is already the value '$Value'.`n\"\r\n            }\r\n            else {\r\n                try {\r\n                    # Update the registry key with the new value\r\n                    Set-ItemProperty -Path $Path -Name $Name -Value $Value -Force -Confirm:$false -ErrorAction Stop | Out-Null\r\n                }\r\n                catch {\r\n                    # If there is an error setting the key, output an error message and exit\r\n                    Write-Host \"[Error] Unable to set registry key for $Name at $Path. Please see the error below!\"\r\n                    Write-Host \"[Error] $($_.Exception.Message)\"\r\n                    exit 1\r\n                }\r\n                # Output the change made to the registry key\r\n                Write-Host \"$Path\\$Name changed from '$CurrentValue' to '$((Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue).$Name)'.`n\"\r\n            }\r\n        }\r\n        else {\r\n            try {\r\n                # If the registry key does not exist, create it with the specified value and property type\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                # If there is an error creating the key, output an error message and exit\r\n                Write-Host \"[Error] Unable to set registry key for $Name at $Path. Please see the error below!\"\r\n                Write-Host \"[Error] $($_.Exception.Message)\"\r\n                exit 1\r\n            }\r\n            # Output the creation of the new registry key\r\n            Write-Host \"Set $Path\\$Name to '$((Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue).$Name)'.`n\"\r\n        }\r\n    }\r\n}\r\nprocess {\r\n    if (-not (Test-IsElevated)) {\r\n        Write-Host -Object \"[Error] Access Denied. Please run with Administrator privileges.\"\r\n        exit 1\r\n    }\r\n\r\n    $BaseRegPath = \"HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\OEMInformation\"\r\n\r\n    $currentSettings = try {\r\n        Get-ItemProperty $BaseRegPath -ErrorAction Stop\r\n    }\r\n    catch{\r\n        Write-Host \"[Error] Error getting current branding settings from registry.\"\r\n        Write-Host \"[Error] $($_.Exception.Message)\"\r\n        exit 1\r\n    }\r\n\r\n    $currentSettingsHash = @{\r\n        Manufacturer = $currentSettings.Manufacturer\r\n        SupportPhone = $currentSettings.SupportPhone\r\n        SupportURL = $currentSettings.SupportURL\r\n        SupportHours = $currentSettings.SupportHours\r\n        Model = $currentSettings.Model\r\n    }\r\n\r\n    # remove blank\/null parameters\r\n    if ($RemoveIfBlank){\r\n        Write-Host \"[Info] Removing blank items from HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\OEMInformation registry key.`n\"\r\n        \r\n        $paramsToCheck = @{\r\n            Manufacturer    = $Manufacturer\r\n            \"Support Phone\" = $SupportPhone\r\n            \"Support URL\"   = $SupportURL\r\n            \"Support Hours\" = $SupportHours\r\n            Model           = $Model\r\n        }\r\n\r\n        # create list for parameters that will be deleted, containing the spaced name of the parameter\r\n        $paramsToDelete = [System.Collections.Generic.List[string]]::new()\r\n\r\n        # determine what will be deleted\r\n        foreach ($param in $paramsToCheck.Keys){\r\n            $value = $paramsToCheck[$param]\r\n            $paramNoSpaces = $param -replace \" \",\"\"\r\n\r\n            # if there are no PSBoundParameters, but we got here, this is running using script\/environment variables\r\n            # if running the script directly, only the parameters that are given blank string values will be removed\r\n            if (([string]::IsNullOrWhiteSpace($value)) -and ($paramNoSpaces -in $PSBoundParameters.Keys -or $PSBoundParameters.Keys.Count -eq 0)){\r\n                # add the parameter name to the list\r\n                $paramsToDelete.Add($param)\r\n\r\n                # create variable to represent this parameter being deleted\r\n                New-Variable -Name \"removing$paramNoSpaces\" -Value $true\r\n            }\r\n        }\r\n\r\n        # store the current relevant settings in variables\r\n        $currentSupportPhone = $currentSettingsHash.SupportPhone\r\n        $currentManufacturer = $currentSettingsHash.Manufacturer\r\n        $currentSupportHours = $currentSettingsHash.SupportHours\r\n\r\n        # warn the user that removing the Support URL while keeping the Support Phone will result in a default URL being displayed\r\n        if ($removingSupportURL -and -not $removingSupportPhone -and -not [string]::IsNullOrWhiteSpace($currentSupportPhone)){\r\n            Write-Host \"[Warning] In the Settings app, removing the Support URL without removing the Support Phone will result in a default Support URL that links to https:\/\/support.microsoft.com\/en-us.`n\"\r\n        }\r\n        # otherwise warn the user that removing the URL and phone, or removing only the URL when the phone is blank, will also affect the Manufacturer and Support Hours settings if they are populated\r\n        elseif (\r\n            $removingSupportURL -and \r\n            -not ($removingManufacturer -and $removingSupportHours) -and\r\n            ($removingSupportPhone -or [string]::IsNullOrWhiteSpace($currentSupportPhone)) -and\r\n            ($currentManufacturer -or $currentSupportHours)\r\n        ){\r\n            Write-Host \"[Warning] If both Support URL and Support Phone are empty, Manufacturer and Support Hours will be hidden in the Settings app.`n\"              \r\n        }\r\n\r\n        # delete the blank parameters\r\n        foreach ($param in $paramsToDelete){\r\n            $paramNoSpaces = $param -replace \" \",\"\"\r\n\r\n            # get current value of the parameter\r\n            $currentValue = (Get-ItemProperty $BaseRegPath -Name $paramNoSpaces -ErrorAction SilentlyContinue).$paramNoSpaces\r\n            \r\n            # if the above finds a value, proceed with removing the value\r\n            if ($null -ne $currentValue){\r\n                Write-Host \"[Info] Current value of HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\OEMInformation\\$paramNoSpaces`: '$currentValue'\"\r\n                Write-Host \"[Info] Removing the registry value for $param.\"\r\n\r\n                try{\r\n                    Remove-ItemProperty $BaseRegPath -Name $paramNoSpaces -ErrorAction Stop\r\n                    Write-Host \"[Info] Successfully removed the registry value for $param!`n\"\r\n                    # set entry for this value in current settings hashtable to null since the remove was successful\r\n                    $currentSettingsHash[$paramNoSpaces] = \"\"\r\n                }\r\n                catch{\r\n                    Write-Host \"[Error] Error removing the registry value for $param`:\"\r\n                    Write-Host \"$($_.Exception.Message)\"\r\n                    $ExitCode = 1\r\n                }\r\n            }\r\n            elseif ($null -eq $currentValue){\r\n                Write-Host \"[Warning] Registry value for $param does not exist. No action taken.`n\"\r\n            }\r\n        }\r\n        Write-Host \"[Info] Finished removing blank items.`n\"\r\n    }\r\n\r\n    # check the current values of Support URL and Support Phone\r\n    $currentSupportURL = $currentSettingsHash.SupportURL\r\n    $currentSupportPhone = $currentSettingsHash.SupportPhone\r\n    $currentManufacturer = $currentSettingsHash.Manufacturer\r\n    $currentSupportHours = $currentSettingsHash.SupportHours\r\n\r\n    # warn that Manufacturer and Support Hours are dependent on one of either Support URL or Support Phone being populated\r\n    if (\r\n        [string]::IsNullOrWhiteSpace($currentSupportPhone) -and [string]::IsNullOrWhiteSpace($currentSupportURL) -and\r\n        -not $SupportURL -and -not $SupportPhone -and\r\n        ($Manufacturer -or $SupportHours -or $currentManufacturer -or $currentSupportHours)\r\n    ){\r\n        Write-Host \"[Warning] In the Settings app, Manufacturer and Support Hours will not display unless the Support URL or Support Phone settings are populated.`n\"\r\n    }\r\n\r\n    # warn if SupportURL is not populated that it will be shown with a default link if SupportPhone is or will be populated\r\n    if ([string]::IsNullOrWhiteSpace($currentSupportURL) -and -not $SupportURL -and ($SupportPhone -or $currentSupportPhone)){\r\n        Write-Host \"[Warning] Support URL is not populated. In the Settings app, when Support Phone is populated, a default Support URL will show that links to https:\/\/support.microsoft.com\/en-us.`n\"\r\n    }\r\n\r\n    # set values if provided\r\n    if ($Manufacturer){\r\n        try{\r\n            Write-Host \"[Info] Setting the registry value for Manufacturer to '$Manufacturer'.\"\r\n            Set-RegKey $BaseRegPath -Name 'Manufacturer' -Value \"$Manufacturer\" -PropertyType \"String\"\r\n        }\r\n        catch{\r\n            Write-Host \"[Error] Error setting Manufacturer registry value:\"\r\n            Write-Host \"$($_.Exception.Message)\"\r\n            $ExitCode = 1\r\n        }\r\n    }\r\n\r\n    if ($SupportPhone){\r\n        try{\r\n            Write-Host \"[Info] Setting the registry value for Support Phone to '$SupportPhone'.\"\r\n            Set-RegKey $BaseRegPath -Name 'SupportPhone' -Value \"$SupportPhone\" -PropertyType \"String\"\r\n        }\r\n        catch{\r\n            Write-Host \"[Error] Error setting SupportPhone registry value:\"\r\n            Write-Host \"$($_.Exception.Message)\"\r\n            $ExitCode = 1\r\n        }\r\n    }\r\n    \r\n    if ($SupportURL){\r\n        try{\r\n            Write-Host \"[Info] Setting the registry value for Support URL to '$SupportURL'.\"\r\n            Set-RegKey $BaseRegPath -Name 'SupportURL' -Value \"$SupportURL\" -PropertyType \"String\"\r\n        }\r\n        catch{\r\n            Write-Host \"[Error] Error setting SupportURL registry value:\"\r\n            Write-Host \"$($_.Exception.Message)\"\r\n            $ExitCode = 1\r\n        }\r\n    }\r\n\r\n    if ($SupportHours){\r\n        try{\r\n            Write-Host \"[Info] Setting the registry value for Support Hours to '$SupportHours'.\"\r\n            Set-RegKey $BaseRegPath -Name 'SupportHours' -Value \"$SupportHours\" -PropertyType \"String\"\r\n        }\r\n        catch{\r\n            Write-Host \"[Error] Error setting Support Hours registry value:\"\r\n            Write-Host \"$($_.Exception.Message)\"\r\n            $ExitCode = 1\r\n        }\r\n    }\r\n\r\n    if ($Model){\r\n        try{\r\n            Write-Host \"[Info] Setting the registry value for Model to '$Model'.\"\r\n            Set-RegKey $BaseRegPath -Name 'Model' -Value \"$Model\" -PropertyType \"String\"\r\n        }\r\n        catch{\r\n            Write-Host \"[Error] Error setting Model registry value:\"\r\n            Write-Host \"$($_.Exception.Message)\"\r\n            $ExitCode = 1\r\n        }\r\n    }\r\n\r\n    exit $ExitCode\r\n}\r\nend {\r\n    \r\n    \r\n    \r\n}<\/pre>\n<p>&nbsp;<\/p>\n\n<h2>Description d\u00e9taill\u00e9e<\/h2>\n<p>Ce script suit un flux bien structur\u00e9, de la validation \u00e0 l&rsquo;ex\u00e9cution. Voici une pr\u00e9sentation \u00e9tape par \u00e9tape\u00a0:<\/p>\n<h3>1. Initialisation des param\u00e8tres<\/h3>\n<p>Accepte les param\u00e8tres suivants, soit par l&rsquo;interm\u00e9diaire de la ligne de commande, soit par l&rsquo;interm\u00e9diaire de variables d&rsquo;environnement :<\/p>\n<ul>\n<li>Fabricant<\/li>\n<li>Mod\u00e8le<\/li>\n<li>SupportURL (doit utiliser https)<\/li>\n<li>SupportPhone (max 20 caract\u00e8res)<\/li>\n<li>Heures de soutien<\/li>\n<li>RemoveIfBlank (nettoie les entr\u00e9es de registre laiss\u00e9es vides)<\/li>\n<\/ul>\n<h3>2. Logique de validation<\/h3>\n<p>Chaque param\u00e8tre est v\u00e9rifi\u00e9 :<\/p>\n<ul>\n<li>Contraintes de longueur de caract\u00e8res (255 pour la plupart, 20 pour le t\u00e9l\u00e9phone).<\/li>\n<li>Format appropri\u00e9 (https:\/\/ pour les URL).<\/li>\n<li>Des messages d&rsquo;avertissement sont imprim\u00e9s si des champs de support obligatoires sont manquants, car ils contr\u00f4lent la visibilit\u00e9 d&rsquo;autres champs dans l&rsquo;interface utilisateur Windows.<\/li>\n<\/ul>\n<h4>Gestion des cl\u00e9s de registre<\/h4>\n<p>Une fonction personnalis\u00e9e, Set-RegKey, est utilis\u00e9e pour cr\u00e9er, mettre \u00e0 jour ou ignorer les entr\u00e9es de registre sous :<br \/>\nfichier de fabrication<br \/>\nCopyEdit<br \/>\nHKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\OEMInformation<\/p>\n<h3>4. Suppression conditionnelle de champs<\/h3>\n<p>Si l&rsquo;option -RemoveIfBlank est activ\u00e9e, le script va :<\/p>\n<ul>\n<li>Identifier les param\u00e8tres vides<\/li>\n<li>Supprimer leurs entr\u00e9es de registre<\/li>\n<li>Avertir des cons\u00e9quences en termes de visibilit\u00e9 (par exemple, la suppression du t\u00e9l\u00e9phone d&rsquo;assistance et de l&rsquo;URL masque le fabricant et les heures d&rsquo;assistance)<\/li>\n<\/ul>\n<h3>5. Ex\u00e9cution Sortie<\/h3>\n<p>Le texte fournit un enregistrement clair tout au long de la proc\u00e9dure :<\/p>\n<ul>\n<li>Modifications apport\u00e9es<\/li>\n<li>\u00c9l\u00e9ments ignor\u00e9s<\/li>\n<li>Erreurs et avertissements (par exemple, si des privil\u00e8ges de non-administrateur sont d\u00e9tect\u00e9s)<\/li>\n<\/ul>\n<h2>Cas d&rsquo;utilisation potentiels<\/h2>\n<h3>\u00c9tude de cas\u00a0: Normalisation des MSP<\/h3>\n<p>Un MSP g\u00e8re 200 appareils clients dans 10 petites entreprises. Ils veulent que chaque terminal refl\u00e8te le num\u00e9ro de leur service d&rsquo;assistance 24h\/24, 7j\/7 et l&rsquo;URL d&rsquo;assistance de leur marque. Au lieu de toucher chaque machine manuellement, le MSP cr\u00e9e un script NinjaOne qui ex\u00e9cute ce module PowerShell avec des variables appropri\u00e9es inject\u00e9es \u00e0 partir de champs personnalis\u00e9s.<\/p>\n<p>En outre, lorsque les contrats d&rsquo;assistance changent, le MSP peut r\u00e9ex\u00e9cuter le script avec les valeurs mises \u00e0 jour &#8211; ou utiliser -RemoveIfBlank pour nettoyer les d\u00e9tails obsol\u00e8tes.<\/p>\n<h2>Comparaisons<\/h2>\n<table>\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><strong>M\u00e9thode<\/strong><\/td>\n<td style=\"text-align: center;\"><strong>Avantages<\/strong><\/td>\n<td style=\"text-align: center;\"><strong>Inconv\u00e9nients<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>Modification manuelle (Regedit)<\/strong><\/td>\n<td>Simple pour les mises \u00e0 jour ponctuelles<\/td>\n<td>Non \u00e9volutive ; sujette aux erreurs<\/td>\n<\/tr>\n<tr>\n<td><strong>Politique de groupe (GPO)<\/strong><\/td>\n<td>Automatisation ax\u00e9e sur les politiques<\/td>\n<td>Limit\u00e9 aux machines reli\u00e9es \u00e0 un domaine<\/td>\n<\/tr>\n<tr>\n<td><strong>Script PowerShell<\/strong><\/td>\n<td>Rapide, scriptable, fonctionne via les outils RMM<\/td>\n<td>Requiert des autorisations \u00e9lev\u00e9es<\/td>\n<\/tr>\n<tr>\n<td><strong>Gestionnaire de configuration<\/strong><\/td>\n<td>Pr\u00eat pour l&rsquo;entreprise, s&rsquo;int\u00e8gre \u00e0 SCCM<\/td>\n<td>La complexit\u00e9 peut s&rsquo;av\u00e9rer excessive pour les PME<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Ce script combine le meilleur de la simplicit\u00e9 et de l&rsquo;\u00e9volutivit\u00e9, en particulier pour les MSP qui utilisent des plateformes RMM comme NinjaOne.<\/p>\n<h2>Questions fr\u00e9quentes<\/h2>\n<h3>Q\u00a0: Ai-je besoin de droits d&rsquo;administrateur pour ex\u00e9cuter ce programme ?<\/h3>\n<p>Oui, la modification des entr\u00e9es du registre HKLM n\u00e9cessite des privil\u00e8ges administratifs.<\/p>\n<h3>Q\u00a0: Que se passe-t-il si j&rsquo;omets le num\u00e9ro de t\u00e9l\u00e9phone et l&rsquo;URL de l&rsquo;assistance ?<\/h3>\n<p>Les heures de fabrication et d&rsquo;assistance ne s&rsquo;afficheront pas dans l&rsquo;interface utilisateur des param\u00e8tres si au moins l&rsquo;un de ces \u00e9l\u00e9ments n&rsquo;est pas renseign\u00e9.<\/p>\n<h3>Q\u00a0: Puis-je utiliser HTTP dans l&rsquo;URL ?<\/h3>\n<p>Non, le script impose https:\/\/ pour des raisons de s\u00e9curit\u00e9 et de compatibilit\u00e9.<\/p>\n<h3>Q\u00a0: Les valeurs existantes seront-elles \u00e9cras\u00e9es ?<\/h3>\n<p>Oui, si de nouvelles valeurs sont fournies. Si les valeurs sont inchang\u00e9es, le script les ignore.<\/p>\n<h3>Q\u00a0: Que fait\u00a0RemoveIfBlank\u00a0?<\/h3>\n<p>Il supprime toutes les entr\u00e9es de registre OEMInformation qui sont transmises sous forme de cha\u00eenes vides, ce qui permet de nettoyer les m\u00e9tadonn\u00e9es p\u00e9rim\u00e9es.<\/p>\n<h2>Implications<\/h2>\n<p>Bien que ce script modifie des m\u00e9tadonn\u00e9es inoffensives de l&rsquo;interface utilisateur, il touche des zones sensibles du registre du syst\u00e8me. Une mauvaise utilisation pourrait briser l&rsquo;\u00e9cran de marquage ou pire si les touches sont mal retir\u00e9es. Cela dit, le fait que\u00a0<strong>d\u00e9finisse des informations de contact coh\u00e9rentes pour l&rsquo;assistance r\u00e9duit les frictions au sein du service d&rsquo;assistance<\/strong>, am\u00e9liore le professionnalisme et aide les utilisateurs lors des sc\u00e9narios de d\u00e9pannage.<\/p>\n<p>Du point de vue de la s\u00e9curit\u00e9, le fait d&rsquo;exiger https:\/\/ pour les URL garantit que toutes les pages de support li\u00e9es sont servies en toute s\u00e9curit\u00e9, ce qui permet d&rsquo;\u00e9viter les attaques de type \u00ab\u00a0downgrade\u00a0\u00bb ou les fuites d&rsquo;informations.<\/p>\n<h2>Recommandations<\/h2>\n<ul>\n<li><strong>Testez toujours sur une machine d&rsquo;essai<\/strong>\u00a0avant de d\u00e9ployer sur l&rsquo;ensemble des flottes.<\/li>\n<li><strong>Utilisez des variables d&rsquo;environnement ou des param\u00e8tres de script RMM<\/strong>\u00a0pour ins\u00e9rer dynamiquement des marques sp\u00e9cifiques au client.<\/li>\n<li><strong>Associez-le \u00e0 une solution d&rsquo;audit de scripts<\/strong>\u00a0pour confirmer les modifications apport\u00e9es au registre.<\/li>\n<li><strong>D\u00e9finissez une URL de secours et un num\u00e9ro de t\u00e9l\u00e9phone<\/strong>\u00a0pour garantir la visibilit\u00e9 dans tous les sc\u00e9narios.<\/li>\n<li><strong>Programmez des mises \u00e0 jour de routine<\/strong>\u00a0si les coordonn\u00e9es de l&rsquo;assistance changent r\u00e9guli\u00e8rement.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>Pour les professionnels de l&rsquo;informatique et les MSP, la possibilit\u00e9 de\u00a0<strong>configurer les informations de contact de l&rsquo;assistance et du site Web avec PowerShell<\/strong>\u00a0est un atout pr\u00e9cieux pour l&rsquo;image de marque, la standardisation et l&rsquo;assistance \u00e0 l&rsquo;utilisateur final. Ce script ne se contente pas de simplifier le processus, il introduit \u00e9galement une logique de nettoyage et de validation des entr\u00e9es, ce que de nombreuses solutions existantes n\u00e9gligent.<\/p>\n<p>Lorsqu&rsquo;il est associ\u00e9 \u00e0 des outils d&rsquo;automatisation tels que\u00a0<a href=\"https:\/\/www.ninjaone.com\/fr\/\"><strong>NinjaOne<\/strong><\/a> ce script devient encore plus puissant. Les champs personnalis\u00e9s et le moteur de script de NinjaOne permettent de d\u00e9ployer en toute simplicit\u00e9 des informations d&rsquo;assistance personnalis\u00e9es \u00e0 chaque terminal, renfor\u00e7ant ainsi votre marque tout en am\u00e9liorant la qualit\u00e9 du service.<\/p>\n","protected":false},"author":35,"featured_media":0,"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":[4281],"class_list":["post-534766","script_hub","type-script_hub","status-publish","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/script_hub\/534766","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/comments?post=534766"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/media?parent=534766"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/operating_system?post=534766"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/use_cases?post=534766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}