ich habe folgendes PowerShell Skript zur Deinstallation von Dell Command Update erstellt und konnte dieses erfolgreich testen (gestartet über eine privilegierte PowerShell ISE). Hinterlege ich dieses nun in einem Empirum Paket und führe dieses aus (egal ob im SYSTEM Kontext oder als Admin mit manuellem Aufruf des Skriptinterpreters (gleicher User wie beim Aufruf über die ISE)) wird trotz installiertem Dell Command Update kein entsprechender Eintrag in der Registry gefunden. Da in HKLM geguckt wird scheint es für mich erstmal nicht nach einem Kontextproblem (der Skriptinterpreter wurde ja auch mit dem gleichen User als Admin ausgeführt).
Der Aufruf des Skripts im Empirum Paket sieht wie folgt aus:
Code: Select all
Call powershell -executionpolicy bypass -command "& '%SRC%\neoSource\DCU.ps1' ;exit $lastexitcode"
Code: Select all
Call powershell -executionpolicy bypass -noprofile -File "%SRC%\neoSource\DCU.ps1"
Code: Select all
$Name = "Dell Command | Update*"
$ProcName = "DellCommandUpdate"
$Timestamp = Get-Date -Format "yyyy-MM-dd_THHmmss"
$LogFile = "C:\Windows\Temp\Dell-CU-Uninst_$Timestamp.log"
$ProgramList = @( "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" )
$Programs = $null
foreach ($key in $ProgramList) {
$output = ®.exe query "$key" 2>&1
if ($output -match "ERROR") {
# Ignore errors if the key is not found
continue
}
$Programs += Get-ItemProperty $key -EA 0
}
$App = ($Programs | Where-Object { $_.DisplayName -like $Name -and $_.UninstallString -like "*msiexec*" }).PSChildName
if ($App) {
Get-Process | Where-Object { $_.ProcessName -eq $ProcName } | Stop-Process -Force
$Params = @(
"/qn"
"/norestart"
"/X"
"$App"
"/L*V ""$LogFile"""
)
Start-Process "msiexec.exe" -ArgumentList $Params -Wait -NoNewWindow
}
else {
Write-Output "$Name not found installed in the registry."
}
Write-Output "Current User: $env:USERNAME"
Pause
Die letzten beiden Zeilen sind aus Testgründen vorhanden und werden für das produktive Paket entfernt.
Wo könnte hier das Problem liegen? Da das PowerShell Skript über die ISE problemlos funktioniert kann ich es mir nicht erklären.