{"id":531916,"date":"2025-09-25T01:53:00","date_gmt":"2025-09-25T01:53:00","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=531916"},"modified":"2025-09-25T01:53:00","modified_gmt":"2025-09-25T01:53:00","slug":"activer-ou-desactiver-l-affichage-des-fichiers-et-dossiers-caches-avec-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/fr\/script-hub\/activer-ou-desactiver-l-affichage-des-fichiers-et-dossiers-caches-avec-powershell\/","title":{"rendered":"Comment activer ou d\u00e9sactiver l&rsquo;affichage des fichiers et dossiers cach\u00e9s avec PowerShell ?"},"content":{"rendered":"<p>La gestion des environnements utilisateurs Windows \u00e0 grande \u00e9chelle est un exercice d&rsquo;\u00e9quilibre permanent 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>. Des configurations apparemment mineures, comme la visibilit\u00e9 des fichiers et dossiers cach\u00e9s, peuvent avoir un impact significatif sur la convivialit\u00e9, le d\u00e9pannage et m\u00eame la s\u00e9curit\u00e9. L&rsquo;automatisation de ce type de configuration sur plusieurs terminaux permet de maintenir la coh\u00e9rence et <a href=\"https:\/\/www.ninjaone.com\/fr\/efficacite\/\">l&rsquo;efficacit\u00e9<\/a>. Cet article explique <strong>comment activer ou d\u00e9sactiver l&rsquo;affichage des fichiers et dossiers cach\u00e9s avec PowerShell<\/strong>, soit par utilisateur, soit pour l&rsquo;ensemble du syst\u00e8me.<\/p>\n<h2>Contexte<\/h2>\n<p>L&rsquo;Explorateur Windows cache par d\u00e9faut certains fichiers syst\u00e8me et utilisateur afin de les prot\u00e9ger contre les modifications accidentelles. Cependant, les techniciens ont souvent besoin d&rsquo;exposer ces fichiers pour d\u00e9panner, configurer ou auditer les appareils. Plut\u00f4t que de cliquer manuellement sur les options de dossier ou les strat\u00e9gies de groupe, <a href=\"https:\/\/www.ninjaone.com\/it-hub\/endpoint-management\/what-is-powershell\/\">PowerShell<\/a> offre une alternative simplifi\u00e9e. Le script propos\u00e9 facilite ce processus avec souplesse : il peut appliquer les param\u00e8tres \u00e0 l&rsquo;utilisateur actuel ou \u00e0 tous les utilisateurs de l&rsquo;appareil, en fonction du contexte d&rsquo;ex\u00e9cution.<\/p>\n<p>Cette capacit\u00e9 est particuli\u00e8rement pr\u00e9cieuse dans les environnements g\u00e9r\u00e9s par des plateformes <a href=\"https:\/\/www.ninjaone.com\/fr\/blog\/definition-de-la-surveillance-et-gestion-a-distance\/\">RMM<\/a> comme NinjaOne, o\u00f9 l&rsquo;uniformit\u00e9 et le contr\u00f4le sont essentiels.<\/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    Enable or disable the viewing of hidden files and folders for all users (when run as 'System') or just the current user (when run as 'Current Logged On User').\r\n.DESCRIPTION\r\n    Enable or disable the viewing of hidden files and folders for all users (when run as 'System') or just the current user (when run as 'Current Logged On User').\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    -Action \"Enable\"\r\n\r\n    Enabling 'Show hidden files and folders' for all users.\r\n\r\n    Enabling 'Show hidden files and folders' for user 'tuser'.\r\n    Registry::HKEY_USERS\\S-1-5-21-2311417250-918970610-4221123468-1001\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced\\Hidden changed from 1 to 1\r\n\r\n    Enabling 'Show hidden files and folders' for user 'Administrator'.\r\n    Registry::HKEY_USERS\\S-1-5-21-2311417250-918970610-4221123468-500\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced\\Hidden changed from 2 to 1\r\n\r\n    Finished enabling 'Show hidden files and folders'.\r\n    \r\n    WARNING: You may need to restart Explorer.exe for the script to take effect immediately.\r\n\r\nPARAMETER: -Action \"ReplaceMeWithYourDesiredAction\"\r\n    Specify whether you would like to disable or enable the viewing of hidden files or folders. Valid actions are 'Enable' or 'Disable'.\r\n\r\nPARAMETER: -RestartExplorer\r\n    You may need to restart explorer.exe for this script to take effect immediately. Use this switch to do so upon completion.\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]$Action,\r\n    [Parameter()]\r\n    [Switch]$RestartExplorer = [System.Convert]::ToBoolean($env:restartExplorer)\r\n)\r\n\r\nbegin {\r\n    # Check if the environment variable 'action' is set and is not null\r\n    if ($env:action -and $env:action -notlike \"null\") { $Action = $env:action }\r\n\r\n    # If $Action has a value, trim any leading or trailing whitespace\r\n    if ($Action) {\r\n        $Action = $Action.Trim()\r\n    }\r\n\r\n    # If $Action is empty or null after trimming, display an error message indicating that an action must be specified\r\n    if (!$Action) {\r\n        Write-Host -Object \"[Error] You must specify an action.\"\r\n        exit 1\r\n    }\r\n\r\n    # Define a list of valid actions: \"Enable\" and \"Disable\"\r\n    $ValidActions = \"Enable\", \"Disable\"\r\n\r\n    # Check if the value of $Action is not one of the valid actions\r\n    if ($ValidActions -notcontains $Action) {\r\n        Write-Host -Object \"[Error] Invalid action '$Action' provided. Please specify either 'Enable' or 'Disable'.\"\r\n        exit 1\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        $UserProfiles = Foreach ($Pattern in $Patterns) { \r\n            try {\r\n                Get-ItemProperty \"HKLM:\\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 = \"UserHive\"; Expression = { \"$($_.ProfileImagePath)\\NTuser.dat\" } }, \r\n                    @{Name = \"Path\"; Expression = { $_.ProfileImagePath } }\r\n            }\r\n            catch {\r\n                Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n            }\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.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        # Return the list of user profiles, excluding any specified in the ExcludedUsers list\r\n        $UserProfiles | Where-Object { $ExcludedUsers -notcontains $_.Username }\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            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        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    function Test-IsSystem {\r\n        # Get the current Windows identity of the user running the script\r\n        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n    \r\n        # Check if the current identity's name matches \"NT AUTHORITY*\"\r\n        # or if the identity represents the SYSTEM account\r\n        return $id.Name -like \"NT AUTHORITY*\" -or $id.IsSystem\r\n    }\r\n\r\n    if (!$ExitCode) {\r\n        $ExitCode = 0\r\n    }\r\n}\r\nprocess {\r\n    # Retrieve all user profile registry hives (including system profiles).\r\n    $UserProfiles = Get-UserHives -Type \"All\"\r\n\r\n    # Check if the script is not running as the system account.\r\n    if (!(Test-IsSystem)) {\r\n        # Depending on the value of $Action, display the corresponding message for the current user.\r\n        switch ($Action) {\r\n            \"Enable\" { Write-Host -Object \"Enabling 'Show hidden files and folders' for the current user.\" }\r\n            \"Disable\" { Write-Host -Object \"Disabling 'Show hidden files and folders' for the current user.\" }\r\n        }\r\n\r\n        # Filter user profiles to only include the current user's SID.\r\n        try {\r\n            $UserProfiles = $UserProfiles | Where-Object { $_.SID -match \"$([System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value)\" }\r\n        }\r\n        catch {\r\n            # If an error occurs (e.g., failed to retrieve the current user's SID), display an error and exit.\r\n            Write-Host -Object \"[Error] Failed to get current user's SID.\"\r\n            Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n            exit 1\r\n        }\r\n    }\r\n    else {\r\n        # If running as the system account, display a message for all users depending on the value of $Action.\r\n        switch ($Action) {\r\n            \"Enable\" { Write-Host -Object \"Enabling 'Show hidden files and folders' for all users.\" }\r\n            \"Disable\" { Write-Host -Object \"Disabling 'Show hidden files and folders' for all users.\" }\r\n        }\r\n    }\r\n\r\n    # Create a list to track which user profiles had their NTuser.dat loaded.\r\n    $ProfileWasLoaded = New-Object System.Collections.Generic.List[object]\r\n\r\n    # Check if any user profiles were retrieved.\r\n    if (!$UserProfiles) {\r\n        Write-Host -Object \"[Error] No user profiles found.\"\r\n        exit 1\r\n    }\r\n\r\n    # Iterate through each user profile.\r\n    ForEach ($UserProfile in $UserProfiles) {\r\n        # Check if the NTuser.dat file (the user's registry hive) is not already loaded for the user.\r\n        If (!(Test-Path -Path Registry::HKEY_USERS\\$($UserProfile.SID) -ErrorAction SilentlyContinue)) {\r\n            # Load the user's NTuser.dat into the registry under HKEY_USERS using reg.exe.\r\n            Start-Process -FilePath \"cmd.exe\" -ArgumentList \"\/C reg.exe LOAD HKU\\$($UserProfile.SID) `\"$($UserProfile.UserHive)`\"\" -Wait -WindowStyle Hidden\r\n            \r\n            # Add the profile to the list of loaded profiles for later unloading.\r\n            $ProfileWasLoaded.Add($UserProfile)\r\n        }\r\n    }\r\n\r\n    # Set the appropriate registry value for hidden files based on the $Action.\r\n    switch ($Action) {\r\n        \"Enable\" { $HiddenFilesValue = 1 }\r\n        \"Disable\" { $HiddenFilesValue = 2 }\r\n    }\r\n\r\n    # Iterate through each user profile to apply the registry change.\r\n    ForEach ($UserProfile in $UserProfiles) {\r\n        $CurrentHiddenFilesOption = Get-ItemProperty -Path \"Registry::HKEY_USERS\\$($UserProfile.SID)\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced\" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty \"Hidden\"\r\n\r\n        # If the requested action has already been applied, display a message indicating the action has already been applied for the user.\r\n        if ($HiddenFilesValue -eq $CurrentHiddenFilesOption) {\r\n            switch ($Action) {\r\n                \"Enable\" { Write-Host -Object \"`n'Show hidden files and folders' is already enabled for user '$($UserProfile.Username)'.\" }\r\n                \"Disable\" { Write-Host -Object \"`n'Show hidden files and folders' is already disabled for user '$($UserProfile.Username)'.\" }\r\n            }\r\n            continue\r\n        }\r\n\r\n        # Display a message indicating the action being applied for the user.\r\n        switch ($Action) {\r\n            \"Enable\" { Write-Host -Object \"`nEnabling 'Show hidden files and folders' for user '$($UserProfile.Username)'.\" }\r\n            \"Disable\" { Write-Host -Object \"`nDisabling 'Show hidden files and folders' for user '$($UserProfile.Username)'.\" }\r\n        }\r\n\r\n        # Modify the registry key to set the visibility of hidden files and folders for the user.\r\n        Set-RegKey -Path \"Registry::HKEY_USERS\\$($UserProfile.SID)\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced\" -Name \"Hidden\" -Value $HiddenFilesValue\r\n    }\r\n\r\n    # Display a final message indicating that the process is complete.\r\n    switch ($Action) {\r\n        \"Enable\" { Write-Host -Object \"`nFinished enabling 'Show hidden files and folders'.\" }\r\n        \"Disable\" { Write-Host -Object \"`nFinished disabling 'Show hidden files and folders'.\" }\r\n    }\r\n\r\n    # Unload NTuser.dat for any profiles that were loaded earlier.\r\n    if ($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 if the $RestartExplorer flag is set\r\n    if ($RestartExplorer) {\r\n        # Display a message indicating that Explorer.exe is being restarted\r\n        Write-Host \"`nRestarting Explorer.exe as requested.\"\r\n\r\n        try {\r\n            # Stop all instances of Explorer\r\n            if (Test-IsSystem) {\r\n                Get-Process -Name \"explorer\" | Stop-Process -Force -ErrorAction Stop\r\n            }\r\n            else {\r\n                Get-Process -Name \"explorer\" | Where-Object { $_.SI -eq (Get-Process -PID $PID).SessionId } | Stop-Process -Force -ErrorAction Stop\r\n            }\r\n        }\r\n        catch {\r\n            Write-Host -Object \"[Error] Failed to stop explorer.exe\"\r\n            Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n            $ExitCode = 1\r\n        }\r\n        \r\n        # Pause for 1 second to ensure processes have fully stopped before restarting\r\n        Start-Sleep -Seconds 1\r\n    \r\n        # If not running as the System account and Explorer.exe is not already running, start a new instance\r\n        if (!(Test-IsSystem) -and !(Get-Process -Name \"explorer\" -ErrorAction SilentlyContinue)) {\r\n            try {\r\n                Start-Process -FilePath \"$env:SystemRoot\\explorer.exe\" -Wait -ErrorAction Stop\r\n            }\r\n            catch {\r\n                Write-Host -Object \"[Error] Failed to start explorer.exe\"\r\n                Write-Host -Object \"[Error] $($_.Exception.Message)\"\r\n                $ExitCode = 1\r\n            }\r\n        }\r\n    }\r\n    else {\r\n        # If $RestartExplorer is not set, warn the user that they may need to manually restart Explorer.exe\r\n        Write-Host -Object \"\"\r\n        Write-Warning -Message \"You may need to restart Explorer.exe for the script to take effect immediately.\"\r\n    }\r\n\r\n    # Exit the script with the predefined $ExitCode.\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>Le script fonctionne en plusieurs \u00e9tapes :<\/p>\n<ol>\n<li><strong>Traitement des entr\u00e9es<\/strong><strong><br \/>\n<\/strong>Il accepte un param\u00e8tre -Action (Enable ou Disable) et un commutateur facultatif -RestartExplorer. Ceux-ci peuvent \u00eatre transmis directement ou par l&rsquo;interm\u00e9diaire de variables d&rsquo;environnement, ce qui permet de mettre en place des pipelines d&rsquo;automatisation.<\/li>\n<li><strong>Validation et pr\u00e9paration<\/strong><strong><br \/>\n<\/strong>Il v\u00e9rifie le param\u00e8tre d&rsquo;action et pr\u00e9pare les fonctions d&rsquo;aide :<\/p>\n<ul>\n<li>Get-UserHives : R\u00e9cup\u00e8re toutes les ruches (hive) du registre utilisateur (charg\u00e9es ou non).<\/li>\n<li>Set-RegKey : Modifie le registre pour refl\u00e9ter les pr\u00e9f\u00e9rences en mati\u00e8re de fichiers cach\u00e9s.<\/li>\n<li>Test-IsSystem : V\u00e9rifie si le script est ex\u00e9cut\u00e9 en tant que SYST\u00c8ME.<\/li>\n<\/ul>\n<\/li>\n<li><strong>D\u00e9tection de profil<\/strong><strong><br \/>\n<\/strong>S&rsquo;il est ex\u00e9cut\u00e9 en tant que SYST\u00c8ME (par exemple, via NinjaOne ou le planificateur de t\u00e2ches), le script cible\u00a0<strong>tous les utilisateurs.<\/strong> Dans le cas contraire, il modifie les param\u00e8tres pour\u00a0<strong>uniquement pour l&rsquo;utilisateur actuel<\/strong>.<\/li>\n<li><strong>Chargement de ruche<\/strong><strong><br \/>\n<\/strong>Pour les profils d&rsquo;utilisateur non charg\u00e9s, il monte temporairement les fichiers NTUSER.DAT dans HKEY_USERS \u00e0 l&rsquo;aide de reg.exe.<\/li>\n<li><strong>Modification du registre<\/strong><strong><br \/>\n<\/strong>Pour chaque profil :<\/p>\n<ul>\n<li>Il v\u00e9rifie les param\u00e8tres actuels (cach\u00e9 sous HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced)<\/li>\n<li>Si la valeur diff\u00e8re de celle souhait\u00e9e (1 pour Afficher, 2 pour Cacher), il met \u00e0 jour la cl\u00e9.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Nettoyage et finalisation<\/strong><strong><br \/>\n<\/strong>Les ruches charg\u00e9es sont d\u00e9charg\u00e9es afin d&rsquo;\u00e9viter la persistance des poign\u00e9es de registre. Si l&rsquo;option -RestartExplorer est sp\u00e9cifi\u00e9e, le script s&rsquo;arr\u00eate et (re)d\u00e9marre explorer.exe pour que les modifications s&rsquo;appliquent imm\u00e9diatement.<\/li>\n<\/ol>\n<h2>Cas d&rsquo;utilisation potentiels<\/h2>\n<h3>\u00c9tude de cas\u00a0: Standardiser la visibilit\u00e9 pour le personnel du service d&rsquo;assistance<\/h3>\n<p>L&rsquo;\u00e9quipe d&rsquo;un service d&rsquo;assistance prend r\u00e9guli\u00e8rement en charge un large \u00e9ventail d&rsquo;applications, dont certaines stockent des journaux dans des dossiers cach\u00e9s. Pour r\u00e9duire les temps d&rsquo;appel et les clics r\u00e9p\u00e9titifs, l&rsquo;administrateur informatique d\u00e9ploie ce script sur tous les postes de travail des techniciens avec le param\u00e8tre -Action \u00ab\u00a0Enable\u00a0\u00bb via NinjaOne. Cela garantit la visibilit\u00e9 des fichiers essentiels dans tous les profils, am\u00e9liorant ainsi l&rsquo;efficacit\u00e9 op\u00e9rationnelle sans modifier la strat\u00e9gie de groupe.<\/p>\n<p>Par ailleurs, un fournisseur de services g\u00e9r\u00e9s (MSP) peut utiliser l&rsquo;action \u00ab\u00a0Disable\u00a0\u00bb pour les machines en contact avec les clients afin de renforcer leur s\u00e9curit\u00e9 en masquant les fichiers syst\u00e8me sensibles.<\/p>\n<h2><strong>Comparaisons<\/strong><\/h2>\n<p>Cette approche PowerShell offre plusieurs avantages par rapport aux m\u00e9thodes traditionnelles :<\/p>\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>Strat\u00e9gie de groupe (GPO)<\/strong><\/td>\n<td>Mise en \u0153uvre \u00e0 l&rsquo;\u00e9chelle de l&rsquo;entreprise<\/td>\n<td>N\u00e9cessite Active Directory, manque de nuances en fonction de l&rsquo;utilisateur<\/td>\n<\/tr>\n<tr>\n<td><strong>Configuration manuelle de l&rsquo;interface graphique<\/strong><\/td>\n<td>Simple pour une utilisation individuelle<\/td>\n<td>Non \u00e9volutif<\/td>\n<\/tr>\n<tr>\n<td><strong>PowerShell (ce script)<\/strong><\/td>\n<td>Scriptable, flexible, sp\u00e9cifique \u00e0 l&rsquo;utilisateur<\/td>\n<td>N\u00e9cessite un contexte d&rsquo;administration pour les op\u00e9rations SYST\u00c8ME<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Contrairement \u00e0 la strat\u00e9gie de groupe, ce script fonctionne sans d\u00e9pendance de domaine et peut cibler \u00e0 la fois les utilisateurs locaux et ceux d&rsquo;<a href=\"https:\/\/www.ninjaone.com\/blog\/azure-ad-vs-active-directory-whats-the-difference\/\">AzureAD<\/a>. Il s&rsquo;adapte \u00e9galement aux syst\u00e8mes dont les profils ne sont pas charg\u00e9s, ce que les modifications de l&rsquo;interface graphique ne peuvent pas faire si l&rsquo;utilisateur n&rsquo;est pas connect\u00e9.<\/p>\n<h2>FAQ<\/h2>\n<h3>Q\u00a0: Ce script fonctionnera-t-il pour les utilisateurs distants qui ne se sont pas encore connect\u00e9s ?<\/h3>\n<p>Oui, il peut s&rsquo;appliquer \u00e0 des profils non charg\u00e9s en acc\u00e9dant directement au fichier NTUSER.DAT.<\/p>\n<h3>Q\u00a0: La modification s&rsquo;applique-t-elle imm\u00e9diatement ?<\/h3>\n<p>Pas n\u00e9cessairement. Explorer peut mettre en cache les param\u00e8tres d&rsquo;affichage des dossiers. Utilisez -RestartExplorer pour forcer l&rsquo;application imm\u00e9diate.<\/p>\n<h3>Q\u00a0: Que se passe-t-il si je r\u00e9ex\u00e9cute le script ?<\/h3>\n<p>Si le param\u00e8tre correspond d\u00e9j\u00e0 \u00e0 l&rsquo;\u00e9tat souhait\u00e9, le script n&rsquo;applique pas les modifications et indique qu&rsquo;il a d\u00e9j\u00e0 \u00e9t\u00e9 d\u00e9fini.<\/p>\n<h3>Q\u00a0: Puis-je l&rsquo;utiliser dans une t\u00e2che planifi\u00e9e de NinjaOne ?<\/h3>\n<p>Absolument. Il suffit de s&rsquo;assurer qu&rsquo;il est ex\u00e9cut\u00e9 avec les privil\u00e8ges SYST\u00c8ME pour que tous les utilisateurs soient pris en compte.<\/p>\n<h2>Implications<\/h2>\n<p>Du point de vue de la s\u00e9curit\u00e9, le masquage des fichiers permet de prot\u00e9ger les composants sensibles du syst\u00e8me d&rsquo;exploitation. L&rsquo;activation de la visibilit\u00e9 sur l&rsquo;ensemble du syst\u00e8me peut accro\u00eetre les risques pour les utilisateurs, en particulier sur les terminaux partag\u00e9s ou publics. Les administrateurs informatiques doivent trouver un \u00e9quilibre entre la facilit\u00e9 d&rsquo;utilisation et le respect des r\u00e8gles. Inversement, la d\u00e9sactivation de la visibilit\u00e9 peut renforcer le durcissement des terminaux et r\u00e9duire les manipulations accidentelles par les utilisateurs finaux.<\/p>\n<h2>Recommandations<\/h2>\n<ul>\n<li><strong>Testez dans un environnement d&rsquo;essai<\/strong>\u00a0avant de proc\u00e9der \u00e0 un d\u00e9ploiement massif.<\/li>\n<li>Toujours\u00a0<strong>inclure la journalisation<\/strong>\u00a0lors de l&rsquo;ex\u00e9cution par l&rsquo;automatisation pour capturer les r\u00e9sultats.<\/li>\n<li>Utilisez -RestartExplorer avec prudence, en particulier sur les syst\u00e8mes multi-utilisateurs, car le red\u00e9marrage de l&rsquo;explorateur peut perturber les flux de travail.<\/li>\n<li>Envisagez\u00a0<strong>d&rsquo;int\u00e9grer ce script aux strat\u00e9gies d&rsquo;automatisation de NinjaOne<\/strong>\u00a0pour renforcer la normalisation dans le cadre de l&rsquo;int\u00e9gration des appareils.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>La gestion de la visibilit\u00e9 des fichiers est un aspect mineur mais significatif de l&rsquo;hygi\u00e8ne des terminaux. Ce script PowerShell permet aux professionnels de l&rsquo;informatique de contr\u00f4ler avec pr\u00e9cision un param\u00e8tre souvent n\u00e9glig\u00e9, mais qui joue un r\u00f4le essentiel dans les flux de travail d&rsquo;assistance et les configurations de s\u00e9curit\u00e9.<\/p>\n<p>Lorsqu&rsquo;il est associ\u00e9 \u00e0\u00a0<a href=\"https:\/\/www.ninjaone.com\/fr\/\"><strong>NinjaOne<\/strong><\/a> ce script devient un puissant outil d&rsquo;automatisation. Qu&rsquo;il s&rsquo;agisse de pousser cette configuration sur des centaines de terminaux ou de personnaliser la visibilit\u00e9 par r\u00f4le, les fonctions d&rsquo;automatisation et de planification des scripts de NinjaOne garantissent une ex\u00e9cution constante avec un minimum de frais g\u00e9n\u00e9raux.<\/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-531916","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\/531916","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=531916"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/media?parent=531916"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/operating_system?post=531916"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/use_cases?post=531916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}