Voir la démo×
×

Voir NinjaOne en action !

En soumettant ce formulaire, j'accepte la politique de confidentialité de NinjaOne.

Script PowerShell : comment rationaliser la gestion des fonds d’écran dans Windows

Principaux points à retenir

  • Automatise les changements de fonds d’écran : le script automatise le processus de définition des fonds d’écran pour plusieurs profils d’utilisateurs dans les environnements Windows.
  • Permet de gagner du temps et d’assurer une cohérence : idéal pour les professionnels de l’informatique et les MSP qui gèrent plusieurs ordinateurs, afin de garantir l’uniformité et la conformité de la marque.
  • Des paramètres flexibles : permet de personnaliser les paramètres de l’URL de l’image, du répertoire de stockage et du style de fond d’écran.
  • Des fonctionnalités à effet immédiat : inclut des options pour remplacer les fichiers de fond d’écran transcodés et redémarrer Explorer pour une modification immédiate.
  • Adapté aux différentes versions de Windows : conçu pour Windows 7 et les versions plus récentes, bien que certaines caractéristiques puissent varier dans les versions plus anciennes.
  • Une prise en charge des formats d’image courants : compatible avec les formats d’image les plus courants tels que JPG, PNG, BMP et GIF.
  • Questions relatives à la sécurité : implique la modification des paramètres de la base de registre et des fichiers système ; une bonne gestion des autorisations de script est cruciale.
  • Des tests complets sont recommandés : effectuez des tests approfondis dans des environnements contrôlés avant le déploiement à l’échelle du réseau.
  • S’intègre aux outils de gestion informatique : peut être intégré de manière transparente dans des plateformes de gestion informatique telles que NinjaOne pour un déploiement et une surveillance efficaces.
  • Documentez et vérifiez l’utilisation des scripts : maintenez des journaux concernant l’utilisation de scripts afin de faciliter l’audit et le dépannage.

La modification du fond d’écran de plusieurs profils d’utilisateurs dans un environnement Windows est une tâche à laquelle les professionnels de l’informatique sont souvent confrontés. Que ce soit à des fins d’image de marque, de conformité ou simplement pour changer un peu l’espace de travail, l’automatisation de ce processus permet de gagner du temps et d’assurer une cohérence. Les scripts PowerShell sont devenus des outils indispensables dans la boîte à outils informatique, offrant des solutions puissantes et flexibles pour de telles tâches.

Contexte

Le script en question est conçu pour automatiser le processus de définition des fonds d’écran pour tous les profils d’utilisateurs sur un système Windows. Cette capacité est particulièrement précieuse pour les professionnels de l’informatique et les fournisseurs de services gérés (MSP) qui gèrent un grand nombre d’ordinateurs. Il permet d’uniformiser les environnements d’entreprise, garantissant que tous les utilisateurs ont le même fond d’écran, ce qui peut être vital pour l’image de marque ou la transmission d’informations importantes.

Le script PowerShell :

<#
.SYNOPSIS
    This sets the desktop wallpaper for all existing users (if run as System) or the currently logged-in user. To have the wallpaper change take effect immediately please select "Replace Transcoded Wallpaper File" and "Restart Explorer". These options may not work on Windows 7 and Server 2008.
.DESCRIPTION
    This sets the desktop wallpaper for all existing users (if run as System) or the currently logged-in user. 
    To have the wallpaper change take effect immediately please select "Replace Transcoded Wallpaper File" and "Restart Explorer". 
    These options may not work on Windows 7 and Server 2008.
.EXAMPLE
    (No Parameters) - Windows 10

    C:ProgramDataNinjaRMMAgentscriptingcustomscript_gen_55.ps1 : No image given!
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,customscript_gen_55.ps1

PARAMETER: -Url "https://www.example.com/image.png"
    A link to the wallpaper you would like to set.

PARAMETER: -Directory "C:ExampleExample"
    A location to store the wallpaper.

