![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | 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) |
| Guest | 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 | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing parameters to a cmdlet in a variable | Alastair Smith | PowerShell | 1 | 02-08-2008 06:29 AM |
| Hosting PowerShell & passing parameters to script | Dmitry Naumov | PowerShell | 9 | 09-24-2007 03:34 AM |
| Passing parameters to PS script and escaping spaces | James | PowerShell | 2 | 08-14-2007 07:30 AM |
| passing [switch] parameters | Jeff | PowerShell | 4 | 07-28-2007 09:17 AM |
| Passing parameters to a PS script | Dan | PowerShell | 9 | 07-17-2007 05:05 PM |