Power shell script with options


i'm trying teach myself powershell , thought i'd start out little script change ip addresses options menu powershell. can't figure out how though take input, example 1, 2 or 3 , have corresponds input, example change ip address address specified. can give me pointers go or how proceed this? many thanks, peter

with following small script can ask ip address , validate it:

function validateip ($ipaddress) {     $pattern = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";      if ( $ipaddress -match $pattern) {         return $true     } else {         return $false     } }  $ip = read-host "insert ip-address: " validateip $ip  

save under meaningful name , start dotsourcing (". <fullnameofyourscript>; can leave path out, if script stored in directory listed in environment path variable).

kind regards,

wizend



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

some help on Event 540

WMI Repository 4GB limit - Win 2003 Ent Question

Event ID 1302 (error 1307) DFS replication service encountered an error while writing to the debug log file