Benutzer mit den meisten Antworten
MSI aus Script aufrufen

Frage
-
Hallo
zusammen<o:p></o:p>Ich bin
ziemlich neu in Powershell und habe eine kleine Frage.<o:p></o:p>für die
Installation einer EXE Datei via SCCM software Verteilung habe ich folgendes
Script erstellt.<o:p></o:p>$scriptRoot = Split-Path -Path $MyInvocation.MyCommand.Path
Start-Process "$scriptRoot\SslvpnClient.msi" /qn <o:p></o:p>die
Manuelle Verteilung funktioniert problemlos. doch sobald ich es via SCCM
Verteilen möchte erhalte ich einen Fehler.<o:p></o:p>Meine
Vermutungt ist, das irgend wo noch ein EXIT rein müsste, damit er das Script
schliest nach der Installation.<o:p></o:p>Dies habe
ich wie folgt versucht:<o:p></o:p>$scriptRoot = Split-Path -Path $MyInvocation.MyCommand.Path
Start-Process "$scriptRoot\SslvpnClient.msi" /qn
{Exit} <o:p></o:p>Leider geht
das aber auch nicht. Kann mir da jemand weiterhelfen. Besten Dank im Voraus<o:p></o:p>
- Bearbeitet Denniver ReiningMVP, Moderator Dienstag, 21. April 2015 15:08 Bitte aussagekräftige Titel verwenden!
Antworten
-
- Würde ich mich beim Aufrufen der Installation nicht auf irgendwelche Shell-Zuordnungen verlassen.
- Beim automatisierten Ausführen eines Scripts auf n Systemen wäre es doch sicher nicht von Schaden, wenn du mitkriegen würdest, ob es überhaupt funktioniert hat? Daher immer Rückgabewerte verwenden!
- Ich würde mir mal das PowerShell App Deployment Toolkit anschauen. Das hat diese Funktion schon fest eingebaut.
Und hier mal ein Beispiel für die Installation eines MSIs:
# Quick & Dirty with minimal testing # Use on your own risk [CmdletBinding()] Param ( [Parameter(Mandatory=$true,Position=0)] [string]$MSIPath ) $ExitCode = 0 if (-not (Test-Path $MSIPath)) { Write-Error "Could not find file `'$MSIPath`'." exit 1 } if (-not (Split-Path $MSIPath -IsAbsolute)) { $MSIPath = Resolve-Path $MSIPath } $LogFile = Join-Path $env:TEMP -ChildPath "$((Get-Item $MSIPath).BaseName).log" Write-Verbose "Found MSI file `'$MSIPath`'." Write-Verbose "Using log file `'$LogFile`'." $Cmd = @{ FilePath = Join-Path ([Environment]::SystemDirectory) -ChildPath 'msiexec.exe' ArgumentList = "/package `"$MSIPath`" /l `"$LogFile`" /quiet /norestart" } Write-Verbose 'Executing command line' Write-Verbose "$($Cmd.FilePath) $($Cmd.ArgumentList)" $Return = Start-Process @Cmd -Wait -PassThru if ($Return) { $ExitCode = $Return.ExitCode } else { $ExitCode = 2 } if ($ExitCode -eq 0) { Write-Verbose "Successfully installed file `'$MSIPath`'." } elseif ($ExitCode -eq 3010) { Write-Warning 'Restart required to complete the installation.' } else { Write-Error "Error occured while installing file `'$MSIPath`'. Error code: $ExitCode" } exit $ExitCode
Gruß
Joachim- Bearbeitet Joachim Meyer Mittwoch, 22. April 2015 08:33
- Als Antwort markiert Denniver ReiningMVP, Moderator Mittwoch, 29. April 2015 11:22
Alle Antworten
-
Hallo Sascha,
lies mal diesen Artikel hier: LINK, da wird dir das mit den externen Programmen und Parametern erklärt und dann für die Zukunft bitte auch mal den hier: LINK.Grüße, Denniver
Blog: http://bytecookie.wordpress.com
Kostenloser Powershell Snippet Manager v3: Link
(Schneller, besser + einfacher scripten.)
Hilf mit und markiere hilfreiche Beiträge mit dem "Abstimmen"-Button (links) und Beiträge die eine Frage von dir beantwortet haben, als "Antwort" (unten).
Warum das Ganze? Hier gibts die Antwort. -
- Würde ich mich beim Aufrufen der Installation nicht auf irgendwelche Shell-Zuordnungen verlassen.
- Beim automatisierten Ausführen eines Scripts auf n Systemen wäre es doch sicher nicht von Schaden, wenn du mitkriegen würdest, ob es überhaupt funktioniert hat? Daher immer Rückgabewerte verwenden!
- Ich würde mir mal das PowerShell App Deployment Toolkit anschauen. Das hat diese Funktion schon fest eingebaut.
Und hier mal ein Beispiel für die Installation eines MSIs:
# Quick & Dirty with minimal testing # Use on your own risk [CmdletBinding()] Param ( [Parameter(Mandatory=$true,Position=0)] [string]$MSIPath ) $ExitCode = 0 if (-not (Test-Path $MSIPath)) { Write-Error "Could not find file `'$MSIPath`'." exit 1 } if (-not (Split-Path $MSIPath -IsAbsolute)) { $MSIPath = Resolve-Path $MSIPath } $LogFile = Join-Path $env:TEMP -ChildPath "$((Get-Item $MSIPath).BaseName).log" Write-Verbose "Found MSI file `'$MSIPath`'." Write-Verbose "Using log file `'$LogFile`'." $Cmd = @{ FilePath = Join-Path ([Environment]::SystemDirectory) -ChildPath 'msiexec.exe' ArgumentList = "/package `"$MSIPath`" /l `"$LogFile`" /quiet /norestart" } Write-Verbose 'Executing command line' Write-Verbose "$($Cmd.FilePath) $($Cmd.ArgumentList)" $Return = Start-Process @Cmd -Wait -PassThru if ($Return) { $ExitCode = $Return.ExitCode } else { $ExitCode = 2 } if ($ExitCode -eq 0) { Write-Verbose "Successfully installed file `'$MSIPath`'." } elseif ($ExitCode -eq 3010) { Write-Warning 'Restart required to complete the installation.' } else { Write-Error "Error occured while installing file `'$MSIPath`'. Error code: $ExitCode" } exit $ExitCode
Gruß
Joachim- Bearbeitet Joachim Meyer Mittwoch, 22. April 2015 08:33
- Als Antwort markiert Denniver ReiningMVP, Moderator Mittwoch, 29. April 2015 11:22