Removing Image Objects

Image Objects are deleted using the Remove-EmdbStateImage cmdlet or by calling the object's Delete()-method.


Examples:


Hint: The execution of these examples requires a connected PowerShell drive.


The example below deletes the Image Object "Win7 Master Image":


Remove-EmdbStateImage "emdb:\rootDSE\Global Software Library\Image Library\Win7 Master Image"


This snippet removes the Image Object "Win8 Master Image" in the current context:


Cd "emdb:\rootDSE\Global Software Library\Image Library"

Remove-EmdbStateImage "Win8 Master Image"


The following example first retrieves the Image Object "Win 7 Master Image" and deletes it subsequently:


$MyImage = Get-EmdbStateImage "emdb:\rootDSE\Global Software Library\Image Library\Win7 Master Image"

$MyImage.Delete()


In the example shown below, all Image Objects having a name beginning with "WinXP" are retrieved and then deleted:


Cd "emdb:\rootDSE\Global Software Library\Image Library"

Get-EmdbStateImage "WinXP*" | ForEach-Object {$_.Delete()}


Note: If an Image Object having an associated Image-Group is deleted, the corresponding Image-Group is deleted automatically.


Starting with PSX 3.1 there was a new option implemented when deleting Image objects. When specifying the SingleItemExpected-switch it is expected, that none or exactly one object is affected. If the command would delete more than one object, an error is raised that can be caught and handled in scripts.