diff --git a/experimental/SyncVirtualDesktops.ps1 b/experimental/SyncVirtualDesktops.ps1 index f208d53..9f88581 100644 --- a/experimental/SyncVirtualDesktops.ps1 +++ b/experimental/SyncVirtualDesktops.ps1 @@ -9,9 +9,16 @@ 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 { @@ -19,3 +26,7 @@ Get-DesktopList | ForEach-Object { Set-DesktopWallpaper -Desktop $_.Number -Path $imagePath } } + +if ($settingsUpdated) { + $currentWinVer | Export-Clixml -Path $settingsFile +}