![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | Parameters I have the following code in a script called 'IP': function total() { ipconfig -all } function MAC() { $Name = ipconfig -all | findstr "Physical"; $Name.Replace("Physical", "MAC") } function IPAdd() { ipconfig | findstr "IP" } function subnet() { ipconfig -all | findstr "Subnet" } What do I need to add so I can e.g. call the MAC function by doing this at the command line?: ../IP -MAC |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Parameters Pimp Daddy wrote: Quote: > I have the following code in a script called 'IP': > > function total() > { > ipconfig -all > } > > function MAC() > { > $Name = ipconfig -all | findstr "Physical"; > $Name.Replace("Physical", "MAC") > } > > function IPAdd() > { > ipconfig | findstr "IP" > } > > function subnet() > { > ipconfig -all | findstr "Subnet" > } > > > > What do I need to add so I can e.g. call the MAC function by doing this at > the command line?: > > ./IP -MAC function IP { if ($args -contains "-total") {ipconfig -all} if ($args -contains "-mac"){ $Name = ipconfig -all | findstr "Physical" $Name|foreach-object {$_.Replace("Physical", "MAC")} } if ($args -contains "-ipadd") {ipconfig | findstr "IP"} if ($args -contains "-subnet"){ ipconfig -all | findstr "Subnet" } } PSH> . ./IP.ps1 PSH> IP -MAC MAC Address. . . . . . . . . : xxxxxxxxxxxxxx .... -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Parameters function IP ($pattern){ switch ($pattern){ "mac" { $Name = ipconfig -all | findstr "Physical" $Name | foreach {$_.Replace("Physical", "MAC")} break; } "ipadd" { ipconfig | findstr "IP" ; break} "subnet" { ipconfig -all | findstr "Subnet"; break} default { ipconfig -all; break} } } IP # get total IP mac # get mac IP subnet # get subnet Also, read about the select-string. It's the PowerShell findstr 'equivalent', for more help, type: help select-string -full ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic Quote: > I have the following code in a script called 'IP': > > function total() > { > ipconfig -all > } > function MAC() > { > $Name = ipconfig -all | findstr "Physical"; > $Name.Replace("Physical", "MAC") > } > function IPAdd() > { > ipconfig | findstr "IP" > } > function subnet() > { > ipconfig -all | findstr "Subnet" > } > What do I need to add so I can e.g. call the MAC function by doing > this at the command line?: > > ./IP -MAC > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| parameters in .net | .NET General | |||
| Far Cry parameters | Vista Games | |||
| environment parameters | Vista installation & setup | |||
| Parameters with ScriptMethod? | PowerShell | |||