We are attempting to take a vendor's command-line remote execution and convert it to PowerShell 2.0. However, it seems that we are unable to get the command to run remotely due to the way the variables are setup. They are space delimited instead of comma delimited. We have created a form to get the input for our variables. Does anyone have a suggestion on how to get this to work in PowerShell? Thank you! Rhett
#Call the Function
GenerateForm
#Attempting to translate Dos command below to Powershell
#winrs -r:$ServerName -nop -d:"C:\Program Files (x86)\PaperCut NG\server\bin\win\" server-command.exe $Command $Varible1 $Varible2 $Varible3
#cd C:\Program Files\PaperCut NG\server\bin\win\server-command rename-printer oldprintserver oldqueuename newprintserver newqueuename
#From: http://www.papercut.com/kb/Main/HowToRenameAPrinter
#Also: http://www.papercut.com/kb/Main/CallingServerCommandRemotely
#Server Commands List: http://www.papercut.com/products/ng/manual/apdx-tools.html
#Have tried below and many others:
#Invoke-Command -computername $ServerName -scriptblock {'C:\Program Files (x86)\PaperCut NG\server\bin\win\server-command.exe rename-printer $OldPrintServer $OldQueueName $NewPrintServer $NewQueueName}
#Invoke-Command -Authentication Kerberos -computername $ServerName -scriptblock {"C:\Program Files (x86)\PaperCut NG\server\bin\win\server-command.exe"} -ArgumentList {param(rename-printer[, $OldPrintServe][, $OldQueueName][, $NewPrintServer][, $NewQueueName])}
#Invoke-Command -computername $ServerName -scriptblock {cd 'C:\Program Files (x86)\PaperCut NG\server\bin\win\'; .\'server-command.exe rename-printer' $OldPrintServer $OldQueueName $NewPrintServer $NewQueueName}
#Invoke-Command -computername $ServerName -scriptblock {cd 'C:\Program Files (x86)\PaperCut NG\server\bin\win\'; .\'server-command.exe' + ' rename-printer' + ' ' + $OldPrintServer + ' ' + $OldQueueName + ' ' + $NewPrintServer + ' ' + $NewQueueName}
#Invoke-Command -computername $ServerName &"C:\Program Files (x86)\PaperCut NG\server\bin\win\server-command.exe" "rename-printer" "$OldPrintServer" "$OldQueueName" "$NewPrintServer" "$NewQueueName"
#Invoke-Command -computername $ServerName &{"C:\Program Files (x86)\PaperCut NG\server\bin\win\server-command.exe" "rename-printer" "$OldPrintServer" "$OldQueueName" "$NewPrintServer" "$NewQueueName"}
Invoke-Command -computername $ServerName -scriptblock {&"C:\Program Files (x86)\PaperCut NG\server\bin\win\server-command.exe" "rename-printer" "$OldPrintServer" "$OldQueueName" "$NewPrintServer" "$NewQueueName"}
Read-Host "Press ENTER to continue"