.EXAMPLE
    -Url "https://www.microsoft.com/en-us/microsoft-365/blog/wp-content/uploads/sites/2/2021/06/Msft_Nostalgia_Landscape.jpg" -Directory "C:ProgramDataWallpaper" (Windows 10 as System)
    
    WARNING: Restarting Explorer.exe is required for wallpaper change to take effect!
    URL Given, Downloading the file...
    Download Attempt 1

    Registry::HKEY_USERSS-1-5-21-3600085911-33463358-3311494591-1103Control PanelDesktopWallpaper changed from C:ProgramDataWallpaperwallpaper-686581913.jpg to C:ProgramDataWallpaperwallpaper-1935193304.jpg
    Registry::HKEY_USERSS-1-5-21-3600085911-33463358-3311494591-1103Control PanelDesktopWallpaperStyle changed from 10 to 10
    Registry::HKEY_USERSS-1-5-21-3600085911-33463358-3311494591-1103Control PanelDesktopTileWallpaper changed from 0 to 0
    WARNING: Replacing the wallpaper transcoded file is required for wallpaper change to take immediate effect.

    Registry::HKEY_USERSS-1-5-21-3870645062-3653562310-3850680542-1002Control PanelDesktopWallpaper changed from C:ProgramDataWallpaperwallpaper-686581913.jpg to C:ProgramDataWallpaperwallpaper-1935193304.jpg
    Registry::HKEY_USERSS-1-5-21-3870645062-3653562310-3850680542-1002Control PanelDesktopWallpaperStyle changed from 10 to 10
    Registry::HKEY_USERSS-1-5-21-3870645062-3653562310-3850680542-1002Control PanelDesktopTileWallpaper changed from 0 to 0
    WARNING: Replacing the wallpaper transcoded file is required for wallpaper change to take immediate effect.

    Registry::HKEY_USERSS-1-5-21-3870645062-3653562310-3850680542-1003Control PanelDesktopWallpaper changed from C:ProgramDataWallpaperwallpaper-686581913.jpg to C:ProgramDataWallpaperwallpaper-1935193304.jpg
    Registry::HKEY_USERSS-1-5-21-3870645062-3653562310-3850680542-1003Control PanelDesktopWallpaperStyle changed from 10 to 10
    Registry::HKEY_USERSS-1-5-21-3870645062-3653562310-3850680542-1003Control PanelDesktopTileWallpaper changed from 0 to 0
    WARNING: Replacing the wallpaper transcoded file is required for wallpaper change to take immediate effect.

    Registry::HKEY_USERSS-1-5-21-3870645062-3653562310-3850680542-1004Control PanelDesktopWallpaper changed from C:ProgramDataWallpaperwallpaper-686581913.jpg to C:ProgramDataWallpaperwallpaper-1935193304.jpg
    Registry::HKEY_USERSS-1-5-21-3870645062-3653562310-3850680542-1004Control PanelDesktopWallpaperStyle changed from 10 to 10
    Registry::HKEY_USERSS-1-5-21-3870645062-3653562310-3850680542-1004Control PanelDesktopTileWallpaper changed from 0 to 0
    WARNING: Replacing the wallpaper transcoded file is required for wallpaper change to take immediate effect.

PARAMETER: -WallpaperStyle "Fill"
    This will set the wallpaper style to the appropriate option. Valid Options: "Fill", "Fit", "Stretch", "Tile", "Center", "Span"

PARAMETER: -ReplaceTranscodedWallpaperFile
    This will replace the file %APPDATA%MicrosoftWindowsThemesTranscodedWallpaper. This file is generated whenever the wallpaper is changed and is required for the wallpaper change to take immediate effect.

PARAMETER: -RestartExplorer
    This will restart explorer.exe. This is required for the wallpaper change to take immediate effect.

.OUTPUTS
    None
.NOTES
    Minimum Supported OS: Windows 7+, Server 2008+
    Release Notes: Initial Release
By 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.
    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. 
    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. 
    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. 
    Warranty Disclaimer: The script is provided “as is” and “as available”, 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. 
    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. 
    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. 
    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).
#>

[CmdletBinding()]
param (
    [Parameter()]
    [String]$Url,
    [Parameter()]
    [String]$Directory,
    [Parameter()]
    [String]$WallpaperStyle = "Fill",
    [Parameter()]
    [Switch]$ReplaceTranscodedWallpaperFile = [System.Convert]::ToBoolean($env:replaceTranscodedWallpaperFile),
    [Parameter()]
    [Switch]$RestartExplorer = [System.Convert]::ToBoolean($env:restartExplorer)
)

