Skip to content

Commit

Permalink
Update VirtualDesktop PS1 module if Windows build changes
Browse files Browse the repository at this point in the history
  • Loading branch information
t1m0thyj committed Feb 20, 2023
1 parent 3d92b24 commit af161c0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions experimental/SyncVirtualDesktops.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,24 @@ If (-Not ($PSBoundParameters.ContainsKey("imagePath"))) {
Break
}

$currentWinVer = (Get-CimInstance Win32_OperatingSystem).version
$settingsFile = "$((Get-Item $PSCommandPath).BaseName).dat"
$settingsUpdated = $false
if (-Not (Get-Module -ListAvailable -Name VirtualDesktop)) {
Install-PackageProvider -Name NuGet -Force -Scope CurrentUser
Install-Module -Name VirtualDesktop -Force -Scope CurrentUser
$settingsUpdated = $true
} elseif (-Not (Test-Path -Path $settingsFile -PathType Leaf) -Or ($currentWinVer -Ne (Import-Clixml -Path $settingsFile))) {
Update-Module -Name VirtualDesktop -Force -Scope CurrentUser
$settingsUpdated = $true
}

Get-DesktopList | ForEach-Object {
if (-Not (Test-CurrentDesktop -Desktop $_.Number)) {
Set-DesktopWallpaper -Desktop $_.Number -Path $imagePath
}
}

if ($settingsUpdated) {
$currentWinVer | Export-Clixml -Path $settingsFile
}

0 comments on commit af161c0

Please sign in to comment.