Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 

Intelligent Automation - Attach/Mount ISO As CD To VMware Virtual Machine

Script Inputs

  • VMName -------------------------------- $args[0]
  • ISO_Path ------------------------------- $args[1]
  • Vcenter ServerName --------------- $args[2]
  • VcenterUserName ------------------ $args[3] 
  • VcenterPassword ------------------- $args[4]

PowerCLI Script

Add-PSSnapin VMware.VimAutomation.Core

Connect-VIServer -Server $args[2] -Protocol https -User $args[3] -Password $args[4]

$vm = Get-VM -Name $args[0]

$datastore = Get-Datastore -Name "NFS_ISO"

if($vm.PowerState -eq "PoweredOn") {

    Get-VM -Name $args[0] | Get-CDDrive | Set-CDDrive -ISOPath $args[1] -StartConnected:$true  -Connected:$true -Confirm:$false

} else {

    Get-VM -Name $args[0] | Get-CDDrive | Set-CDDrive -ISOPath $args[1] -StartConnected:$true -Confirm:$false

}

Disconnect-VIServer $args[2] -confirm:$false

CPO (Process Orcehstrator) Workflow

Mount_CDROM.GIF

[Process.Variables.Input.VMName#<?xml version="1.0" encoding="utf-16"?><VariableReference xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="PropertyReference"><DisplayPath>Process.Variables.Input.VMName</DisplayPath><LinkChain /><ObjectId>458f40ec-c2c5-4052-b3dd-457854c41be6</ObjectId><ObjectType>GlobalVariable</ObjectType></VariableReference>]
507
Views
10
Helpful
0
Comments