powershell (PowerShell)请求静态IP配置并将其放入文本文件中

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell (PowerShell)请求静态IP配置并将其放入文本文件中相关的知识,希望对你有一定的参考价值。

## 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

以上是关于powershell (PowerShell)请求静态IP配置并将其放入文本文件中的主要内容,如果未能解决你的问题,请参考以下文章