{"id":534707,"date":"2025-09-30T17:20:10","date_gmt":"2025-09-30T17:20:10","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=534707"},"modified":"2025-09-30T17:20:10","modified_gmt":"2025-09-30T17:20:10","slug":"desactiver-la-migration-forcee-vers-le-nouveau-outlook","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/fr\/script-hub\/desactiver-la-migration-forcee-vers-le-nouveau-outlook\/","title":{"rendered":"Comment utiliser PowerShell pour activer ou d\u00e9sactiver la migration forc\u00e9e vers le nouveau Outlook"},"content":{"rendered":"<p>La volont\u00e9 de Microsoft de faire passer les utilisateurs de l&rsquo;exp\u00e9rience Outlook classique \u00e0 la nouvelle interface Outlook modernis\u00e9e a cr\u00e9\u00e9 toute une s\u00e9rie de d\u00e9fis administratifs, en particulier pour les professionnels de l&rsquo;informatique et les <a href=\"https:\/\/www.ninjaone.com\/fr\/quest-ce-quun-msp\/\">fournisseurs de services g\u00e9r\u00e9s (MSP).<\/a> Bien que le nouvel Outlook offre de meilleures performances et une interface utilisateur plus propre, les migrations soudaines, parfois forc\u00e9es, peuvent perturber les flux de travail, d\u00e9sorienter les utilisateurs et donner lieu \u00e0 des tickets d&rsquo;assistance non d\u00e9sir\u00e9s.<\/p>\n<p>Heureusement, avec le bon script PowerShell, les entreprises peuvent contr\u00f4ler ce comportement \u00e0 travers les profils d&rsquo;utilisateurs, pr\u00e9servant ainsi la stabilit\u00e9 et l&rsquo;exp\u00e9rience des utilisateurs.<\/p>\n<h2>Contexte<\/h2>\n<p>Le nouvel Outlook, bien que con\u00e7u pour moderniser l&rsquo;exp\u00e9rience de la messagerie \u00e9lectronique, introduit plusieurs changements qui peuvent ne pas \u00eatre compatibles avec les flux de travail existants, les modules d&rsquo;extension tiers ou les pr\u00e9f\u00e9rences de l&rsquo;utilisateur. Microsoft a d\u00e9j\u00e0 commenc\u00e9 \u00e0 inciter les utilisateurs \u00e0 passer au num\u00e9rique, et dans de nombreux cas, \u00e0 les y contraindre. Cette \u00e9volution a conduit \u00e0 un besoin croissant des \u00e9quipes informatiques de garder le contr\u00f4le sur le moment et la mani\u00e8re dont les utilisateurs effectuent la transition.<\/p>\n<p>Le script PowerShell que nous examinons aujourd&rsquo;hui a \u00e9t\u00e9 sp\u00e9cialement con\u00e7u pour\u00a0<strong>d\u00e9sactiver la migration forc\u00e9e vers le nouveau Outlook<\/strong>,\u00a0<strong>masquer ou afficher le bouton<\/strong>\u00a0qui invite les utilisateurs \u00e0 essayer la nouvelle version, et garantir que les param\u00e8tres sont appliqu\u00e9s au niveau du profil de l&rsquo;utilisateur, m\u00eame dans les environnements li\u00e9s \u00e0 un domaine. Ce script est particuli\u00e8rement utile lorsque les strat\u00e9gies de groupe n&rsquo;ont pas encore \u00e9t\u00e9 appliqu\u00e9es ou lorsqu&rsquo;un contr\u00f4le pr\u00e9cis est n\u00e9cessaire.<\/p>\n<h2>Le script<\/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 required registry key to either block the forced migration from 'classic Outlook' to 'New Outlook' and optionally hides the 'Try the New Outlook' toggle button.\r\n.DESCRIPTION\r\n    Sets the required registry key to either block the forced migration from 'classic Outlook' to 'New Outlook' and optionally hides the 'Try the New Outlook' toggle button.\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.EXAMPLE\r\n    -NewOutlookToggle \"Hide Toggle\"\r\n    \r\n    [Warning] This device is currently joined to a domain. This setting could be overridden by a group policy in the future.\r\n    [Warning] https:\/\/learn.microsoft.com\/en-us\/microsoft-365-apps\/outlook\/get-started\/control-install#prevent-users-from-switching-to-new-outlook\r\n    Gathering all user profiles.\r\n    Successfully retrieved one or more profiles.\r\n\r\n    Setting the New Outlook forced migration policy for all users.\r\n\r\n    Setting the New Outlook forced migration policy for the user 'Administrator' to disabled.\r\n    Set Registry::HKEY_USERS\\S-1-5-21-1045302187-3297466791-1554884838-500\\Software\\Policies\\Microsoft\\office\\16.0\\outlook\\preferences\\NewOutlookMigrationUserSetting to 0\r\n    Successfully set the New Outlook forced migration policy for the user 'Administrator'.\r\n\r\n    Setting the New Outlook forced migration policy for the user 'tuser1' to disabled.\r\n    Set Registry::HKEY_USERS\\S-1-5-21-1308996835-875450383-3441943874-1104\\Software\\Policies\\Microsoft\\office\\16.0\\outlook\\preferences\\NewOutlookMigrationUserSetting to 0\r\n    Successfully set the New Outlook forced migration policy for the user 'tuser1'.\r\n\r\n    Setting the New Outlook forced migration policy for the user 'cheart' to disabled.\r\n    Set Registry::HKEY_USERS\\S-1-5-21-1308996835-875450383-3441943874-1113\\Software\\Policies\\Microsoft\\office\\16.0\\outlook\\preferences\\NewOutlookMigrationUserSetting to 0\r\n    Successfully set the New Outlook forced migration policy for the user 'cheart'.\r\n\r\n    Setting the New Outlook forced migration policy for the user 'Administrator' to disabled.\r\n    Set Registry::HKEY_USERS\\S-1-5-21-1308996835-875450383-3441943874-500\\Software\\Policies\\Microsoft\\office\\16.0\\outlook\\preferences\\NewOutlookMigrationUserSetting to 0\r\n    Successfully set the New Outlook forced migration policy for the user 'Administrator'.\r\n\r\n    Successfully set the New Outlook forced migration policy for all users.\r\n\r\n    Setting the 'Try the new outlook' toggle for all users.\r\n\r\n    Setting the 'Try the New Outlook' toggle for user 'Administrator' to hidden.\r\n    Set Registry::HKEY_USERS\\S-1-5-21-1045302187-3297466791-1554884838-500\\Software\\Microsoft\\Office\\16.0\\Outlook\\Options\\General\\HideNewOutlookToggle to 1\r\n    Successfully set the 'Try the new outlook' toggle for user 'Administrator'\r\n\r\n    Setting the 'Try the New Outlook' toggle for user 'tuser1' to hidden.\r\n    Set Registry::HKEY_USERS\\S-1-5-21-1308996835-875450383-3441943874-1104\\Software\\Microsoft\\Office\\16.0\\Outlook\\Options\\General\\HideNewOutlookToggle to 1\r\n    Successfully set the 'Try the new outlook' toggle for user 'tuser1'\r\n\r\n    Setting the 'Try the New Outlook' toggle for user 'cheart' to hidden.\r\n    Set Registry::HKEY_USERS\\S-1-5-21-1308996835-875450383-3441943874-1113\\Software\\Microsoft\\Office\\16.0\\Outlook\\Options\\General\\HideNewOutlookToggle to 1\r\n    Successfully set the 'Try the new outlook' toggle for user 'cheart'\r\n\r\n    Setting the 'Try the New Outlook' toggle for user 'Administrator' to hidden.\r\n    Set Registry::HKEY_USERS\\S-1-5-21-1308996835-875450383-3441943874-500\\Software\\Microsoft\\Office\\16.0\\Outlook\\Options\\General\\HideNewOutlookToggle to 1\r\n    Successfully set the 'Try the new outlook' toggle for user 'Administrator'\r\n\r\n    Successfully set the 'Try the New Outlook' toggle for all users. You may need to close and re-open Outlook for your change to take effect.\r\n\r\nPARAMETER: -MigrationPolicy \"Disable\"\r\n    Sets a policy to either disable or enable the automatic forced migration of classic Outlook to New Outlook.\r\n\r\nPARAMETER: -NewOutlookToggle \"Hide Toggle\"\r\n    Hide or show the toggle button to migrate to the new outlook.\r\n\r\nPARAMETER: -UserToSetPolicyFor \"ReplaceMeWithAValidUsername\"\r\n    The username you would like to set the policy for. Leave blank for all users.\r\n\r\n.LINK\r\n    https:\/\/learn.microsoft.com\/en-us\/microsoft-365-apps\/outlook\/get-started\/control-install\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]$MigrationPolicy = \"Disable\",\r\n    [Parameter()]\r\n    [String]$NewOutlookToggle,\r\n    [Parameter()]\r\n    [String]$UserToSetPolicyFor\r\n)\r\n\r\nbegin {\r\n    # If the script form variables are used, replace the command line parameters with their value.\r\n    if ($env:migrationAction -and $env:migrationAction -ne \"null\") { $MigrationPolicy = $env:migrationAction }\r\n    if ($env:toggleButtonAction -and $env:toggleButtonAction -ne \"null\") { $NewOutlookToggle = $env:toggleButtonAction }\r\n    if ($env:usernameToSetPolicyFor -and $env:usernameToSetPolicyFor -ne \"null\") { $UserToSetPolicyFor = $env:usernameToSetPolicyFor }\r\n    \r\n    # Check if a specific username was provided for setting the policy.\r\n    if ($UserToSetPolicyFor) {\r\n        # Trim any leading or trailing spaces from the username.\r\n        $UserToSetPolicyFor = $UserToSetPolicyFor.Trim()\r\n\r\n        # Validate that the username is not empty after trimming.\r\n        if (!$UserToSetPolicyFor) {\r\n            Write-Host -Object \"[Error] An invalid username was given. Please specify a valid username.\"\r\n            exit 1\r\n        }\r\n\r\n        # Ensure the username does not contain any illegal characters.\r\n        if ($UserToSetPolicyFor -match '\\[|\\]|:|;|\\||=|\\+|\\*|\\?|&lt;|&gt;|\/|\\\\|,|\"|@') {\r\n            Write-Host -Object (\"[Error] $UserToSetPolicyFor contains one of the following invalid characters.\" + ' \" [ ] : ; | = + * ? &lt; &gt; \/ \\ , @')\r\n            exit 1\r\n        }\r\n\r\n        # Ensure the username does not contain spaces.\r\n        if ($UserToSetPolicyFor -match '\\s') {\r\n            Write-Host -Object (\"[Error] '$UserToSetPolicyFor' contains a space.\")\r\n            exit 1\r\n        }\r\n\r\n        # Ensure the username does not exceed 20 characters.\r\n        $UserNameCharacters = $UserToSetPolicyFor | Measure-Object -Character | Select-Object -ExpandProperty Characters\r\n        if ($UserNameCharacters -gt 20) {\r\n            Write-Host -Object \"[Error] '$UserToSetPolicyFor' is too long. The username must not exceed 20 characters.\"\r\n            exit 1\r\n        }\r\n    }\r\n\r\n    # Check if a migration policy was provided and trim any leading\/trailing spaces.\r\n    if ($MigrationPolicy) {\r\n        $MigrationPolicy = $MigrationPolicy.Trim()\r\n    }\r\n\r\n    # Check if the \"Try the New Outlook\" toggle policy was provided and trim spaces.\r\n    if ($NewOutlookToggle) {\r\n        $NewOutlookToggle = $NewOutlookToggle.Trim()\r\n\r\n        # Validate that the toggle action is not empty after trimming.\r\n        if (!$NewOutlookToggle) {\r\n            Write-Host -Object \"[Error] An invalid 'Try the new outlook' toggle button action was given. Please specify either 'Hide Toggle', 'Show Toggle', 'Default' or nothing.\"\r\n            exit 1\r\n        }\r\n    }\r\n\r\n    # Ensure that a migration policy was specified.\r\n    if (!$MigrationPolicy) {\r\n        Write-Host -Object \"[Error] Please specify a valid migration policy action. Valid migration actions include 'Enable', 'Disable' or 'Default'.\"\r\n        exit 1\r\n    }\r\n\r\n    \r\n    # Define valid migration policy actions and ensure the input is valid.\r\n    $ValidMigrationPolicyActions = \"Enable\", \"Disable\", \"Default\"\r\n    if ($ValidMigrationPolicyActions -notcontains $MigrationPolicy) {\r\n        Write-Host -Object \"[Error] An invalid migration policy of '$MigrationPolicy' was given. Please specify a valid migration action such as 'Enable', 'Disable' or 'Default'.\"\r\n        exit 1\r\n    }\r\n\r\n    # Define valid New Outlook toggle actions and ensure the input is valid.\r\n    $ValidNewOutlookTogglePolicy = \"Hide Toggle\", \"Show Toggle\", \"Default\"\r\n    if ($NewOutlookToggle -and $ValidNewOutlookTogglePolicy -notcontains $NewOutlookToggle) {\r\n        Write-Host -Object \"[Error] An invalid 'Try the new outlook' toggle button action of '$NewOutlookToggle' was given. Please specify either 'Hide Toggle', 'Show Toggle', 'Default' or nothing.\"\r\n        exit 1\r\n    }\r\n\r\n    # To check if office is installed on the machine.\r\n    function Find-InstallKey {\r\n        [CmdletBinding()]\r\n        param (\r\n            [Parameter(ValueFromPipeline = $True)]\r\n            [String]$DisplayName,\r\n            [Parameter()]\r\n            [Switch]$UninstallString,\r\n            [Parameter()]\r\n            [String]$UserBaseKey\r\n        )\r\n        process {\r\n            # Initialize a list to store found installation keys\r\n            $InstallList = New-Object System.Collections.Generic.List[Object]\r\n    \r\n            # If no custom user base key is provided, search in the standard HKLM paths\r\n            if (!$UserBaseKey) {\r\n                $ErrorActionPreference = \"Stop\"\r\n                # Search in the 32-bit uninstall registry key and add results to the list\r\n                try {\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) { $InstallList.Add($Result) }\r\n                }\r\n                catch {\r\n                    Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n                    Write-Host -Object \"[Error] Failed to retrieve registry keys at 'HKEY_LOCAL_MACHINE\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*'.\"\r\n                    exit 1\r\n                }\r\n    \r\n                # Search in the 64-bit uninstall registry key and add results to the list\r\n                try {\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) { $InstallList.Add($Result) }\r\n                }\r\n                catch {\r\n                    Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n                    Write-Host -Object \"[Error] Failed to retrieve registry keys at 'HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*'.\"\r\n                    exit 1\r\n                }\r\n    \r\n                $ErrorActionPreference = \"Continue\"\r\n            }\r\n            else {\r\n                $ErrorActionPreference = \"Stop\"\r\n                # If a custom user base key is provided, search in the corresponding Wow6432Node path and add results to the list\r\n                try {\r\n                    $Result = Get-ChildItem -Path \"$UserBaseKey\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*\" | Get-ItemProperty | Where-Object { $_.DisplayName -like \"*$DisplayName*\" }\r\n                    if ($Result) { $InstallList.Add($Result) }\r\n                }\r\n                catch {\r\n                    Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n                    Write-Host -Object \"[Error] Failed to retrieve registry keys at '$UserBaseKey\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*'.\"\r\n                    exit 1\r\n                }\r\n    \r\n                try {\r\n                    # Search in the custom user base key for the standard uninstall path and add results to the list\r\n                    $Result = Get-ChildItem -Path \"$UserBaseKey\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*\" | Get-ItemProperty | Where-Object { $_.DisplayName -like \"*$DisplayName*\" }\r\n                    if ($Result) { $InstallList.Add($Result) }\r\n                }\r\n                catch {\r\n                    Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n                    Write-Host -Object \"[Error] Failed to retrieve registry keys at '$UserBaseKey\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*'.\"\r\n                    exit 1\r\n                }\r\n    \r\n                $ErrorActionPreference = \"Continue\"\r\n            }\r\n    \r\n            # If the UninstallString switch is set, return only the UninstallString property of the found keys\r\n            if ($UninstallString) {\r\n                $InstallList | Select-Object -ExpandProperty UninstallString -ErrorAction SilentlyContinue\r\n            }\r\n            else {\r\n                $InstallList\r\n            }\r\n        }\r\n    }\r\n\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        # Define the SID patterns to match based on the selected user type\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        # Retrieve user profile information based on the defined patterns\r\n        try {\r\n            $UserProfiles = Foreach ($Pattern in $Patterns) { \r\n                Get-ItemProperty \"Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\*\" -ErrorAction Stop |\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 = \"Domain\"; Expression = { if ($_.PSChildName -match \"S-1-12-1-(\\d+-?){4}$\") { \"AzureAD\" }else { $Null } } }, \r\n                    @{Name = \"UserHive\"; Expression = { \"$($_.ProfileImagePath)\\NTuser.dat\" } }, \r\n                    @{Name = \"Path\"; Expression = { $_.ProfileImagePath } }\r\n            }\r\n        }\r\n        catch {\r\n            Write-Host -Object \"[Error] Failed to scan registry keys at 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList'.\"\r\n            Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n            exit 1\r\n        }\r\n    \r\n        # If the IncludeDefault switch is set, add the Default profile to the results\r\n        switch ($IncludeDefault) {\r\n            $True {\r\n                $DefaultProfile = \"\" | Select-Object Username, SID, UserHive, Path\r\n                $DefaultProfile.Username = \"Default\"\r\n                $DefaultProfile.Domain = $env:COMPUTERNAME\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                # Exclude users specified in the ExcludedUsers list\r\n                $DefaultProfile | Where-Object { $ExcludedUsers -notcontains $_.Username }\r\n            }\r\n        }\r\n    \r\n        try {\r\n            if ($PSVersionTable.PSVersion.Major -lt 3) {\r\n                $AllAccounts = Get-WmiObject -Class \"win32_UserAccount\" -ErrorAction Stop\r\n            }\r\n            else {\r\n                $AllAccounts = Get-CimInstance -ClassName \"win32_UserAccount\" -ErrorAction Stop\r\n            }\r\n        }\r\n        catch {\r\n            Write-Host -Object \"[Error] Failed to gather complete profile information.\"\r\n            Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n            exit 1\r\n        }\r\n    \r\n        $CompleteUserProfiles = $UserProfiles | ForEach-Object {\r\n            $SID = $_.SID\r\n            $Win32Object = $AllAccounts | Where-Object { $_.SID -like $SID }\r\n    \r\n            if ($Win32Object) {\r\n                $Win32Object | Add-Member -NotePropertyName UserHive -NotePropertyValue $_.UserHive\r\n                $Win32Object\r\n            }\r\n            else {\r\n                [PSCustomObject]@{\r\n                    Name     = $_.Username\r\n                    Domain   = $_.Domain\r\n                    SID      = $_.SID\r\n                    UserHive = $_.UserHive\r\n                    Path     = $_.Path\r\n                }\r\n            }\r\n        }\r\n    \r\n        # Return the list of user profiles, excluding any specified in the ExcludedUsers list\r\n        $CompleteUserProfiles | Where-Object { $ExcludedUsers -notcontains $_.Name }\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'.\"\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)\"\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)\"\r\n        }\r\n    }\r\n\r\n    function Test-IsDomainJoined {\r\n        # Check the PowerShell version to determine the appropriate cmdlet to use\r\n        try {\r\n            if ($PSVersionTable.PSVersion.Major -lt 3) {\r\n                return $(Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain\r\n            }\r\n            else {\r\n                return $(Get-CimInstance -Class Win32_ComputerSystem).PartOfDomain\r\n            }\r\n        }\r\n        catch {\r\n            Write-Host -Object \"[Error] Unable to validate whether or not this device is a part of a domain.\"\r\n            Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n            exit 1\r\n        }\r\n    }\r\n\r\n    function Test-IsDomainController {\r\n        # Determine the method to retrieve the operating system information based on PowerShell version\r\n        try {\r\n            $OS = if ($PSVersionTable.PSVersion.Major -lt 3) {\r\n                Get-WmiObject -Class Win32_OperatingSystem -ErrorAction Stop\r\n            }\r\n            else {\r\n                Get-CimInstance -ClassName Win32_OperatingSystem -ErrorAction Stop\r\n            }\r\n        }\r\n        catch {\r\n            Write-Host -Object \"[Error] Unable to validate whether or not this device is a domain controller.\"\r\n            Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n            exit 1\r\n        }\r\n    \r\n        # Check if the ProductType is \"2\", which indicates that the system is a domain controller\r\n        if ($OS.ProductType -eq \"2\") {\r\n            return $true\r\n        }\r\n    }\r\n\r\n    function Test-IsElevated {\r\n        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n        $p = New-Object System.Security.Principal.WindowsPrincipal($id)\r\n        $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)\r\n    }\r\n\r\n    if (!$ExitCode) {\r\n        $ExitCode = 0\r\n    }\r\n}\r\nprocess {\r\n    # Check if the script is running with elevated (Administrator) privileges\r\n    if (!(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    # Check if the current device is either joined to a domain or is a domain controller\r\n    if (Test-IsDomainJoined -or Test-IsDomainController) {\r\n        # Display a warning indicating that the device is joined to a domain\r\n        Write-Host -Object \"[Warning] This device is currently joined to a domain. This setting could be overridden by a group policy in the future.\"\r\n\r\n        # Display additional information about the group policy that can override the setting\r\n        Write-Host -Object \"[Warning] https:\/\/learn.microsoft.com\/en-us\/microsoft-365-apps\/outlook\/get-started\/control-install#prevent-users-from-switching-to-new-outlook\"\r\n    }\r\n\r\n    # Search for Office installations (both legacy and Microsoft 365 versions)\r\n    $OfficeInstallations = Find-InstallKey -DisplayName \"Office 201\"\r\n    $Microsoft365Installations = Find-InstallKey -DisplayName \"Microsoft 365\"\r\n\r\n    # Exit if no Office installations are detected\r\n    if (!$OfficeInstallations -and !$Microsoft365Installations) {\r\n        Write-Host -Object \"[Error] Microsoft Office was not detected on this device. Please ensure that it is installed and listed in the Control Panel.\"\r\n        exit 1\r\n    }\r\n\r\n    # Create lists to store registry paths for Outlook migration and New Outlook toggle policies\r\n    $OutlookMigrationRegistryPaths = New-Object System.Collections.Generic.List[object]\r\n    $NewOutlookToggleRegistryPaths = New-Object System.Collections.Generic.List[object]\r\n\r\n    # Check if a specific user is targeted for the policy\r\n    if ($UserToSetPolicyFor) {\r\n        Write-Host -Object \"Retrieving the user profile for '$UserToSetPolicyFor'.\"\r\n    }\r\n    else {\r\n        Write-Host -Object \"Gathering all user profiles.\"\r\n    }\r\n\r\n    # Retrieve all user profiles (hives) on the system\r\n    $UserProfiles = Get-UserHives -Type \"All\"\r\n    $ProfileWasLoaded = New-Object System.Collections.Generic.List[object]\r\n\r\n    # If a specific user is targeted, filter the retrieved profiles to find a match\r\n    if ($UserToSetPolicyFor) {\r\n        $ProfileToSet = $UserProfiles | Where-Object { $_.Name -eq $UserToSetPolicyFor }\r\n\r\n        # Exit if no matching profile is found\r\n        if (!$ProfileToSet) {\r\n            Write-Host -Object \"[Error] No user profiles matching '$UserToSetPolicyFor' were found. Below is a list of existing users on the system.\"\r\n            Write-Host -Object \"[Error] You can also leave the 'Username to Set Policy For' field blank to set the policy for all users.\"\r\n            Write-Host -Object \"### User Profiles ###\"\r\n            ($UserProfiles | Format-Table -Property Name, Path, SID | Out-String).Trim() | Write-Host\r\n            exit 1\r\n        }else{\r\n            $UserProfiles = $ProfileToSet\r\n        }\r\n    }\r\n\r\n    # Load user registry hives (NTUSER.DAT) if not already loaded\r\n    ForEach ($UserProfile in $UserProfiles) {\r\n        # Load User ntuser.dat if it's not already loaded\r\n        If (!(Test-Path -Path Registry::HKEY_USERS\\$($UserProfile.SID) -ErrorAction SilentlyContinue)) {\r\n            Start-Process -FilePath \"cmd.exe\" -ArgumentList \"\/C reg.exe LOAD HKU\\$($UserProfile.SID) `\"$($UserProfile.UserHive)`\"\" -Wait -WindowStyle Hidden\r\n            $ProfileWasLoaded.Add($UserProfile)\r\n        }\r\n    }\r\n\r\n    # Construct the registry paths for Outlook migration and New Outlook toggle settings\r\n    $UserProfiles | ForEach-Object {\r\n        # Add Outlook migration policy registry path\r\n        $OutlookMigrationRegistryPaths.Add(\r\n            [PSCustomObject]@{\r\n                Username = $_.Name\r\n                Path     = \"Registry::HKEY_USERS\\$($_.SID)\\Software\\Policies\\Microsoft\\office\\16.0\\outlook\\preferences\"\r\n            }\r\n        )\r\n\r\n        # Add New Outlook toggle policy registry path\r\n        $NewOutlookToggleRegistryPaths.Add(\r\n            [PSCustomObject]@{\r\n                Username = $_.Name\r\n                BasePath = \"Registry::HKEY_USERS\\$($_.SID)\\Software\\Microsoft\\Office\"\r\n                Path     = \"Registry::HKEY_USERS\\$($_.SID)\\Software\\Microsoft\\Office\\16.0\\Outlook\\Options\\General\"\r\n            }\r\n        )\r\n    }\r\n\r\n    # Validate that registry paths have been generated successfully\r\n    if ($OutlookMigrationRegistryPaths.Count -lt 1 -or $NewOutlookToggleRegistryPaths.Count -lt 1) {\r\n        Write-Host -Object \"[Error] Failed to retrieve any user profiles.\"\r\n        exit 1\r\n    }\r\n    else {\r\n        Write-Host -Object \"Successfully retrieved one or more profiles.\"\r\n    }\r\n\r\n    # Check whether a specific user is targeted for the policy, and output a message accordingly.\r\n    if ($UserToSetPolicyFor) {\r\n        Write-Host -Object \"`nSetting the New Outlook forced migration policy for '$UserToSetPolicyFor'.\"\r\n    }\r\n    else {\r\n        Write-Host -Object \"`nSetting the New Outlook forced migration policy for all users.\"\r\n    }\r\n\r\n    # Set the Outlook migration policy for each user\r\n    $OutlookMigrationRegistryPaths | ForEach-Object {\r\n        $Username = $_.Username\r\n        Write-Host -Object \"\"\r\n\r\n        # Determine the action to take based on the $MigrationPolicy variable\r\n        switch ($MigrationPolicy) {\r\n            \"Enable\" { \r\n                Write-Host -Object \"Setting the New Outlook forced migration policy for the user '$Username' to enabled.\" \r\n                $RegValue = 1\r\n            }\r\n            \"Disable\" { \r\n                Write-Host -Object \"Setting the New Outlook forced migration policy for the user '$Username' to disabled.\"\r\n                $RegValue = 0\r\n            }\r\n            \"Default\" { \r\n                Write-Host -Object \"Setting the New Outlook forced migration policy back to the default for the user '$Username'.\"\r\n            }\r\n        }\r\n\r\n        # If the policy is set to \"Default,\" remove the registry key if it exists\r\n        if ($MigrationPolicy -eq \"Default\") {\r\n            # Check if the registry path exists\r\n            if (!(Test-Path -Path $_.Path -ErrorAction SilentlyContinue)) {\r\n                Write-Host -Object \"The registry key '$($_.Path)\\NewOutlookMigrationUserSetting' has already been removed.\"\r\n                Write-Host -Object \"Successfully set the New Outlook forced migration policy for the user '$Username'.\"\r\n                return\r\n            }\r\n\r\n            try {\r\n                # Check for an existing registry value\r\n                $ExistingValue = Get-ItemProperty -Path $_.Path -ErrorAction Stop | Select-Object -ExpandProperty \"NewOutlookMigrationUserSetting\" -ErrorAction SilentlyContinue\r\n            }\r\n            catch {\r\n                Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n                Write-Host -Object \"[Error] Failed to check if the new outlook forced migration policy is already set to the default.\"\r\n                $ExitCode = 1\r\n                return\r\n            }\r\n\r\n            # Remove the registry value if it exists\r\n            if (!$ExistingValue -and $ExistingValue -ne 0) {\r\n                Write-Host -Object \"The registry key '$($_.Path)\\NewOutlookMigrationUserSetting' has already been removed.\"\r\n                Write-Host -Object \"Successfully set the New Outlook forced migration policy for the user '$Username'.\"\r\n                return\r\n            }\r\n\r\n            try {\r\n                Remove-ItemProperty -Path $_.Path -Name \"NewOutlookMigrationUserSetting\" -ErrorAction Stop\r\n                Write-Host -Object \"Removed the registry key '$($_.Path)\\NewOutlookMigrationUserSetting'.\"\r\n                Write-Host -Object \"Successfully set the New Outlook forced migration policy for the user '$Username'.\"\r\n                return\r\n            }\r\n            catch {\r\n                Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n                Write-Host -Object \"[Error] Failed to remove the registry key '$($_.Path)\\NewOutlookMigrationUserSetting'.\"\r\n                Write-Host -Object \"[Error] Failed to set the new outlook forced migration policy for user '$Username' to the default.\"\r\n                $ExitCode = 1\r\n                return\r\n            }\r\n        }\r\n\r\n        # Set the specified registry key value for Outlook migration\r\n        Set-RegKey -Path $_.Path -Name \"NewOutlookMigrationUserSetting\" -Value $RegValue\r\n        Write-Host -Object \"Successfully set the New Outlook forced migration policy for the user '$Username'.\"\r\n    }\r\n\r\n    # If user profiles were loaded and a New Outlook toggle policy was not specified, unload their registry hives\r\n    if (!$NewOutlookToggle -and $ProfileWasLoaded.Count -gt 0) {\r\n        ForEach ($UserProfile in $ProfileWasLoaded) {\r\n            # Unload NTuser.dat\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    # Check whether a specific user is targeted for the policy, and output a message accordingly.\r\n    if ($UserToSetPolicyFor -and $ExitCode -eq 0) {\r\n        Write-Host -Object \"`nSuccessfully set the New Outlook forced migration policy for '$UserToSetPolicyFor'.\"\r\n    }\r\n    elseif ($ExitCode -eq 0) {\r\n        Write-Host -Object \"`nSuccessfully set the New Outlook forced migration policy for all users.\"\r\n    }\r\n\r\n    # Exit if no New Outlook toggle policy is specified\r\n    if (!$NewOutlookToggle) {\r\n        exit $ExitCode\r\n    }\r\n\r\n    # Check whether a specific user is targeted for the policy, and output a message accordingly.\r\n    if ($UserToSetPolicyFor) {\r\n        Write-Host -Object \"`nSetting the 'Try the new outlook' toggle for '$UserToSetPolicyFor'.\"\r\n    }\r\n    else{\r\n        Write-Host -Object \"`nSetting the 'Try the new outlook' toggle for all users.\"\r\n    }\r\n\r\n    # Process each New Outlook toggle registry path for user profiles\r\n    $NewOutlookToggleRegistryPaths | ForEach-Object {\r\n        Write-Host -Object \"\"\r\n        $Username = $_.Username\r\n\r\n        # Set the New Outlook toggle value based on the specified policy\r\n        switch ($NewOutlookToggle) {\r\n            \"Hide Toggle\" { \r\n                Write-Host -Object \"Setting the 'Try the New Outlook' toggle for user '$Username' to hidden.\"\r\n                $RegValue = 1\r\n            }\r\n            \"Show Toggle\" { \r\n                Write-Host -Object \"Setting the 'Try the new outlook' toggle for user '$Username' to show.\"\r\n                $RegValue = 0\r\n            }\r\n            \"Default\" { \r\n                Write-Host -Object \"Setting the 'Try the new outlook' toggle back to the default for user '$Username'\" \r\n            }\r\n        }\r\n\r\n        # Handle the \"Default\" policy by removing the registry key if it exists\r\n        if ($NewOutlookToggle -eq \"Default\") {\r\n            if (!(Test-Path -Path $_.Path -ErrorAction SilentlyContinue)) {\r\n                Write-Host -Object \"The registry key '$($_.Path)\\HideNewOutlookToggle' has already been removed.\"\r\n                Write-Host -Object \"Successfully set the 'Try the new outlook' toggle to the default for user '$Username'\"\r\n                return\r\n            }\r\n\r\n            # Attempt to retrieve the existing registry value\r\n            try {\r\n                $ExistingValue = Get-ItemProperty -Path $_.Path -ErrorAction Stop | Select-Object -ExpandProperty \"HideNewOutlookToggle\" -ErrorAction SilentlyContinue\r\n            }\r\n            catch {\r\n                Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n                Write-Host -Object \"[Error] Failed to verify whether the 'Try the new outlook' toggle is already set to the default.\"\r\n                $ExitCode = 1\r\n                return\r\n            }\r\n\r\n            # If the registry key does not exist, confirm it has already been removed\r\n            if (!$ExistingValue -and $ExistingValue -ne 0) {\r\n                Write-Host -Object \"The registry key '$($_.Path)\\HideNewOutlookToggle' has already been removed.\"\r\n                Write-Host -Object \"Successfully set the 'Try the new outlook' toggle to the default for user '$Username'\"\r\n                return\r\n            }\r\n            \r\n            # Remove the specific registry key property\r\n            try {\r\n                Remove-ItemProperty -Path $_.Path -Name \"HideNewOutlookToggle\" -ErrorAction Stop\r\n                Write-Host -Object \"Removed the registry key '$($_.Path)\\HideNewOutlookToggle'.\"\r\n            }\r\n            catch {\r\n                Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n                Write-Host -Object \"[Error] Failed to remove the registry key '$($_.Path)\\HideNewOutlookToggle'.\"\r\n                Write-Host -Object \"[Error] Failed to set the 'Try the new outlook' toggle to the default for user '$Username'\"\r\n                $ExitCode = 1\r\n                return\r\n            }\r\n\r\n            # Confirm successful removal of the registry key\r\n            Write-Host -Object \"Successfully set the 'Try the new outlook' toggle to the default for user '$Username'\"\r\n            return\r\n        }\r\n\r\n        # Ensure the base registry path exists; create it if necessary\r\n        $BasePath = $_.BasePath\r\n        if (!(Test-Path -Path $BasePath -ErrorAction SilentlyContinue)) {\r\n            # Create the missing base registry path\r\n            try {\r\n                New-Item -Path $BasePath -ErrorAction Stop | Out-Null\r\n            }\r\n            catch {\r\n                Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n                Write-Host -Object \"[Error] Failed to create the base path '$BasePath', which is required to set the registry key.\"\r\n                Write-Host -Object \"[Error] https:\/\/learn.microsoft.com\/en-us\/microsoft-365-apps\/outlook\/get-started\/control-install#prevent-users-from-switching-to-new-outlook\"\r\n                $ExitCode = 1\r\n                return\r\n            }\r\n        }\r\n\r\n        # Set the registry key value for the specified toggle policy\r\n        Set-RegKey -Path $_.Path -Name \"HideNewOutlookToggle\" -Value $RegValue\r\n        Write-Host -Object \"Successfully set the 'Try the new outlook' toggle for user '$Username'\"\r\n    }\r\n\r\n    # If user profiles were loaded during the process, unload their registry hives\r\n    if ($ProfileWasLoaded.Count -gt 0) {\r\n        ForEach ($UserProfile in $ProfileWasLoaded) {\r\n            # Collect garbage to release memory and avoid locking issues\r\n            [gc]::Collect()\r\n            Start-Sleep 1\r\n            # Unload the user's NTUSER.DAT registry hive\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    # Check whether a specific user is targeted for the policy, and output a message accordingly.\r\n    if ($UserToSetPolicyFor -and $ExitCode -eq 0) {\r\n        Write-Host -Object \"`nSuccessfully set the 'Try the new outlook' toggle for '$UserToSetPolicyFor'.  You may need to close and re-open Outlook for your change to take effect.\"\r\n    }\r\n    elseif ($ExitCode -eq 0) {\r\n        Write-Host -Object \"`nSuccessfully set the 'Try the New Outlook' toggle for all users. You may need to close and re-open Outlook for your change to take effect.\"\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 est structur\u00e9 en trois sections principales : validation des entr\u00e9es et d\u00e9tection de l&rsquo;environnement, gestion des profils et des ruches de registre, et modification du registre. Voici comment il fonctionne :<\/p>\n<h3>Param\u00e8tre d&rsquo;admission &amp; Validation<\/h3>\n<p>Le script accepte trois param\u00e8tres facultatifs :<\/p>\n<ul>\n<li><strong>-MigrationPolicy<\/strong> (Enable, Disable, Default)<\/li>\n<li><strong>-NewOutlookToggle<\/strong> (Hide Toggle, Show Toggle, Default)<\/li>\n<li><strong>-UserToSetPolicyFor<\/strong> (Target specific user, else apply to all)<\/li>\n<\/ul>\n<h3>V\u00e9rification de l&rsquo;environnement<\/h3>\n<p>Avant toute modification, le script :<\/p>\n<ul>\n<li>V\u00e9rifie s&rsquo;il est ex\u00e9cut\u00e9 avec des privil\u00e8ges administratifs<\/li>\n<li>D\u00e9tecte l&rsquo;appartenance \u00e0 un domaine<\/li>\n<li>Confirme la pr\u00e9sence d&rsquo;une installation de Microsoft Office<\/li>\n<\/ul>\n<h3>\u00c9num\u00e9ration des profils d&rsquo;utilisateurs<\/h3>\n<p>Il recherche tous les profils d&rsquo;utilisateurs locaux, de domaine et d&rsquo;AzureAD \u00e0 l&rsquo;aide de requ\u00eates dans le registre et de <strong>Win32_UserAccount<\/strong>, ce qui permet de s&rsquo;assurer que m\u00eame les profils inactifs peuvent \u00eatre modifi\u00e9s.<\/p>\n<h3>Gestion des ruches du registre<\/h3>\n<p>Si le r\u00e9pertoire de stockage d&rsquo;un utilisateur n&rsquo;est pas charg\u00e9, le script monte temporairement le fichier <strong>NTUSER.DAT<\/strong> de l&rsquo;utilisateur \u00e0 l&rsquo;aide de <strong>reg.exe<\/strong>, ce qui lui permet d&rsquo;appliquer les param\u00e8tres hors ligne.<\/p>\n<h3>D\u00e9finition des valeurs du registre<\/h3>\n<p>Deux cl\u00e9s sont g\u00e9r\u00e9es :<\/p>\n<ul>\n<li><strong>NewOutlookMigrationUserSetting :<\/strong> Contr\u00f4le la migration forc\u00e9e (DWORD : 0 pour d\u00e9sactiver, 1 pour activer)<\/li>\n<li><strong>HideNewOutlookToggle :<\/strong> Contr\u00f4le la visibilit\u00e9 du bouton (DWORD : 1 pour cacher, 0 pour montrer)<\/li>\n<\/ul>\n<h3>Nettoyage<\/h3>\n<p>Une fois les op\u00e9rations termin\u00e9es, le script d\u00e9charge les ruches (hive) qu&rsquo;il a charg\u00e9es.<\/p>\n<p>Un diagramme de flux illustrant le processus de d\u00e9cision pourrait servir d&rsquo;aide visuelle, par exemple :<br \/>\n<strong>Entr\u00e9e \u2192 Valider \u2192 D\u00e9tecter l&rsquo;environnement \u2192 Enum\u00e9rer les profils \u2192 Charger les ruches \u2192 Modifier le registre \u2192 D\u00e9charger les ruches<\/strong><\/p>\n<h2>Cas d&rsquo;utilisation potentiels<\/h2>\n<p><strong>Sc\u00e9nario<\/strong>\u00a0: Un fournisseur de services g\u00e9r\u00e9s (MSP) g\u00e8re 50 ordinateurs portables Windows 10 Pro dans plusieurs cliniques distantes. Les utilisateurs ont commenc\u00e9 \u00e0 recevoir des invitations \u00e0 passer au nouvel Outlook, ce qui a provoqu\u00e9 une certaine confusion, en particulier chez les membres du personnel plus \u00e2g\u00e9s, habitu\u00e9s \u00e0 l&rsquo;interface classique.<\/p>\n<p><strong>Solution<\/strong>\u00a0: L&rsquo;entreprise MSP int\u00e8gre ce script PowerShell dans une <a href=\"https:\/\/www.ninjaone.com\/fr\/rmm\/automatisation-des-taches\/\">t\u00e2che d&rsquo;automatisation NinjaOne<\/a>. Avec les param\u00e8tres d\u00e9finis pour d\u00e9sactiver la migration forc\u00e9e et masquer le bouton, le script garantit que tous les utilisateurs de la clinique conservent l&rsquo;exp\u00e9rience classique d&rsquo;Outlook. Il prend m\u00eame en compte les profils itin\u00e9rants et les machines reli\u00e9es \u00e0 un domaine.<\/p>\n<p><strong>R\u00e9sultat<\/strong> : Moins d&rsquo;appels d&rsquo;assistance, des utilisateurs plus satisfaits et un meilleur contr\u00f4le de l&rsquo;environnement client.<\/p>\n<h2>Comparaisons<\/h2>\n<p>La <strong>strat\u00e9gie de groupe (GPO)<\/strong>\u00a0est la m\u00e9thode traditionnelle de gestion des param\u00e8tres Office, y compris les configurations Outlook. Cependant, les GPO n\u00e9cessitent Active Directory, un temps de synchronisation et une connectivit\u00e9 r\u00e9seau. Elles ont \u00e9galement parfois contourn\u00e9es si les utilisateurs se connectent \u00e0 distance sans <a href=\"https:\/\/www.ninjaone.com\/fr\/it-hub\/endpoint-security\/qu-est-ce-qu-un-vpn-reseau-prive-virtuel\/\">VPN<\/a>.<\/p>\n<p>Les <strong>modifications manuelles du registre<\/strong>\u00a0offrent une certaine flexibilit\u00e9, mais demande beaucoup de travail et sont sujettes \u00e0 des erreurs.<\/p>\n<p><strong>L&rsquo;avantage des scripts PowerShell<\/strong> :<\/p>\n<ul>\n<li>Fonctionne avec et sans GPO<\/li>\n<li>Peut \u00eatre d\u00e9ploy\u00e9 \u00e0 l&rsquo;aide <a href=\"https:\/\/www.ninjaone.com\/fr\/rmm\/\">d&rsquo;outils RMM tels que NinjaOne<\/a><\/li>\n<li>S&rsquo;applique \u00e0 tous les utilisateurs ou \u00e0 des utilisateurs sp\u00e9cifiques, en ligne ou hors ligne<\/li>\n<li>Automatise le chargement du r\u00e9pertoire de stockage pour les profils inactifs<\/li>\n<\/ul>\n<h2>Questions fr\u00e9quentes<\/h2>\n<h3>Q\u00a0: Ce script remplacera-t-il les param\u00e8tres de la strat\u00e9gie de groupe ?<\/h3>\n<p>Non. Si des param\u00e8tres de strat\u00e9gie de groupe existent, ils remplaceront les modifications apport\u00e9es par ce script.<\/p>\n<h3>Q\u00a0: Peut-il \u00eatre ex\u00e9cut\u00e9 \u00e0 distance ?<\/h3>\n<p>Oui, \u00e0 condition qu&rsquo;il soit ex\u00e9cut\u00e9 avec des privil\u00e8ges administratifs et que l&rsquo;acc\u00e8s au registre requis soit disponible.<\/p>\n<h3>Q\u00a0: Que faire si Outlook n&rsquo;est pas install\u00e9 ?<\/h3>\n<p>Le script se termine de mani\u00e8re \u00e9l\u00e9gante et vous informe que Microsoft Office n&rsquo;a pas \u00e9t\u00e9 d\u00e9tect\u00e9.<\/p>\n<h3>Q\u00a0: Quel est l&rsquo;effet du param\u00e8tre \u00ab\u00a0Default\u00a0\u00bb ?<\/h3>\n<p>Il supprime la cl\u00e9 de registre, ce qui permet \u00e0 Outlook de revenir au comportement par d\u00e9faut de Microsoft.<\/p>\n<h2>Implications<\/h2>\n<p>La possibilit\u00e9 de\u00a0<strong>d\u00e9sactiver la migration forc\u00e9e vers le nouveau Outlook avec PowerShell<\/strong>\u00a0permet aux \u00e9quipes informatiques de garder le contr\u00f4le sur l&rsquo;exp\u00e9rience de l&rsquo;utilisateur. Toutefois, les administrateurs doivent surveiller l&rsquo;\u00e9volution des strat\u00e9gies de Microsoft afin d&rsquo;\u00e9viter les conflits entre les scripts locaux et les futures mises \u00e0 jour ou modifications des GPO.<\/p>\n<p>De plus, la gestion des cl\u00e9s de registre au niveau de l&rsquo;utilisateur, en particulier entre plusieurs profils, pr\u00e9sente des risques potentiels si elle n&rsquo;est pas ex\u00e9cut\u00e9e avec soin. Des scripts mal g\u00e9r\u00e9s peuvent corrompre les ruches d&rsquo;utilisateurs ou introduire des incoh\u00e9rences.<\/p>\n<h2>Recommandations<\/h2>\n<ul>\n<li><strong>Ex\u00e9cuter en tant qu&rsquo;administrateur<\/strong>\u00a0: Veillez toujours \u00e0 ce que le script soit ex\u00e9cut\u00e9 avec des privil\u00e8ges \u00e9lev\u00e9s.<\/li>\n<li><strong>Tesert en isolement<\/strong> : Ex\u00e9cutez le script sur une machine de test pour vous assurer de sa compatibilit\u00e9 avec votre environnement.<\/li>\n<li><strong>Utiliser la journalisation<\/strong> : Modifiez le script pour inclure la sortie du fichier journal \u00e0 des fins d&rsquo;audit.<\/li>\n<li><strong>Automatiser via le RMM<\/strong> : D\u00e9ployez le script \u00e0 l&rsquo;aide de NinjaOne pour une ex\u00e9cution constante et \u00e0 distance.<\/li>\n<li><strong>Surveiller les conflits de GPO<\/strong> : V\u00e9rifiez p\u00e9riodiquement si les strat\u00e9gies de groupe l&#8217;emportent sur les param\u00e8tres bas\u00e9s sur les scripts.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>Ce script offre une m\u00e9thode performante et adaptable pour\u00a0<strong>utiliser PowerShell pour activer ou d\u00e9sactiver la migration forc\u00e9e vers le nouveau Outlook<\/strong>, et \u00e9ventuellement contr\u00f4ler la visibilit\u00e9 du bouton de migration. Pour les MSP et les administrateurs informatiques, il comble le foss\u00e9 entre la configuration manuelle et la gestion centralis\u00e9e des GPO.<\/p>\n<p>En int\u00e9grant ce script aux\u00a0<a href=\"https:\/\/www.ninjaone.com\/fr\/rmm\/automatisation-informatique\/\">outils d&rsquo;automatisation de NinjaOne<\/a>, les administrateurs peuvent planifier, d\u00e9ployer et surveiller son ex\u00e9cution sur des flottes de terminaux, garantissant ainsi que les utilisateurs restent sur la version d&rsquo;Outlook qui r\u00e9pond le mieux aux besoins de l&rsquo;entreprise, sans intervention manuelle ni confusion pour l&rsquo;utilisateur.<\/p>\n<p>Que vous cherchiez \u00e0\u00a0<strong>d\u00e9sactiver la migration forc\u00e9e vers le nouveau Outlook avec PowerShell<\/strong>,\u00a0<strong>l&rsquo;activer<\/strong>\u00a0pour des utilisateurs sp\u00e9cifiques, ou simplement\u00a0<strong>g\u00e9rer la visibilit\u00e9 du bouton<\/strong>, ce script offre une solution flexible et puissante pour les environnements informatiques modernes.<\/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":[4287],"class_list":["post-534707","script_hub","type-script_hub","status-publish","hentry","script_hub_category-windows","use_cases-configuration-de-systeme"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/script_hub\/534707","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=534707"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/media?parent=534707"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/operating_system?post=534707"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/use_cases?post=534707"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}