![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | passing parameters to script (ps1) i have the following command in my ps1 script : get-wmiobject Win32_ComputerSystem -computername 155.14.197.22 | format-table -property username I wish to change to following : get-wmiobject Win32_ComputerSystem -computername <this becomes a parameter, and how to make it a parameter> | format-table -property username From my cmd prompt, how do i call the scripts filling in the parameters eg powershell -command test.ps1 <parameter 1>, etc |
My System Specs![]() |
| | #2 (permalink) |
| | RE: passing parameters to script (ps1) "IT Staff" wrote: > i have the following command in my ps1 script : > > get-wmiobject Win32_ComputerSystem -computername 155.14.197.22 | > format-table -property username > > I wish to change to following : > > get-wmiobject Win32_ComputerSystem -computername <this becomes a parameter, and how to make it a parameter> | format-table -property username Try someting like: get-wmiobject Win32_ComputerSystem -computername $args[0] | format-table -property username # $args[0] is the first parameter of your script, $args[1] the second, etc. > From my cmd prompt, how do i call the scripts filling in the parameters > > eg powershell -command test.ps1 <parameter 1>, etc you guessed correctly: PS>get-content C:\do-foo.ps1 write-host 'test0' write-host $args[0] write-host $args[1] cmd> powershell -command c:\do-foo.ps1 test1 test2 test0 test1 test2 -- greetings dreeschkind |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Passing parameters to a PS script | PowerShell | |||
| Help with PS wretched way of passing parameters to executables | PowerShell | |||
| Hosting PowerShell & passing parameters to script | PowerShell | |||
| Passing parameters to PS script and escaping spaces | PowerShell | |||
| passing [switch] parameters | PowerShell | |||