-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathSyncVirtualDesktops.ps1
29 lines (25 loc) · 1.04 KB
/
SyncVirtualDesktops.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$params = $Input | ConvertFrom-Json
If (-Not $params.imagePaths) {
Break
}
$currentWinVer = (Get-CimInstance Win32_OperatingSystem).version
$settingsFile = "$((Get-Item $PSCommandPath).BaseName).dat"
$settingsUpdated = $false
if (-Not (Get-Module -ListAvailable -Name VirtualDesktop)) {
if (-Not (Get-PackageProvider -ListAvailable | Where-Object { $_.Name -eq "NuGet" })) {
Install-PackageProvider -Name NuGet -Force -Scope CurrentUser
}
Install-Module -Name VirtualDesktop -AllowClobber -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
$settingsUpdated = $true
}
Get-DesktopList | ForEach-Object {
if (-Not (Test-CurrentDesktop -Desktop $_.Number)) {
Set-DesktopWallpaper -Desktop $_.Number -Path $params.imagePaths[0]
}
}
if ($settingsUpdated) {
$currentWinVer | Export-Clixml -Path $settingsFile
}