powershell修改主机名和IP


Function Rename-Computer( $NewName,$AutoRestart=$false )
{
$computer=Get-WMIObject Win32_ComputerSystem
$computer.Rename( $NewName ) | out-null
if($AutoRestart) { Restart-Computer -Force }
}


$prefx="192.168.0."
$ipaddress = 7..9
Foreach ($sn in $ipaddress)
{
Rename-Computer ZSSH_$ip
netsh interface ip set address "无线网络连接" static 192.168.0.$sn 255.255.255.0 192.168.0.1
netsh interface ip set dns "无线网络连接" static 192.168.0.1
netsh interface ip add dns "无线网络连接" 8.8.4.4
#add-computer -domain "域名" -cred "域名\授权用户" -passthru
$IP=$prefx+$sn
Write-Output "$sn,$IP" >> D:\ServerIPList.txt

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM