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