2225abed9d
- Opdatér Get-DesktopPaths i alle 7 app-scripts: brug Get-ChildItem -Filter 'Desktop' -Depth 2 i stedet for Join-Path/Test-Path så OneDrive-omdirigeret Desktop også fanges - Tilføj -Exclude 'Public','Default' for at springe systemprofiler over - Komprimér og opdatér changelog i alle scripts med ny version - Fjern old_app/ (arkiveret v1.0 scripts) - Opdatér README.md og README.html
67 lines
2.0 KiB
PowerShell
67 lines
2.0 KiB
PowerShell
# ============================================================
|
|
# CHANGELOG
|
|
# 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
|
|
# ============================================================
|
|
# 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"
|
|
)
|
|
|
|
# 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) {
|
|
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
|
|
}
|
|
} else {
|
|
[Environment]::GetFolderPath("CommonDesktopDirectory")
|
|
}
|
|
}
|
|
|
|
try {
|
|
$desktopPaths = Get-desktopPaths
|
|
$allFound = $true
|
|
|
|
foreach ($desktopPath in $desktopPaths) {
|
|
foreach ($fileName in $expectedFiles) {
|
|
$targetFile = Join-Path $desktopPath $fileName
|
|
if (-not (Test-Path $targetFile)) {
|
|
Write-Log "DETECT [FAIL]: Missing: $fileName on $desktopPath"
|
|
$allFound = $false
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($allFound) {
|
|
Write-Log "DETECT [OK]: All expected .rdp files found"
|
|
exit 0
|
|
} else {
|
|
exit 1
|
|
}
|
|
} catch {
|
|
Write-Log "Detect error: $_"
|
|
exit 1
|
|
}
|