Ich versuche ein Powershell-Skript zu erstellen, das ich mit einem RMM-Tool verwenden kann. Im Grunde würde dieses Powershell-Skript auf dem lokalen Rechner ausgeführt werden. Es müsste überprüft werden, ob die Version der Anwendung installiert ist und mindestens Versionsnummer xx. Wenn sie nicht installiert ist oder die Version weniger ist, lädt sie die ausführbare Datei herunter und installiert sie automatisch.Powershell-Skript zur Installation der Software
Ich habe ein Online-Beispiel für Adobe Reader gefunden, das funktioniert, aber es tut die Überprüfung nicht vorher. Also, dieses Skript würde Adobe Reader jedes Mal installieren, wenn es ausgeführt wird.
$tempFolder=$Env:TEMP
function runProcess ($cmd, $params) {
$p = new-object System.Diagnostics.Process
$p.StartInfo = new-object System.Diagnostics.ProcessStartInfo
$exitcode = $false
$p.StartInfo.FileName = $cmd
$p.StartInfo.Arguments = $params
$p.StartInfo.UseShellExecute = $False
$p.StartInfo.RedirectStandardError = $True
$p.StartInfo.RedirectStandardOutput = $True
$p.StartInfo.WindowStyle = 1;
$null = $p.Start()
$p.WaitForExit()
$output = $p.StandardOutput.ReadToEnd()
$exitcode = $p.ExitCode
$p.Dispose()
$exitcode
$output
}
#download installer
invoke-webrequest "ftp://ftp.adobe.com/pub/adobe/reader/win/AcrobatDC/1500720033/AcroRdrDC1500720033_en_US.msi" -OutFile "$tempFolder\AcroRdrDC1500720033_en_US.msi" -ErrorAction Stop
#run installer
$res = runProcess msiexec "/i $tempFolder\AcroRdrDC1500720033_en_US.msi /qb"
#check if return code is 0
if(0 -ne $res[0]){
return "Failed to install Adobe Reader: $($res[0]) $($res[1])"
}
#download the patch
invoke-webrequest "ftp://ftp.adobe.com/pub/adobe/reader/win/AcrobatDC/1502320070/AcroRdrDCUpd1502320070.msp" -OutFile "$tempFolder\AcroRdrDCUpd1502320070.msp" -ErrorAction Stop
#install it
$res = runProcess msiexec "/p $tempFolder\AcroRdrDCUpd1502320070.msp /qb"
#check if return code is 0
if(0 -ne $res[0]){
return "Failed to install Adobe Reader DC Patch: $($res[0]) $($res[1])"
}else{
#Attempt to silently disable the auto updater if set in this script
new-itemproperty "HKLM:\Software\Policies\Adobe\Acrobat Reader\DC\FeatureLockDown" -name bUpdater -value 0 -ErrorAction SilentlyContinue
}
Ich denke, es gibt einige Dinge, die in diesem Skript möglicherweise nicht benötigt werden. Es hat auch keine Überprüfung auf Version.
Gefunden auf einer anderen Website, aber nicht sicher, wie Sie es implementieren. Außerdem sieht es nicht so aus, als würde es nach der Versionsnummer suchen.
Im Idealfall möchte ich die Parameter oben festlegen, damit ich eine Vorlage für andere ausführbare Dateien verwenden konnte. Zum Beispiel
$app_name
$app_version
$app_url
$app_filename
$app_executable
$app_arguments
Jede Hilfe würde sehr geschätzt werden.
Jede Hilfe mit dem, was? Entwerfen Sie eine schlüsselfertige Lösung für Sie? (Das ist nicht der Zweck dieser Website.) –