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
>