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

Selenium firefox driver session fails with : Could not start a new session. Response code 500. Message: Expected browser binary location, but unable to find binary in default location,

 Error: With Firefox driver /gecko driver Could not start a new session. Response code 500. Message: Expected browser binary location, but u...