Skip to content

Instantly share code, notes, and snippets.

@joaopaulo1511
Forked from ygra/Get-SpotlightImages.ps1
Last active May 4, 2019 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joaopaulo1511/ed6d42c048fc8906810279117e2eee65 to your computer and use it in GitHub Desktop.
Save joaopaulo1511/ed6d42c048fc8906810279117e2eee65 to your computer and use it in GitHub Desktop.
A small PowerShell script to save Windows 10 lock screen images to a more accessible location.
# https://www.thewindowsclub.com/use-windows-spotlight-desktop-wallpaper-slideshow
# https://onedrive.live.com/?authkey=!ANLOaqn39rJAiok&cid=2813C6E4993C726F&id=2813C6E4993C726F!1507326&parId=2813C6E4993C726F!1507334&o=OneUp
$SpotLightFiles = Get-ChildItem $Env:LocalAppData\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets | Where-Object -Property Length -GT 1kb ;
# $SpotLightFiles = Get-ChildItem [ System.Environment ]:: GetFolderPath( 'LocalApplicationData' ) \Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets | Where-Object -Property Length -GT 1kb ;
If ( $SpotLightFiles ) {
$Shell = New-Object -ComObject Shell.Application ;
# Destination for pictures
$Folder = [ System.Environment ]:: GetFolderPath( 'MyPictures' ) + '\Spotlight' ;
If ( -not ( Test-Path -LiteralPath $Folder ) ) {
New-Item -Path $Folder -ItemType Directory ;
} ;
$NameSpace = $Shell.NameSpace( $Folder ) ;
$SpotLightFiles | ForEach-Object {
$PSItem | Copy-Item -Destination $Folder\$PSItem.jpeg ;
Get-Item $Folder\$PSItem.jpeg ;
} | ForEach-Object {
# $NameSpace = $Shell.NameSpace( $Folder ) ;
$Item = $NameSpace.ParseName( $PSItem.Name ) ;
$Size = $NameSpace.GetDetailsOf( $Item, 31 ) ;
If ( $Size -match '(\d+) x (\d+)' ) {
$Width = [ System.Int16 ] ( $Matches[ 1 ] ) ;
$Height = [ System.Int16 ] ( $Matches[ 2 ] ) ;
} ;
If ( -not $Size -or $Width -lt 1920 -or $Height -lt 500 ) {
Remove-Item $PSItem ;
} ;
} ;
} ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment