Skip to content

Retrieves local Windows Spotlight lock screen wallpapers and saves them to a defined directory (a Windows PowerShell script).

License

Notifications You must be signed in to change notification settings

auberginehill/get-windows-10-lock-screen-wallpapers

 
 

Repository files navigation

Get-Windows10LockScreenWallpapers.ps1

OS: Windows
Type: A Windows PowerShell script
Language: Windows PowerShell
Description:

Get-Windows10LockScreenWallpapers uses by default one of the three methods below to determine the source path, where the Windows Spotlight lock screen wallpapers are stored locally:

  1. Reading a registry key under HKEY_CURRENT_USER: "\SOFTWARE\Microsoft\Windows\CurrentVersion\Lock Screen\Creative\LandscapeAssetPath"
  2. Estimating the * value (and the source path) in "$($env:LOCALAPPDATA)\Packages\Microsoft.Windows.ContentDelivery*\LocalState\Assets" path, which on most Windows 10 machines would most likely point to the "\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets" directory
  3. Figuring out the current lock screen hive (which usually is in the $env:windir\Web\Screen directory)

The methods are tested in an ascending order and selected as the primary (only) method, if deemed to be valid. By adding the -IncludeHive parameter to the command launching Get-Windows10LockScreenWallpapers the third method of wallpaper searching will be enabled, so that Get-Windows10LockScreenWallpapers will also look to the current lock screen hive, even if the first method (registry) or the second method (estimation) was selected as the primary method for searching the available local lock screen wallpapers.

Get-Windows10LockScreenWallpapers uses the inbuilt Get-FileHash cmdlet to calculate SHA256 hash values of the files for determining, whether a wallpaper already exists in the -Output folder or a portrait picture in the -Subfolder directory. By default Get-Windows10LockScreenWallpapers writes the landscape files to "$($env:USERPROFILE)\Pictures\Wallpapers"(, which is the default -Output directory), and the portrait pictures are placed in a subfolder called "Vertical" inside the folder specified with the -Output parameter. The primary save location ("destination") may be set with the -Output parameter, and the name of the subfolder may be changed with the -Subfolder parameter – the former accepts a full path as a value, and the latter just a plain directory name.

The images are loaded as ImageFile COM objects with Microsoft Windows Image Acquisition (WIA, which relies on the Windows Image Acquisition (WIA) service 'stisvc'), and over 300 image properties (usually, though, most of them are empty or non-existent...) are read from the pictures before the new images are copied to their final destination. To exclude the portrait pictures from the results altogether, the parameter -ExcludePortrait may be added to the command launching Get-Windows10LockScreenWallpapers.

The -Log parameter will start a log creation procedure (in case new files were acquired), in which the extracted image properties are written to a new CSV file (spotlight_log.csv) or appended to an existing log file. The other available parameters (-Force, -Open and -Audio) are discussed in further detail below. Please note that if any of the individual parameter values include space characters, the individual value should be enclosed in quotation marks (single or double), so that PowerShell can interpret the command correctly. This script is forked from robledosm's script Save lockscreen as wallpaper.

Homepage: https://github.com/auberginehill/get-windows-10-lock-screen-wallpapers
Short URL: http://tinyurl.com/z3ew947
Version: 1.0
Sources: Emojis: Emoji Table
robledosm: Save lockscreen as wallpaper
clayman2: Disk Space (or one of the archive.org versions)
lamaar75: Creating a Menu (or one of the archive.org versions)
Franck Richard: Use PowerShell to Remove Metadata and Resize Images
klumsy: Call Windows Runtime Classes from PowerShell
Fred: select-object | where
Mike F Robbins: PowerShell Advanced Functions: Can we build them better?
Downloads: For instance Get-Windows10LockScreenWallpapers.ps1. Or everything as a .zip-file.

Screenshot

        screenshot

Parameters