begin {

    # Set Dynamic Script Variables (if used)
    if ($env:localWallpaperFile -and $env:localWallpaperFile -notlike "null") { $ExistingImage = $env:localWallpaperFile }
    if ($env:directoryToStoreWallpaperIn -and $env:directoryToStoreWallpaperIn -notlike "null") { $Directory = $env:directoryToStoreWallpaperIn }
    if ($env:linkToWallpaperFile -and $env:linkToWallpaperFile -notlike "null") { $Url = $env:linkToWallpaperFile }
    if ($env:wallpaperDisplayMode -and $env:wallpaperDisplayMode -notlike "null") { $WallpaperStyle = $env:wallpaperDisplayMode }

    # Validate that we received a correct value for the wallpaper style
    $AllowedFit = "Fill", "Fit", "Stretch", "Tile", "Center", "Span"
    if ($AllowedFit -notcontains $WallpaperStyle) {
        Write-Error "[Error] Invalid Wallpaper Display Mode selected. Please use one of the following options. Fill, Fit, Stretch, Tile, Center or Span."
        exit 1
    }

    # If the local file we were told to use doesn't exist we should ignore it.
    if ($ExistingImage -and -not (Test-Path $ExistingImage -ErrorAction SilentlyContinue)) {
        Write-Warning "Existing wallpaper does not exist. Ignoring..."
        $ExistingImage = $Null
    }

    # If we weren't given a link or a local file to use we should error out.
    if (-not ($Url) -and -not ($ExistingImage)) {
        Write-Error "No image given!"
        Exit 1
    }

    # If we don't have a place to store the file and it doesn't already exist we should error out.
    if (-not ($Directory) -and -not ($ExistingImage)) {
        Write-Error "You must specify a location to store the wallpaper."
        Exit 1
    }

    # Create the directory if it does not exist.
    if ($Directory -and -not (Test-Path -Path $Directory -ErrorAction SilentlyContinue)) {
        try {
            New-Item -Path $Directory -ItemType Directory -ErrorAction Stop | Out-Null
        }
        catch {
            Write-Error "Failed to create directory!"
            Exit 1
        }
    }

    # Warn the end-user that the wallpaper change will not take immediate effect.
    if (-not ($RestartExplorer)) {
        Write-Warning "Restarting Explorer.exe is required for wallpaper change to take effect!"
    }

    # Handy download function.
    function Invoke-Download {
        param(
            [Parameter()]
            [String]$URL,
            [Parameter()]
            [String]$BaseName,
            [Parameter()]
            [Switch]$SkipSleep
        )
        Write-Host "URL Given, Downloading the file..."

        $SupportedTLSversions = [enum]::GetValues('Net.SecurityProtocolType')
        if ( ($SupportedTLSversions -contains 'Tls13') -and ($SupportedTLSversions -contains 'Tls12') ) {
            [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol::Tls13 -bor [System.Net.SecurityProtocolType]::Tls12
        }
        elseif ( $SupportedTLSversions -contains 'Tls12' ) {
            [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
        }
        else {
            # Not everything requires TLS 1.2, but we'll try anyways.
            Write-Warning "TLS 1.2 and or TLS 1.3 isn't supported on this system. This download may fail!"
            if ($PSVersionTable.PSVersion.Major -lt 3) {
                Write-Warning "PowerShell 2 / .NET 2.0 doesn't support TLS 1.2."
            }
        }

        $i = 1
        While ($i -lt 4) {
            if (-not ($SkipSleep)) {
                $SleepTime = Get-Random -Minimum 3 -Maximum 30
                Start-Sleep -Seconds $SleepTime
            }

            Write-Host "Download Attempt $i"

            try {
                $WebClient = New-Object System.Net.WebClient
                $Response = $WebClient.OpenRead($Url)
                $MimeType = $WebClient.ResponseHeaders["Content-Type"]
                $DesiredExtension = switch -regex ($MimeType) {
                    "image/jpeg|image/jpg" { "jpg" }
                    "image/png" { "png" }
                    "image/gif" { "gif" }
                    "image/bmp|image/x-windows-bmp|image/x-bmp" { "bmp" }
                    default { 
                        Write-Error "The URL you provided does not provide a supported image type. Image Types Supported: jpg, jpeg, bmp, png and gif. Image Type detected: $MimeType"
                        Exit 1 
                    }
                }
                $Path = "$BaseName.$DesiredExtension"
                $WebClient.DownloadFile($URL, $Path)
                $File = Test-Path -Path $Path -ErrorAction SilentlyContinue
                $Response.Close()
            }
            catch {
                if ($Response) { $Response.Close() }
                Write-Warning "An error has occured while downloading!"
                Write-Warning $_.Exception.Message
            }

            if ($File) {
                $i = 4
            }
            else {
                $i++
            }
        }

        if (-not (Test-Path $Path)) {
            Write-Error "Failed to download file!"
            Exit 1
        }

        $Path
    }

    # Get a list of all the user profiles for when the script is ran as System.
    function Get-UserHives {
        param (
            [Parameter()]
            [ValidateSet('AzureAD', 'DomainAndLocal', 'All')]
            [String]$Type = "All",
            [Parameter()]
            [String[]]$ExcludedUsers,
            [Parameter()]
            [switch]$IncludeDefault
        )
    
        # User account SID's follow a particular patter depending on if they're Azure AD or a Domain account or a local "workgroup" account.
        $Patterns = switch ($Type) {
            "AzureAD" { "S-1-12-1-(d+-?){4}$" }
            "DomainAndLocal" { "S-1-5-21-(d+-?){4}$" }
            "All" { "S-1-12-1-(d+-?){4}$" ; "S-1-5-21-(d+-?){4}$" } 
        }
    
        # We'll need the NTuser.dat file to load each users registry hive. So we grab it if their account sid matches the above pattern. 
        $UserProfiles = Foreach ($Pattern in $Patterns) { 
            Get-ItemProperty "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionProfileList*" |
                Where-Object { $_.PSChildName -match $Pattern } | 
                Select-Object @{Name = "SID"; Expression = { $_.PSChildName } },
                @{Name = "UserName"; Expression = { "$($_.ProfileImagePath | Split-Path -Leaf)" } }, 
                @{Name = "UserHive"; Expression = { "$($_.ProfileImagePath)NTuser.dat" } }, 
                @{Name = "Path"; Expression = { $_.ProfileImagePath } }
        }
    
        # There are some situations where grabbing the .Default user's info is needed.
        switch ($IncludeDefault) {
            $True {
                $DefaultProfile = "" | Select-Object UserName, SID, UserHive, Path
                $DefaultProfile.UserName = "Default"
                $DefaultProfile.SID = "DefaultProfile"
                $DefaultProfile.Userhive = "$env:SystemDriveUsersDefaultNTUSER.DAT"
                $DefaultProfile.Path = "C:UsersDefault"
    
                $DefaultProfile | Where-Object { $ExcludedUsers -notcontains $_.UserName }
            }
        }
    
        $UserProfiles | Where-Object { $ExcludedUsers -notcontains $_.UserName }
    }

    # This makes setting registry keys A LOT easier.
    function Set-HKProperty {
        param (
            $Path,
            $Name,
            $Value,
            [ValidateSet('DWord', 'QWord', 'String', 'ExpandedString', 'Binary', 'MultiString', 'Unknown')]
            $PropertyType = 'DWord'
        )
        if (-not $(Test-Path -Path $Path)) {
            # Check if path does not exist and create the path
            New-Item -Path $Path -Force | Out-Null
        }
        if ((Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue)) {
            # Update property and print out what it was changed from and changed to
            $CurrentValue = (Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue).$Name
            try {
                Set-ItemProperty -Path $Path -Name $Name -Value $Value -Force -Confirm:$false -ErrorAction Stop | Out-Null
            }
            catch {
                Write-Error "[Error] Unable to Set registry key for $Name please see below error!"
                Write-Error $_
                exit 1
            }
            Write-Host "$Path$Name changed from $CurrentValue to $($(Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue).$Name)"
        }
        else {
            # Create property with value
            try {
                New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force -Confirm:$false -ErrorAction Stop | Out-Null
            }
            catch {
                Write-Error "[Error] Unable to Set registry key for $Name please see below error!"
                Write-Error $_
                exit 1
            }
            Write-Host "Set $Path$Name to $($(Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue).$Name)"
        }
    }

    # This function was made just so I didn't have to make two versions of what's essentially the same code.
    function Set-WallpaperKeys {
        param(
            $BasePath,
            $WallpaperStyle,
            $ImagePath
        )

        $RegKey = "$BasePathControl PanelDesktop"
        $Style = switch ($WallpaperStyle) {
            "Fill" { 10 }
            "Fit" { 6 }
            "Stretch" { 2 }
            "Tile" { 0 }
            "Center" { 0 }
            "Span" { 22 }
        }

        Set-HKProperty -Path $RegKey -Name "Wallpaper" -Value $ImagePath -PropertyType "String"
        Set-HKProperty -Path $RegKey -Name "WallpaperStyle" -Value $Style -PropertyType "String"
        if ($WallpaperStyle -eq "Tile") {
            Set-HKProperty -Path $RegKey -Name "TileWallpaper" -Value 1 -PropertyType "String"
        }
        else {
            Set-HKProperty -Path $RegKey -Name "TileWallpaper" -Value 0 -PropertyType "String"
        }
    }

    # This will overwrite the %APPDATA%MicrosoftWindowsThemesTranscodedWallpaper file.
    function Reset-TranscodedWallpaper {
        param(
            $Username,
            $BasePath
        )

        Write-Host "Replacing transcoded wallpaper file for $Username."

        if (-not (Test-Path "$BasePathMicrosoftWindowsThemesTranscodedWallpaper" -ErrorAction SilentlyContinue)) {
            Write-Host "Transcoded Wallpaper File does not exist. Creating it..."
            New-Item -ItemType "file" -Path "$BasePathMicrosoftWindowsThemes" -Name "TranscodedWallpaper" | Out-Null
            # After creating a blank one windows will automatically overwrite it with what's used by the current wallpaper. We'll need to sleep to overwrite it.
            Start-Sleep -Seconds 7
        }

        # If there's more than one file or the file for some reason still does not exist then something fishy is going on.
        $TranscodedWallpaper = Get-ChildItem "$BasePathMicrosoftWindowsThemes" | Where-Object { $_.Name -eq "TranscodedWallpaper" }
        if (($TranscodedWallpaper | Measure-Object).Count -gt 1) {
            Write-Warning -Message "There is more than 1 Transcoded wallpaper file user $Username may have to Log out and Log back in again to complete the wallpaper update."
        }
        elseif (($TranscodedWallpaper | Measure-Object).Count -lt 1) {
            Write-Warning -Message "Transcoded wallpaper file does not exist. User $Username may have to Log out and Log back in again to complete the wallpaper update."
        }
        else {
            try {
                if (Test-Path $TranscodedWallpaper.FullName -ErrorAction SilentlyContinue) { Get-Item $TranscodedWallpaper.FullName | Remove-Item -Force }
                Copy-Item -Path $ExistingImage -Destination $TranscodedWallpaper.FullName -Force -ErrorAction Stop
            }
            catch {
                Write-Warning -Message "Failed to update Transcoded wallpaper file. User $Username may have to Log out and Log back in again to complete the wallpaper update."
            }
        } 
    }

    # This just restarts explorer.exe
    function Reset-Explorer {
        Write-Host "Restarting Explorer.exe"
        Get-Process explorer | Stop-Process -Force
        Start-Process explorer.exe
    }

    function Test-IsSystem {
        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
        return $id.Name -like "NT AUTHORITY*" -or $id.IsSystem
    }
}
process {

    # If we were given a local file and a link use the local file.
    if ($Url -and -not ($ExistingImage)) {
        
        $ExistingImage = Invoke-Download -Url $Url -BaseName "$Directorywallpaper-$(Get-Random)"
    }
    
    # Warn that older OS's don't always show the change immediately.
    if ([System.Environment]::OSVersion.Version.Major -lt 10) {
        Write-Warning "On older Operating Systems wallpaper changes may require the user to log out and log back in to take effect."
    }

    if (-not (Test-IsSystem)) {

        # Set's the wallpaper registry keys.
        Set-WallpaperKeys -BasePath "Registry::HKEY_CURRENT_USER" -ImagePath $ExistingImage -WallpaperStyle $WallpaperStyle

        if (-not ($ReplaceTranscodedWallpaperFile)) {
            Write-Warning "Replacing the wallpaper transcoded file is required for wallpaper change to take immediate effect."
            Write-Host ""
            continue
        }

        # Replaces the transcoded wallpaper file.
        Reset-TranscodedWallpaper -Username $env:USERNAME -BasePath $env:APPDATA
        
        if ($RestartExplorer) {
            Reset-Explorer
        }

        exit 0
    }

    Write-Host ""

    $UserProfiles = Get-UserHives -Type "All"
    # Loop through each profile on the machine
    Foreach ($UserProfile in $UserProfiles) {
        # Load User ntuser.dat if it's not already loaded
        If (($ProfileWasLoaded = Test-Path Registry::HKEY_USERS$($UserProfile.SID)) -eq $false) {
            Start-Process -FilePath "cmd.exe" -ArgumentList "/C reg.exe LOAD HKU$($UserProfile.SID) `"$($UserProfile.UserHive)`"" -Wait -WindowStyle Hidden
        }

        # Sets the wallpaper registry keys.
        Set-WallpaperKeys -BasePath "Registry::HKEY_USERS$($UserProfile.SID)" -ImagePath $ExistingImage -WallpaperStyle $WallpaperStyle

        if (-not ($ReplaceTranscodedWallpaperFile)) {
            Write-Warning "Replacing the wallpaper transcoded file is required for wallpaper change to take immediate effect."
            Write-Host ""
            continue
        }

        # Replace the transcoded wallpaper
        Reset-TranscodedWallpaper -Username $UserProfile.UserName -BasePath "$($UserProfile.Path)AppDataRoaming"
        
        Write-Host ""

        # Unload NTuser.dat
        If ($ProfileWasLoaded -eq $false) {
            [gc]::Collect()
            Start-Sleep 1
            Start-Process -FilePath "cmd.exe" -ArgumentList "/C reg.exe UNLOAD HKU$($UserProfile.SID)" -Wait -WindowStyle Hidden | Out-Null
        }
    }

    if ($RestartExplorer) {
        Reset-Explorer
    }

    exit 0
}
end {
    
    
    
}

 

Accédez à plus de 700 scripts dans le Dojo NinjaOne

Obtenir l’accès

Description détaillée

Le script opère en plusieurs étapes :

  • Initialisation des paramètres : il commence par définir des paramètres tels que l’URL du fond d’écran, le répertoire de stockage et le style (par exemple, remplir, ajuster, étirer).
  • Vérifications avant exécution : il valide le style de fond d’écran et vérifie l’existence de l’image et du répertoire spécifiés.
  • Téléchargement du fond d’écran : si une URL est fournie, le script télécharge l’image dans le répertoire spécifié.
  • Réglage du fond d’écran pour chaque utilisateur : le script modifie les paramètres du registre pour chaque profil d’utilisateur afin de changer le fond d’écran. Il traite également des cas particuliers tels que les comptes système.
  • Options à effet immédiat : les options de remplacement du fichier de fond d’écran transcodé et de redémarrage du processus Explorer garantissent que les modifications prennent effet immédiatement.

Cas d’utilisation potentiels

Imaginez qu’un administrateur informatique d’une grande entreprise doive mettre à jour les fonds d’écran de tous les ordinateurs de ses employés pour qu’ils arborent le nouveau logo de l’entreprise. À l’aide de ce script, il peut déployer le nouveau fond d’écran sur l’ensemble du réseau, en veillant à ce que chaque utilisateur, quels que soient ses paramètres individuels, voie la nouvelle image de marque.

Comparaisons

La modification des fonds d’écran sur plusieurs profils nécessite en général des ajustements manuels ou des stratégies de groupe. Ce script offre une approche plus directe et plus souple, particulièrement utile dans les environnements où les stratégies de groupe ne sont pas réalisables ou trop lourdes à mettre en place.

FAQ

Q : Ce script fonctionnera-t-il sur toutes les versions de Windows ?
R : Le script est conçu pour Windows 7 et les versions plus récentes, mais certaines fonctionnalités peuvent ne pas fonctionner sur des versions antérieures, comme Server 2008 par exemple.

Q : Puis-je utiliser n’importe quel format d’image comme fond d’écran ?
R : Le script prend en charge les formats courants tels que JPG, PNG, BMP et GIF.

Implications

Bien que ce script soit pratique, il souligne également la nécessité de gérer soigneusement les autorisations de script et les politiques d’exécution, car il implique la modification des paramètres du registre et des fichiers système, ce qui pourrait présenter des risques pour la sécurité en cas d’utilisation abusive.

Recommandations

  • Effectuez des tests approfondis : testez toujours les scripts dans un environnement contrôlé avant de les déployer sur l’ensemble du réseau.
  • Gérez les autorisations : restreignez l’exécution des scripts au personnel autorisé afin d’éviter toute utilisation abusive.
  • Modifications du document : conservez un journal indiquant quand et comment le script est utilisé à des fins d’audit et de dépannage.

Conclusion

Dans un environnement informatique dynamique, des outils tels que NinjaOne peuvent considérablement améliorer l’efficacité de tâches telles que le déploiement de ce script PowerShell. Grâce à ses capacités de gestion et d’automatisation performantes, NinjaOne permet de rationaliser le processus de déploiement, et les professionnels de l’informatique peuvent maintenir plus facilement et en toute confiance des environnements de bureau cohérents pour de multiples profils d’utilisateurs. Cet alignement de l’automatisation et de la gestion renforce l’importance de l’intégration d’outils puissants tels que les scripts PowerShell dans des stratégies de gestion informatique plus larges.

Pour aller plus loin

Créer une équipe informatique efficace et performante nécessite une solution centralisée qui soit l’outil principal pour fournir vos services. NinjaOne permet aux équipes informatiques de surveiller, gérer, sécuriser et prendre en charge tous les appareils, où qu’ils soient, sans avoir besoin d’une infrastructure complexe sur site.

Pour en savoir plus sur NinjaOne Endpoint Management, participez à une visite guidée ou commencez votre essai gratuit de la plateforme NinjaOne.

Catégories :

Vous pourriez aussi aimer

Termes et conditions NinjaOne

En cliquant sur le bouton « J’accepte » ci-dessous, vous indiquez que vous acceptez les termes juridiques suivants ainsi que nos conditions d’utilisation:

  • Droits de propriété: NinjaOne possède et continuera de posséder tous les droits, titres et intérêts relatifs au script (y compris les droits d’auteur). NinjaOne vous accorde une licence limitée pour l’utilisation du script conformément à ces conditions légales.
  • Limitation de l’utilisation: Les scripts ne peuvent être utilisés qu’à des fins personnelles ou professionnelles internes légitimes et ne peuvent être partagés avec d’autres entités.
  • Interdiction de publication: Vous n’êtes en aucun cas autorisé à publier le script dans une bibliothèque de scripts appartenant à, ou sous le contrôle d’un autre fournisseur de logiciels.
  • Clause de non-responsabilité: Le texte est fourni « tel quel » et « tel que disponible », sans garantie d’aucune sorte. NinjaOne ne promet ni ne garantit que le script sera exempt de défauts ou qu’il répondra à vos besoins ou attentes particulières.
  • Acceptation des risques: L’utilisation du script est sous votre propre responsabilité. Vous reconnaissez qu’il existe certains risques inhérents à l’utilisation du script, et vous comprenez et assumez chacun de ces risques.
  • Renonciation et exonération de responsabilité: Vous ne tiendrez pas NinjaOne pour responsable des conséquences négatives ou involontaires résultant de votre utilisation du script, et vous renoncez à tout droit ou recours légal ou équitable que vous pourriez avoir contre NinjaOne en rapport avec votre utilisation du script.
  • EULA: Si vous êtes un client de NinjaOne, votre utilisation du script est soumise au contrat de licence d’utilisateur final qui vous est applicable (End User License Agreement (EULA)).