PowerShell: Destroy CIFS ISO Library

This is step one of two in destroying (and then re-creating) a CIFS ISO library in XenServer, the reasons you may need to do this are varied, this is personally useful to me in a lab environment when the repo location or user credentials may change often. Everythign below requires the XenServer PSSnapin.

First thing we want to do is snag the info for the SR we want to delete:

$sr = Get-XenServer:SR | Where-Object {$_.content_type -eq "iso" -and $_.type -ne "udev" -and $_.name_label -ne "XenServer Tools"}

This filters out the CD-ROM (udev) and XS Tools and just returns us SR's whose content type is ISO, so it shouldn't matter what you name your repo (um, as long as you don't name it XenServer Tools I guess).

Now we need to unplug it:

foreach($i in $sr.PBDs){Invoke-XenServer:PBD.Unplug -SR $i}

Do you need to foreach this? Probably not. But if you DO happen to set it up with multiple PBD's then it will still fail on the next step because you only unplugged some of the PBD's, when in doubt, be thorough.

Now lets remove the SR:

Invoke-XenServer:SR.Forget -SR $sr.name_label

There you go, the next step will be to ask for a path, user and password to create a new ISO Library, which I'll cover next time.

 

Previous
Previous

PowerShell: XenServer Recreate ISO Store

Next
Next

App-V 5.0: Package Conversion Script