![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Powershell Invoke-Item and cmd line parameters I am trying to use powershell to execute a net use command on many machines. Unfortunately, I can not get the cmd line parameters to parse properly. Could you assist in this endevour. Thanks. $Computer = get-QADComputer -SearchRoot 'frabrikam/Enterprise- Applications/Business-Systems/MS/Admin-Systems'| foreach-object {$_.name} foreach ($i in $Computer){ $command = "\\"+ $i $command2 = "D:\Sysinternals\psexe.exe "+ $command +"Net use m: \ \servershare\subfolder " Invoke-Item $command2 } |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Powershell Invoke-Item and cmd line parameters "Damian" <damian.yates@xxxxxx> wrote in message news:ba8545c3-a07f-468f-b5ae-fafd2868bb82@xxxxxx Quote: > I am trying to use powershell to execute a net use command on many > machines. Unfortunately, I can not get the cmd line parameters to > parse properly. Could you assist in this endevour. > > Thanks. > > $Computer = get-QADComputer -SearchRoot 'frabrikam/Enterprise- > Applications/Business-Systems/MS/Admin-Systems'| foreach-object > {$_.name} > > foreach ($i in $Computer){ > $command = "\\"+ $i > $command2 = "D:\Sysinternals\psexe.exe "+ $command +"Net use m: \ > \servershare\subfolder " > Invoke-Item $command2 > } want to use Invoke-Expression instead of Invoke-item. Invoke-Item is more for using the ShellExecute capabilities of Windows e.g. invoke-item foo.xls opens Excel and loads foo.xls. But I wouldn't use Invoke-Expression either. I would execute psexec directly like so: $computers | Foreach {d:\Sysinternals\psexec.exe "\\$_" "net use m: \\server\sharename"} -- Keith |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Re: Invoke Scriptblock with parameters in a new thread | PowerShell | |||
| Invoke-Item with param. | PowerShell | |||
| Foreground Invoke-Item | PowerShell | |||
| Another Invoke-Item question | PowerShell | |||
| Invoke-Item and passing command line parameters | PowerShell | |||