Skip to content

Instantly share code, notes, and snippets.

@carlessanagustin
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlessanagustin/724b482de97795e880f6 to your computer and use it in GitHub Desktop.
Save carlessanagustin/724b482de97795e880f6 to your computer and use it in GitHub Desktop.
(PowerShell) Request static IP configuration and place it into a text file
## An A-Z Index of Windows PowerShell 2.0 commands: http://ss64.com/ps/
do {
$ip = Read-Host "Enter IP address"
$mask = Read-Host "Enter mask"
$gw = Read-Host "Enter default gateway"
Write-Host 'Is this information correct? IP $ip MASK $mask GW $gw'
$confirm = Read-Host "yes/no"
}while ($confirm -notlike "yes")
$text = 'sudo ifconfig eth0 $ip netmask $mask`n
sudo route add default gw $gw eth0`n
nameserver 8.8.8.8`n
nameserver 8.8.4.4`n'
## https://technet.microsoft.com/en-us/library/hh849859.aspx
Add-Content -Path C:\Users\UserName\Desktop\test.txt -Value $text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment