Benutzer mit den meisten Antworten
PowerShell - Software mit Parametern auf Server starten

Frage
-
Hallo und schon mal danke im Voraus für jegliche Hilfestellungen!
Ein Kollege von mir hat ein Script gebastelt welches dafür verwendet werden soll auf einem Lokalen PC ausgeführt zu werden und auf dem Server checkt was für Backup Jobs vorhanden sind, welche ausgeführt werden dürfen und diese dann auch ausführt.
Jetzt habe ich das Problem dass dieses Script auf manchen PCs Einwandfrei funktioniert und auf anderen garnicht, wenn es nicht funktioniert kommt diese Fehlermeldung:
Cannot validate argument on parameter 'ArgumentList'. The argument ist null or empty. Provide an argument that is not null or empty, and then try the command again. + CategoryInfo : InvalidData: (:) [Start-Process], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.StartProcessCommand + PSComputerName : inhas64746
Ich bin ein PowerShell Newbie und daher schon mal die nächste dumme Frage.. da er mir hier + PSComputerName : inhas64746 (den Server) anzeigt in der Fehlermeldung, heißt dass das der Server hier Probleme bereitet?
Die betroffene Codezeile:
Invoke-Command -ComputerName $IperiusServer -ScriptBlock {param([string]$p1=$IperiusParam1, $p2=$IperiusParam2) Start-Process -wait -FilePath "c:\program files (x86)\Iperius Backup\Iperius.exe" -ArgumentList $p1, $p2}
Wenn ich die Variablen direkt vor dieser Zeile ausleise werden sie mir richtig angezeigt.
Die Variablen sind die folgenden:
$p1 = "startbackup"
$p2 = '"backup job name'"
Das gesamte Script:
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { $arguments = "& '" + $myinvocation.mycommand.definition + "'" Start-Process powershell -Verb runAs -ArgumentList $arguments Break } $JobDir = ‘\\inhas64746\iperiusbackupjobs’ $JobFiles = ‘\\inhas64746\iperiusbackupjobs\*’ $IperiusServer = "inhas64746" $IperiusExe = '"c:\program files (x86)\Iperius Backup\Iperius.exe"' $IperiusParam1 = "startbackup" Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing $form = New-Object System.Windows.Forms.Form $form.Text = "Select a Computer" $form.Size = New-Object System.Drawing.Size(300,200) $form.StartPosition = "CenterScreen" $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Point(75,120) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text = "OK" $OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK $form.AcceptButton = $OKButton $form.Controls.Add($OKButton) $CancelButton = New-Object System.Windows.Forms.Button $CancelButton.Location = New-Object System.Drawing.Point(150,120) $CancelButton.Size = New-Object System.Drawing.Size(75,23) $CancelButton.Text = "Cancel" $CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel $form.CancelButton = $CancelButton $form.Controls.Add($CancelButton) $label = New-Object System.Windows.Forms.Label $label.Location = New-Object System.Drawing.Point(10,20) $label.Size = New-Object System.Drawing.Size(280,20) $label.Text = "Please select a computer:" $form.Controls.Add($label) $listBox = New-Object System.Windows.Forms.ListBox $listBox.Location = New-Object System.Drawing.Point(10,40) $listBox.Size = New-Object System.Drawing.Size(260,20) $listBox.Height = 80 Function Load-IniFile ($inputfile) { [string] $comment = ";" [string] $header = "^\s*(?!$($comment))\s*\[\s*(.*[^\s*])\s*]\s*$" [string] $item = "^\s*(?!$($comment))\s*([^=]*)\s*=\s*(.*)\s*$" [hashtable]$ini = @{} Switch -Regex -File $inputfile { "$($header)" { $section = ($matches[1] -replace ' ','_'); $ini[$section.Trim()] = @{} } "$($item)" { $name, $value = $matches[1..2]; If (($name -ne $null) -and ($section -ne $null)) { $ini[$section][$name.Trim()] = $value.Trim() } } } Return $ini } $ListBoxCount=0 #foreach ($objResult in get-childitem $JobFiles -include *.ibj -exclude "job001.ibj", "job002.ibj" | % { $_.FullName }) foreach ($objResult in get-childitem $JobFiles -include *.ibj | % { $_.FullName }) { $iniFile = Load-IniFile $objResult #write $inifile['HEADER']['NAME'] #write $inifile['HEADER']['RemoteTriggerAllowedFrom'] #start-sleep 1 $RT=$inifile['HEADER']['RemoteTriggerAllowedFrom'] if (![string]::IsNullOrEmpty($RT) -And ($RT -like "*" + $env:COMPUTERNAME + "*" -Or $RT -eq '*')) { $ListBoxCount=$ListBoxCount+1 write $inifile['HEADER']['NAME'] [void] $listBox.Items.Add($inifile['HEADER']['NAME']) } } write $ListBoxCount if ($ListBoxCount -eq 0) { write "No Entry found" Start-Sleep 10 Exit } $form.Controls.Add($listBox) $form.Topmost = $True $result = $form.ShowDialog() if ($result -eq [System.Windows.Forms.DialogResult]::OK) { $x = $listBox.SelectedItem #Write "Selected Job: $x" } $OSArch = (Get-WmiObject Win32_OperatingSystem).OSArchitecture If ($OSArch -like '64*') { $ProgFilePath=[Environment]::GetEnvironmentVariable("ProgramFiles(x86)") } else { $ProgFilePath=[Environment]::GetEnvironmentVariable("ProgramFiles") } #Check if Eventlog sourec exists if (-not (Invoke-Command -ComputerName $IperiusServer -ScriptBlock {[System.Diagnostics.EventLog]::SourceExists("IperiusBackupJob")})) { write "IperiusBackupJob does not exist as source in Eventlog, create it now ..." Invoke-Command -ComputerName $IperiusServer -ScriptBlock {[System.Diagnostics.EventLog]::CreateEventSource("IperiusBackupJob","Application")} } $IperiusParam2 = """$x""" Write "Create Eventlog Entry on server: $IperiusServer ..." Write-Eventlog -Source IperiusBackupJob -LogName Application -EntryType Information -EventID 9999 -Message "Iperius Backup Job $IperiusParam2 startet from Remote computer $env:COMPUTERNAME" -ComputerName $IperiusServer Write "Selected Job $x is running on server $IperiusServer now..." Invoke-Command -ComputerName $IperiusServer -ScriptBlock {param([string]$p1=$IperiusParam1, $p2=$IperiusParam2) Start-Process -wait -FilePath "c:\program files (x86)\Iperius Backup\Iperius.exe" -ArgumentList $p1, $p2} Start-Sleep 5
Wie gesagt auf manchen PCs funktioniert es ohne Probleme und auf anderen bekomme ich diese Fehlermeldung.
Freue mich über jegliche Hilfe.
Vielen Dank!
LG,
updog
Mittwoch, 27. Juni 2018 07:55
Antworten
-
...aber abgesehen davon: Versuche mal, den Invoke-Command-Aufruf wie folgt umzubauen:
Invoke-Command -ComputerName $IperiusServer -ScriptBlock {param([string]$p1,$p2) Start-Process -wait -FilePath "c:\program files (x86)\Iperius Backup\Iperius.exe" -ArgumentList $p1, $p2} -ArgumentList $IperiusParam1, $IperiusParam2
Evgenij Smirnov
I work @ msg services ag, Berlin -> http://www.msg-services.de
I blog (in German) @ http://it-pro-berlin.de
my stuff in PSGallery --> https://www.powershellgallery.com/profiles/it-pro-berlin.de/
Exchange User Group, Berlin -> https://exusg.de
Windows Server User Group, Berlin -> http://www.winsvr-berlin.de
Mark Minasi Technical Forum, reloaded -> http://newforum.minasi.com
In theory, there is no difference between theory and practice. In practice, there is.
- Als Antwort markiert updog1337 Mittwoch, 27. Juni 2018 10:28
Mittwoch, 27. Juni 2018 09:30
Alle Antworten
-
Moin,
kann es sein, dass auf den problematischen Clients eine ältere PowerShell-Version installiert ist, d.h. älter als 3.0?
Evgenij Smirnov
I work @ msg services ag, Berlin -> http://www.msg-services.de
I blog (in German) @ http://it-pro-berlin.de
my stuff in PSGallery --> https://www.powershellgallery.com/profiles/it-pro-berlin.de/
Exchange User Group, Berlin -> https://exusg.de
Windows Server User Group, Berlin -> http://www.winsvr-berlin.de
Mark Minasi Technical Forum, reloaded -> http://newforum.minasi.com
In theory, there is no difference between theory and practice. In practice, there is.
Mittwoch, 27. Juni 2018 08:04 -
Hallo,
wow.. scheinbar sogar eine ältere Version auf dem funktionierenden Client..
Funktionierender Client:
PSVersion 2.0 WSManStackVersion 2.0 SerializationVersion 1.1.0.1 CLRVersion 2.0.50727.8669 Buildversion 6.1.7601.17514 PSCompatibleVersion {1.0, 2.0,} PSRemotingProtocolVersion 2.1
Client wo es nicht funktioniert:
PSVersion 4.0 WSManStackVersion 3.0 SerializationVersion 1.1.0.1 CLRVersion 4.0.30319.36440 Buildversion 6.3.9600.18728 PSCompatibleVersion {1.0, 2.0, 3.0, 4.0} PSRemotingProtocolVersion 2.2
Am Server:
PSVersion 4.0 WSManStackVersion 3.0 SerializationVersion 1.1.0.1 CLRVersion 4.0.30319.34014 Buildversion 6.3.9600.18968 PSCompatibleVersion {1.0, 2.0, 3.0, 4.0} PSRemotingProtocolVersion 2.2
Das heißt das ist dann wohl ziemlich sicher der Übeltäter.. allerdings ist jetzt nur die Frage wie ich dieses Problem beseitigen kann.. eventuell weiß mein Kollege rat.
Auf jeden Fall schon mal vielen lieben Dank!!
LG,
updog
- Bearbeitet updog1337 Mittwoch, 27. Juni 2018 09:20 besser beschrieben
Mittwoch, 27. Juni 2018 09:19 -
...aber abgesehen davon: Versuche mal, den Invoke-Command-Aufruf wie folgt umzubauen:
Invoke-Command -ComputerName $IperiusServer -ScriptBlock {param([string]$p1,$p2) Start-Process -wait -FilePath "c:\program files (x86)\Iperius Backup\Iperius.exe" -ArgumentList $p1, $p2} -ArgumentList $IperiusParam1, $IperiusParam2
Evgenij Smirnov
I work @ msg services ag, Berlin -> http://www.msg-services.de
I blog (in German) @ http://it-pro-berlin.de
my stuff in PSGallery --> https://www.powershellgallery.com/profiles/it-pro-berlin.de/
Exchange User Group, Berlin -> https://exusg.de
Windows Server User Group, Berlin -> http://www.winsvr-berlin.de
Mark Minasi Technical Forum, reloaded -> http://newforum.minasi.com
In theory, there is no difference between theory and practice. In practice, there is.
- Als Antwort markiert updog1337 Mittwoch, 27. Juni 2018 10:28
Mittwoch, 27. Juni 2018 09:30