How Create Virtual Machine with power cli

آنچه در این مطلب می‌خوانید:

How Create Virtual Machine with power cli

To create a virtual machine using PowerCLI (VMware’s PowerShell-based command-line interface), you can follow these steps:

1-Launch the PowerCLI application or open a PowerShell session and connect to your vCenter server using the Connect-VIServer cmdlet. Provide the necessary information, such as the server IP address, username, and password.

Powershell Script

Connect-VIServer -Server <vCenter-IP> -User <username> -Password <password>

2-Create a new virtual machine configuration using the New-VM cmdlet. Specify the desired parameters such as the name, datastore, resource pool, and guest operating system.

Powershell Script

$vmName = “MyVM”

$datastore = “MyDatastore”

$resourcePool = “MyResourcePool”

$guestOS = “windows9_64Guest”

New-VM -Name $vmName -Datastore $datastore -ResourcePool $resourcePool -GuestId $guestOS

3-Set the virtual machine hardware specifications using the Set-VM cmdlet. You can define parameters like CPU, memory, network adapters, and disk sizes.

powershell Script

$vm = Get-VM -Name $vmName

Set-VM -VM $vm -NumCpu 2 -MemoryGB 4

# Add a network adapter

$networkAdapter = Add-NetworkAdapter -VM $vm -NetworkName “VM Network”

4-Customize the virtual machine settings, such as adding disks or modifying advanced options. Use the appropriate cmdlets like New-HardDisk or Set-VMAdvancedConfiguration.

powershell Script

# Add a new virtual disk

$newDisk = New-HardDisk -VM $vm -CapacityGB 100 -Persistence “IndependentPersistent” -StorageFormat “Thick”

# Modify advanced configuration

Set-VMAdvancedConfiguration -VM $vm -Name “” -Value $true

5-Power on the virtual machine using the Start-VM cmdlet.

Powershell Script

Start-VM -VM $vm

اشتراک گذاری

مدیرعامل آموزشگاه کندو – مدرس شبکه‌های مبتنی بر مایکروسافت و Microsoft Dynamics CRM & 365
0 0 رای ها
امتیازدهی به این محتوا
اشتراک در
اطلاع از
0 نظرات
بازخورد (Feedback) های اینلاین
مشاهده همه دیدگاه ها
افکار شما را دوست داریم، لطفا نظر دهید.x