Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Hyper-V batch create virtual machines automatically change IP and configure PPPOE dialing

2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

PowerShell creates virtual machines in bulk:

#-batch create virtual machine script 20190314-

# Virtual machine storage path

$VHDPath= "d:\ vhd\"

# initial information of virtual machine IP

$IP= "192.168.185."

# Virtual Machine IP start value

$IP_START=2

# number of virtual machines to be created

``quantity

$IP_ZENJIA=25

# name of virtual machine Nic

$NetworkName1= "hgpppoe"

$NetworkName2= "nat"

# Dial-up DNS+ password

$DNS1= "202.103.44.150"

$DNS2= "223.5.5.5"

$PPPOEWD= "123789"

# number of virtual machine cpu cores

$LogicPrecesserCount=2

# Virtual machine memory

$MomeryCount=2GB

# template location

$MasterDiskPath= "C:\ mupan.vhdx"

#-the following part does not need to be modified-

$IP_END=$IP_START+$IP_ZENJIA-1

For ($iSuppli / IP / startup / I-le$IP_END;$i++) {

$VMDIR = $VHDPath + $IP + $I

# create a folder where virtual machine disks are stored

Mkdir $VMDIR

# Virtual Machine name

$VMName = $IP + $I + ".vhdx"

# the full path where the virtual machine file is located

$VMCFDIR = $VMDIR + "\" + $VMName

# copy the master disk to the directory where the virtual machine is stored

Copy-Item $MasterDiskPath $VMCFDIR

# read the dialing information specified by the virtual machine

$PPPOE= (Get-Content C:\ adsl.txt-TotalCount $I) [- 1]

# create a virtual machine

$HYName = $IP + $I + "/" + $PPPOE

New-VM-Name $HYName-path $VMDIR-MemoryStartupBytes $MomeryCount-VHDPath $VMCFDIR-SwitchName $NetworkName1

# to the virtual machine disk directory

Cd $VMDIR

# create new private network Nic information

New-Item "ip.txt"-type File

# write intranet Nic information to a file

"IPADDR=$IP$I" | Out-File ip.txt-encoding utf8

# create an automatic dialing script

New-Item "autoad.sh"-type File

# Editing automatic dialing script

"pppoe-setup

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report