feat: opdater Detect.ps1 med specifik fil-tjek og opdater README
- Implementer $expectedFiles array i Detect.ps1 for at tjekke specifikke .rdp-filnavne - Opdater beskrivelse af Detect.ps1 i pakkens indhold tabel - Tilføj afsnit 'Sådan opsætter du Detect.ps1' med eksempel og forklaring - Opdater indholdsfortegnelse med nyt afsnit
This commit is contained in:
+18
-13
@@ -1,5 +1,7 @@
|
||||
# ============================================================
|
||||
# CHANGELOG
|
||||
# v1.2 - Checks for specific expected .rdp filenames instead
|
||||
# of just "any .rdp file exists on desktop".
|
||||
# v1.1 - Added -AllUsers switch to check all user desktops
|
||||
# instead of only the public desktop.
|
||||
# Added Get-DesktopPaths helper function.
|
||||
@@ -10,6 +12,16 @@ param(
|
||||
[switch]$AllUsers
|
||||
)
|
||||
|
||||
# ============================================================
|
||||
# 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"
|
||||
@@ -37,28 +49,21 @@ function Get-DesktopPaths {
|
||||
}
|
||||
|
||||
try {
|
||||
$desktopPaths = Get-DesktopPaths
|
||||
$desktopPaths = Get-desktopPaths
|
||||
$allFound = $true
|
||||
|
||||
foreach ($desktopPath in $desktopPaths) {
|
||||
$rdpFiles = Get-ChildItem -Path "$desktopPath\*.rdp" -ErrorAction SilentlyContinue
|
||||
|
||||
if ($rdpFiles.Count -eq 0) {
|
||||
Write-Log "DETECT [FAIL]: No .rdp files found on desktop: $desktopPath"
|
||||
$allFound = $false
|
||||
continue
|
||||
}
|
||||
|
||||
foreach ($file in $rdpFiles) {
|
||||
if (-not (Test-Path (Join-Path $desktopPath $file.Name))) {
|
||||
Write-Log "DETECT [FAIL]: Missing: $($file.Name) on $desktopPath"
|
||||
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 .rdp files found on all desktop(s)"
|
||||
Write-Log "DETECT [OK]: All expected .rdp files found"
|
||||
exit 0
|
||||
} else {
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user