Jump to content
Welcome to our new Citrix community!
  • 0

Mounting ISO in VM issue : invoke-XenVBD -XenAction Insert


Julien BANZI1709152910

Question

Hi everyone, 

 

I'm working on a powershell script that required to be able to unmount or mount some ISO in a particular VM.

 

No prob for the "unmounting" part with invoke-xenvbd -XenAction Eject but i'm not able to mount an ISO with the same command but with the XenAction Insert.

 

Here is my code sample :

 

$Master = Get-XenVM -Name $($XD_Master.Xen_MasterName)

 

$ISO_library = get-XenSR | Where-Object {($_.type -eq 'iso') -and $_.name_label -notmatch 'XenServer Tools'}

 

$CD = ForEach ($ISO in $ISO_Library.VDIs) {Get-XenVDI -Ref $ISO.opaque_ref | Where-Object {$_.name_label -eq 'FinalisationVDI.iso'}}

 

$VBD = $Master.VBDs | Get-XenVBD | where {($_.Type -eq 'CD')}

 

I try this command to mount the ISO but it fails...

 

Invoke-XenVBD -Uuid $VBD.uuid -XenAction Insert $CD.uuid

 

Any help please ?

 

 

  • Like 1
Link to comment

10 answers to this question

Recommended Posts

  • 0

I'm stuck on the same, to mount exiting ISO via powershell, but it doesn't work with the command 

 

 

Get-XenVDI -Name "$BootISOName" | Invoke-XenVBD -Uuid (Get-XenVBD)[2].uuid -XenAction Insert
Invoke-XenVBD : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any 
of the parameters that take pipeline input.
At line:1 char:35
+ Get-XenVDI -Name "$BootISOName" | Invoke-XenVBD -Uuid (Get-XenVBD)[2].uuid -XenA ...
+                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (XenAPI.VDI:PSObject) [invoke-XenVBD], ParameterBindingException
    + FullyQualifiedErrorId : InputObjectNotBound,Citrix.XenServer.Commands.InvokeXenVBD

 

------------------------------------------

ouput from Get-XenVDI -Name $BootIsoName

 

 

uuid                 : e0bda688-5519-4ace-953d-999d4f2026c1
name_label           : PVS-DHCP-D1.iso
name_description     : 
allowed_operations   : {forget, destroy, copy, snapshot}
current_operations   : {}
SR                   : XenAPI.XenRef`1[XenAPI.SR]
VBDs                 : {XenAPI.XenRef`1[XenAPI.VBD], XenAPI.XenRef`1[XenAPI.VBD]}
crash_dumps          : {}
virtual_size         : 307200
physical_utilisation : 307200
type                 : user
sharable             : False
read_only            : True
other_config         : {[content_id, 30b7a9b0-a557-ef45-7005-b0376b1f11a6]}
storage_lock         : False
location             : PVS-DHCP-D1.iso
managed              : True
missing              : False
parent               : XenAPI.XenRef`1[XenAPI.VDI]
xenstore_data        : {}
sm_config            : {}
is_a_snapshot        : False
snapshot_of          : XenAPI.XenRef`1[XenAPI.VDI]
snapshots            : {}
snapshot_time        : 01.01.1970 00:00:00
tags                 : {}
allow_caching        : False
on_boot              : persist
metadata_of_pool     : XenAPI.XenRef`1[XenAPI.Pool]
metadata_latest      : False
opaque_ref           : OpaqueRef:7ed76e36-8c9a-a13f-063f-87003a6d64ec
Changed              : True
Link to comment
  • 0

This is not going to work because at the moment the -VDI parameter does not accept pipeline input, and additionally it is a reference, not a VDI object.

 

The most PS-like way I can think of writing your command is:

PS> Invoke-XenVBD -VBD (Get-XenVBD)[2] -XenAction Insert -VDI (Get-XenVDI -Name "$BootISOName" | select -ExpandProperty opaque_ref)

or

PS> (Get-XenVBD)[2] | Invoke-XenVBD -XenAction Insert -VDI (Get-XenVDI -Name "$BootISOName" | select -ExpandProperty opaque_ref)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...