Automatisches SoftwareUpdate per Powershell
Automatisches SoftwareUpdate per Powershell
Hallo Leute,
ich bin absoluter PowerShell-Neuling. Ich kenne mich eigentlich gar nicht aus. Nun hätte ich ein PS Script zur Softwareverteilung erstellt. Einiges hab ich über Google gefunden und funktioniert auch. Aber gewisse Teile sind mir unklar und funktionieren auch nicht. Ev. kann mir da jemand helfen? Vorab besten Dank!
Das Script:
# kopieren des Setupfiles vom Server nach c:\temp
copy-item "\\192.168.1.250\aktuelle_programme$\win\Firefox Setup 52.7.3esr.exe" -destination c:\Temp\
# Variable für Installationspfad
$InstalledFilePath = “C:\Program Files\Mozilla Firefox\firefox.exe”
# Check ob FF vorhanden
IF (!(Test-Path -path $InstalledFilePath -pathType leaf)) {
# wenn nicht vorhanden, dann installieren (silent)
Start-Process 'c:\temp\Firefox Setup 52.7.3esr.exe' -ArgumentList "/S /v /qn" -Wait
}
# Falls vorhanden, dann ev. Update
ELSE {
$InstalledProductVersion = (Get-Command $InstalledFilePath).FileVersionInfo.ProductVersion
IF ($InstalledProductVersion -lt 52.7) {
#Installieren bei Versionsunterschied
Start-Process 'c:\temp\Firefox Setup 52.7.3esr.exe' -ArgumentList "/S /v /qn" -Wait
}}
# Inhalt von temp löschen
Get-ChildItem -path "C:\Temp" | Remove-Item -Recurse -force -ErrorAction SilentlyContinue
ich bin absoluter PowerShell-Neuling. Ich kenne mich eigentlich gar nicht aus. Nun hätte ich ein PS Script zur Softwareverteilung erstellt. Einiges hab ich über Google gefunden und funktioniert auch. Aber gewisse Teile sind mir unklar und funktionieren auch nicht. Ev. kann mir da jemand helfen? Vorab besten Dank!
Das Script:
# kopieren des Setupfiles vom Server nach c:\temp
copy-item "\\192.168.1.250\aktuelle_programme$\win\Firefox Setup 52.7.3esr.exe" -destination c:\Temp\
# Variable für Installationspfad
$InstalledFilePath = “C:\Program Files\Mozilla Firefox\firefox.exe”
# Check ob FF vorhanden
IF (!(Test-Path -path $InstalledFilePath -pathType leaf)) {
# wenn nicht vorhanden, dann installieren (silent)
Start-Process 'c:\temp\Firefox Setup 52.7.3esr.exe' -ArgumentList "/S /v /qn" -Wait
}
# Falls vorhanden, dann ev. Update
ELSE {
$InstalledProductVersion = (Get-Command $InstalledFilePath).FileVersionInfo.ProductVersion
IF ($InstalledProductVersion -lt 52.7) {
#Installieren bei Versionsunterschied
Start-Process 'c:\temp\Firefox Setup 52.7.3esr.exe' -ArgumentList "/S /v /qn" -Wait
}}
# Inhalt von temp löschen
Get-ChildItem -path "C:\Temp" | Remove-Item -Recurse -force -ErrorAction SilentlyContinue
-
Tante Google