📐
  • Parameter -Output

    with aliases -Path, -Destination and -OutputFolder. Specifies the primary folder, where the acquired new images are to be saved, and defines the default location to be used with the -Log parameter (spotlight_log.csv), and also sets the parent directory for the -Subfolder parameter. The default save location for the horizontal (landscape) wallpapers is "$($env:USERPROFILE)\Pictures\Wallpapers", which will be used, if no value for the -Output parameter is defined in the command launching Get-Windows10LockScreenWallpapers. For the best results in iterative usage of this script, the default value should remain constant and be set according to the prevailing conditions (at line 18).

    The value for the -Output parameter should be a valid file system path pointing to a directory (a full path of a folder such as C:\Users\Dropbox\). In case the path includes space characters, please enclose the path in quotation marks (single or double). If the -Output parameter value seems to point to a non-existing directory, the script will ask, whether the user wants to create the folder or not. This query can be bypassed by using the -Force parameter. It's not mandatory to write -Output in the get Windows 10 lock screen wallpapers command to invoke the -Output parameter, as is described in the Examples below.

  • Parameter -Subfolder

    with aliases -SubfolderForThePortraitPictures, -SubfolderForTheVerticalPictures and -SubfolderName. Specifies the name of the subfolder, where the new portrait pictures are to be saved. If the -ExcludePortrait parameter is not used, the subfolder directory will be located under the folder defined with the -Output parameter. The value for the -Subfolder parameter should be a plain directory name (omitting the path and the parent directories). The default value is "Vertical". For the best results in iterative usage of Get-Windows10LockScreenWallpapers, the default value should remain constant and be set according to the prevailing conditions at line 30.

  • Parameter -Force

    If the -Force parameter is added to the command launching Get-Windows10LockScreenWallpapers, the -Output directory will be created without asking any questions, confirmations or additional selections (which will be prompted by default, if the -Output path doesn't seem to exist). If the -Open parameter is used in adjunction with the -Force parameter in the command launching Get-Windows10LockScreenWallpapers, the main destination path is opened in the File Manager in every case, regardless whether any new files were found or not.

  • Parameter -ExcludePortrait

    with aliases -NoPortrait, -NoSubfolder and -Exclude The -ExcludePortrait parameter excludes all portrait (vertical) pictures from the files that will be copied to a new location. -ExcludePortrait also prevents the (automatic) creation of the -Subfolder directory inside the main -Output destination.

  • Parameter -IncludeHive

    with aliases -IncludeCurrentLockScreenBackgroundHive and -Include. If the -IncludeHive parameter is used in the command launching Get-Windows10LockScreenWallpapers, the third method of wallpaper searching will be enabled, so that Get-Windows10LockScreenWallpapers will also look to the current lock screen hive, even if the first method (registry) or the second method (estimation) was selected as the primary method for searching the available local lock screen wallpapers. Usually this will add a directory called '$env:windir\Web\Screen' to the list of source paths to be queried for new images. Please note that the items inside the current lock screen hive may be of varying file extension type, including mostly .jpg and .png pictures.

  • Parameter -Log

    If the -Log parameter is added to the command launching Get-Windows10LockScreenWallpapers, a log file creation/updating procedure is initiated, if new files are found. The log file (spotlight_log.csv) is created or updated at the path defined with the -Output parameter. If the CSV log file seems to already exist, new data will be appended to the end of that file. The log file will consist over 300 image properties, of which most are empty.

    The MakerNote Exif datafield is disabled (commented out in the source code) mainly due to the vast variation of the formats used in the MakerNote Exif datafields themselves. The exhaustive amount of different languages and data formats found in the MakerNote Exif tags means that extensive additional coding efforts would be needed for producing universally readable content from the MakerNote (37500) Exif tag values.

    A rather peculiar append procedure is used instead of the native -Append parameter of the Export-Csv cmdlet for ensuring, that the CSV file will not contain any additional quotation marks(, which might mess up the layout in some scenarios).

  • Parameter -Open

    If the -Open parameter is used in the command launching Get-Windows10LockScreenWallpapers and new files are found, the default File Manager is opened at the -Output folder after the files are processed. If the -Force parameter is used in adjunction with the -Open parameter, the main destination path is opened in the File Manager regardless whether any new files were found or not. Please note, though, that the -Force parameter will also Force the creation of the -Output folder.

  • Parameter -Audio

    If the -Audio parameter is used in the command launching Get-Windows10LockScreenWallpapers and new files are found, an audible beep will occur.

Outputs

➡️
  • All new Windows Spotlight lock screen wallpapers are saved under a directory defined with the -Output parameter. Displays wallpaper related info in console, and if any new files were found, displays the results in a pop-up window (Out-GridView). Optionally, if the -Log parameter was used in the command launching Get-Windows10LockScreenWallpapers, and new files were found, a log file (spotlight_log.csv) creation/updating procedure is initiated at the path defined with the -Output variable. Also optionally, the default File Manager is opened at the -Output folder, after the new files are processed, if the -Open parameter was used in the command launching Get-Windows10LockScreenWallpapers. A progress bar is also shown in console when multiple images are being processed.

  • Default values (the log file creation/updating procedure only occurs, if the -Log parameter is used and new files are found):
    1. Path Type
      $($env:USERPROFILE)\Pictures\Wallpapers The folder for landscape wallpapers
      $($env:USERPROFILE)\Pictures\Wallpapers\spotlight_log.csv CSV-file
      $($env:USERPROFILE)\Pictures\Wallpapers\Vertical The folder for portrait pictures

Notes

⚠️
  • Please note that all the parameters can be used in one get Windows 10 lock screen wallpapers command and that each of the parameters can be "tab completed" before typing them fully (by pressing the [tab] key).

Examples

📖 To open this code in Windows PowerShell, for instance:

  1. ./Get-Windows10LockScreenWallpapers
    Runs the script. Please notice to insert ./ or .\ before the script name. If the default -Output parameter folder "$($env:USERPROFILE)\Pictures\Wallpapers" doesn't seem to exist, the user will be queried, whether the -Output folder should be created or not. Will query "$($env:USERPROFILE)\Pictures\Wallpapers" and the default subfolder ("$($env:USERPROFILE)\Pictures\Wallpapers\Vertical") for existing files, and calculates their SHA256 hash values. Uses one of the three available methods to retrieve the Windows Spotlight lock screen wallpapers and compares their SHA256 hash values against the hash values of the files in the -Output folder to determine, whether any new files are present or not. All new landscape images are then copied to the default -Output parameter folder ("$($env:USERPROFILE)\Pictures\Wallpapers"), and all the new portrait images are copied to the default subfolder of the portrait pictures ("$($env:USERPROFILE)\Pictures\Wallpapers\Vertical"). A pop-up window showing the new files will open, if new files were found.
  2. help ./Get-Windows10LockScreenWallpapers -Full
    Displays the help file.
  3. ./Get-Windows10LockScreenWallpapers.ps1 -Log -Audio -Open -ExcludePortrait -Force
    Runs the script and creates the default -Output folder, if it doesn't exist, since the -Force was used. Also, since the -Force was used, the default File Manager will be opened at the default -Output folder regardless whether any new files were found or not. Uses one of the three available methods for retrieving the Windows Spotlight lock screen wallpapers and compares their SHA256 hash values against the hash values found in the default -Output folder to determine, whether any new files are present or not. Since the -ExcludePortrait parameter was used, the results are limited to the landscape wallpapers, and the vertical portrait pictures are excluded from the images to be processed further. If new landscape (horizontal) images were found, after the new landscape wallpapers are copied to their default destination, a log file creation/updating procedure is initiated, and a CSV-file (spotlight_log.csv) is created/updated at the default -Output folder. Furthermore, if new files were indeed found, an audible beep will occur.
  4. ./Get-Windows10LockScreenWallpapers -Output C:\Users\Dropbox\ -Subfolder dc01 -Include
    Uses one or two of the three available methods (registry, estimation and current lock screen hive) as the basis for determining the source paths, where the Windows Spotlight lock screen wallpapers are stored locally. Since the -IncludeHive parameter was used, the third method of wallpaper searching will be used in any case, which usually means that that the contents of '$env:windir\Web\Screen' are also used as a source. Compares the SHA256 hash values of the found files against the hash values found in the "C:\Users\Dropbox\" and "C:\Users\Dropbox\dc01" folders to determine, whether any new files are present or not. All new landscape images are then copied to the "C:\Users\Dropbox\" folder, and all the new portrait images are copied to the "C:\Users\Dropbox\dc01" subfolder. Since the path or the subfolder name doesn't contain any space characters, they don't need to be enveloped with quotation marks. Furthermore, the word -Output may be left out from the command as well, because -Output values are read automatically from the first parameter position.
  5. Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
    This command is altering the Windows PowerShell rights to enable script execution in the default (LocalMachine) scope, and defines the conditions under which Windows PowerShell loads configuration files and runs scripts in general. In Windows Vista and later versions of Windows, for running commands that change the execution policy of the LocalMachine scope, Windows PowerShell has to be run with elevated rights (Run as Administrator). The default policy of the default (LocalMachine) scope is "Restricted", and a command "Set-ExecutionPolicy Restricted" will "undo" the changes made with the original example above (had the policy not been changed before). Execution policies for the local computer (LocalMachine) and for the current user (CurrentUser) are stored in the registry (at for instance the HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ExecutionPolicy key), and remain effective until they are changed again. The execution policy for a particular session (Process) is stored only in memory, and is discarded when the session is closed.

    Parameters:

      Restricted Does not load configuration files or run scripts, but permits individual commands. Restricted is the default execution policy.
      AllSigned Scripts can run. Requires that all scripts and configuration files be signed by a trusted publisher, including the scripts that have been written on the local computer. Risks running signed, but malicious, scripts.
      RemoteSigned Requires a digital signature from a trusted publisher on scripts and configuration files that are downloaded from the Internet (including e-mail and instant messaging programs). Does not require digital signatures on scripts that have been written on the local computer. Permits running unsigned scripts that are downloaded from the Internet, if the scripts are unblocked by using the Unblock-File cmdlet. Risks running unsigned scripts from sources other than the Internet and signed, but malicious, scripts.
      Unrestricted Loads all configuration files and runs all scripts. Warns the user before running scripts and configuration files that are downloaded from the Internet. Not only risks, but actually permits, eventually, running any unsigned scripts from any source. Risks running malicious scripts.
      Bypass Nothing is blocked and there are no warnings or prompts. Not only risks, but actually permits running any unsigned scripts from any source. Risks running malicious scripts.
      Undefined Removes the currently assigned execution policy from the current scope. If the execution policy in all scopes is set to Undefined, the effective execution policy is Restricted, which is the default execution policy. This parameter will not alter or remove the ("master") execution policy that is set with a Group Policy setting.
      Notes:
      • Please note, that the Group Policy setting "Turn on Script Execution" overrides the execution policies set in Windows PowerShell in all scopes. To find this ("master") setting, please, for example, open the Local Group Policy Editor (gpedit.msc) and navigate to Computer Configuration → Administrative Templates → Windows Components → Windows PowerShell.
      • The Local Group Policy Editor (gpedit.msc) is not available in any Home or Starter editions of Windows.
        1. Group Policy Setting "Turn on Script Execution" PowerShell Equivalent (concerning all scopes)
          Not configured No effect, the default value of this setting
          Disabled Restricted
          Enabled - Allow only signed scripts AllSigned
          Enabled - Allow local scripts and remote signed scripts RemoteSigned
          Enabled - Allow all scripts Unrestricted

    For more information, please type "Get-ExecutionPolicy -List", "help Set-ExecutionPolicy -Full", "help about_Execution_Policies" or visit Set-ExecutionPolicy or about_Execution_Policies.

  6. New-Item -ItemType File -Path C:\Temp\Get-Windows10LockScreenWallpapers.ps1
    Creates an empty ps1-file to the C:\Temp directory. The New-Item cmdlet has an inherent -NoClobber mode built into it, so that the procedure will halt, if overwriting (replacing the contents) of an existing file is about to happen. Overwriting a file with the New-Item cmdlet requires using the Force. If the path name and/or the filename includes space characters, please enclose the whole -Path parameter value in quotation marks (single or double):

      New-Item -ItemType File -Path "C:\Folder Name\Get-Windows10LockScreenWallpapers.ps1"

    For more information, please type "help New-Item -Full".

Contributing

Find a bug? Have a feature request? Here is how you can contribute to this project:

contributing Bugs: Submit bugs and help us verify fixes.
Feature Requests: Feature request can be submitted by creating an Issue.
Edit Source Files: Submit pull requests for bug fixes and features and discuss existing proposals.

www

www Script Homepage
robledosm: Save lockscreen as wallpaper
clayman2: Disk Space (or one of the archive.org versions)
lamaar75: Creating a Menu (or one of the archive.org versions)
Franck Richard: Use PowerShell to Remove Metadata and Resize Images
klumsy: Call Windows Runtime Classes from PowerShell
Fred: select-object | where
Mike F Robbins: PowerShell Advanced Functions: Can we build them better?
Download Windows 10 Wallpapers and Lock Screen Backgrounds
Where to find the Windows Spotlight photos
How to save Windows Spotlight lockscreen images so you can use them as wallpapers
save-spotlight.ps1
Windows 10041 - Windows Spotlight Lock screen Picture location
How to Find the Current Lock Screen Image File Name and Path in Windows 10?
How to Find and Save Windows Spotlight Background Images in Windows 10
Change the Windows 8 Pre-Login Screen Background
Can't customize Lock or Logon screen backgrounds?
Adding a Simple Menu to a Windows PowerShell Script
The String's the Thing
Powershellv2 - remove last x characters from a string
Working with Hash Tables
Get-FileHash
EXIF Quick Reference
Windows Image Acquisition (WIA) - Shared Samples
WinZip Express for Photos on Windows Server 2003/2008/2012
ImageFile object
Image Manipulation in PowerShell
Get startup type of windows service using PowerShell
Get-WmiObject
Using Powershell as a photoshop replacement
Path Methods
Display Detailed Image Information
Send the details of a jpg file to an array
Attribute seems to give byte array. How to convert to string?
A routine for getting file metadata
Standard Exif Tags
PowerTip: Use PowerShell to Send Beep to Console
How can I append files using export-csv for PowerShell 2?
Remove Unwanted Quotation Marks from CSV Files by Using PowerShell
ASCII Art: http://www.figlet.org/ and ASCII Art Text Generator

Related scripts

www Disable-Defrag
Firefox Customization Files
Get-AsciiTable
Get-BatteryInfo
Get-ComputerInfo
Get-CultureTables
Get-DirectorySize
Get-HashValue
Get-InstalledPrograms
Get-InstalledWindowsUpdates
Get-PowerShellAliasesTable
Get-PowerShellSpecialFolders
Get-RAMInfo
Get-TimeDifference
Get-TimeZoneTable
Get-UnusedDriveLetters
Emoji Table
Java-Update
Remove-DuplicateFiles
Remove-EmptyFolders
Remove-EmptyFoldersLite
Rename-Files
Rock-Paper-Scissors
Toss-a-Coin
Unzip-Silently
Update-AdobeFlashPlayer
Update-MozillaFirefox

About

Retrieves local Windows Spotlight lock screen wallpapers and saves them to a defined directory (a Windows PowerShell script).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PowerShell 100.0%