2026-05-22 10:34:36 +02:00
|
|
|
# ============================================================
|
|
|
|
|
# CHANGELOG
|
2026-06-02 08:23:16 +02:00
|
|
|
# v1.3 - Get-DesktopPaths: Depth 2 search for OneDrive Desktop
|
|
|
|
|
# v1.2 - Detect by expected filename list
|
|
|
|
|
# v1.1 - AllUsers switch + Get-DesktopPaths helper
|
|
|
|
|
# v1.0 - Initial
|
2026-05-24 19:27:09 +02:00
|
|
|
# ============================================================
|
|
|
|
|
# Update this list whenever .rdp files are added or removed
|
|
|
|
|
# from the rdp-files\\ folder.
|
|
|
|
|
# ============================================================
|
|
|
|
|
$expectedFiles = @(
|
|
|
|
|
# Add your .rdp filenames here, e.g.:
|
|
|
|
|
# "RemoteServer1.rdp",
|
|
|
|
|
# "RemoteServer2.rdp"
|
|
|
|
|
)
|
|
|
|
|
|
2026-05-22 10:34:36 +02:00
|
|
|
# Setup logging
|
|
|
|
|
$baseFolder = Join-Path $env:SystemDrive "Intune"
|
|
|
|
|
$logFile = Join-Path $baseFolder "DesktopShortcuts.log"
|
|
|
|
|
|
|
|
|
|
if (-not (Test-Path $baseFolder)) {
|
|
|
|
|
New-Item -Path $baseFolder -ItemType Directory -Force | Out-Null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Write-Log {
|
|
|
|
|
param($Message)
|
|
|
|
|
$logMessage = "$(Get-Date -Format 'dd-MM-yyyy HH:mm'): $Message"
|
|
|
|
|
Add-Content -Path $logFile -Value $logMessage
|
|
|
|
|
Write-Host $logMessage
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Get-DesktopPaths {
|
|
|
|
|
if ($AllUsers) {
|
2026-06-02 07:53:48 +02:00
|
|
|
Get-ChildItem "$env:SystemDrive\Users" -Directory -Exclude "Public","Default" | ForEach-Object {
|
|
|
|
|
Get-ChildItem $_.FullName -Directory -Filter "Desktop" -Depth 2 -ErrorAction SilentlyContinue |
|
|
|
|
|
Select-Object -ExpandProperty FullName
|
2026-05-22 10:34:36 +02:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
[Environment]::GetFolderPath("CommonDesktopDirectory")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2026-05-24 19:27:09 +02:00
|
|
|
$desktopPaths = Get-desktopPaths
|
2026-05-22 10:34:36 +02:00
|
|
|
$allFound = $true
|
|
|
|
|
|
|
|
|
|
foreach ($desktopPath in $desktopPaths) {
|
2026-05-24 19:27:09 +02:00
|
|
|
foreach ($fileName in $expectedFiles) {
|
|
|
|
|
$targetFile = Join-Path $desktopPath $fileName
|
|
|
|
|
if (-not (Test-Path $targetFile)) {
|
|
|
|
|
Write-Log "DETECT [FAIL]: Missing: $fileName on $desktopPath"
|
2026-05-22 10:34:36 +02:00
|
|
|
$allFound = $false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($allFound) {
|
2026-05-24 19:27:09 +02:00
|
|
|
Write-Log "DETECT [OK]: All expected .rdp files found"
|
2026-05-22 10:34:36 +02:00
|
|
|
exit 0
|
|
|
|
|
} else {
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
} catch {
|
|
|
|
|
Write-Log "Detect error: $_"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|