How to mount a local ISO to a VMware VM using PowerCLI

Using the below power CLI script we can mount an iso image that's there in your windows VM to a VMware VM.

Connect-VIServer -Server <IP> -Protocol https -User <> -Password <pass>

  1. $Datastore = "datastore1"    //datastore on your VC 
  2. Get-Datastore $Datastore | New-DatastoreDrive -Name ds
  3. New-Item -Type Directory -Path ds:\ISOfiles
  4. Copy-DatastoreItem -Item "<Path of the ISO file>" -Destination ds:\ISOfiles\0.iso
  5. Get-VM -Name SCVOVA1 |Get-CDDrive | Set-CDDrive -IsoPath "[$Datastore] ISOfiles\0.iso" -Confirm:$false -Connected $true


Once you are done please remove the PS drive using:

C:\> Remove-PSDrive -Name ds

No comments:

Post a Comment

How to increase ESXi webclient login user application timeout

 To increase the default 15min timeout to 2hr Login to the esxi webclient on the right top corner ->Click the User login tab Select "...