Retrieving Image Objects
Retrieving Image Objects
Image Objects available in the DSM environment are retrieved via the Get-EmdbStateImage cmdlet.
Examples:
Hint: The execution of these examples requires a connected PowerShell drive. |
The following example retrieves all Image Objects available in the folder "Image Library" and possibly existing subfolders:
Get-EmdbStateImage "emdb:\rootDSE\Global Software Library\Image Library\*" -Recurse |
Typically, Image Objects are associated with so called Image-Groups - this association, however, is not visible in the DMSC yet. Using the PowerShell Extensions, it is easy to determine the Image-Group "belonging" to an Image Object. First you have to retrieve the Image Object. The object's property ImageGroup contains the Object-ID of the Image-Group associated with the Image Object.
$MyImage = Get-EmdbStateImage "emdb:\rootDSE\Global Software Library\Image Library\Win7 Master Image" $MyImageGroup = Get-EmdbGroup -Path "emdb:\rootDSE\Managed Users & Computers\*" -Filter "ObjectID=$($MyImage.ImageGroup)" -Recurse |
The content of the Image Object is available in the Content-property in XML notation. The value can be retrieved and reused for documentation purposes for example:
$MyImageContent = (Get-EmdbStateImage "emdb:\rootDSE\Global Software Library\Image Library\Win7 Master Image").Content |
Retrieve the Image Object "Windows 8.1 Reference Image" in the current context through its Item-ID (this ID will vary in different DSM environments):
Get-EmdbStateImage -ItemID 1983 -Recurse |
Tip: the alias ID can be used instead of ItemID. |
Starting with PSX 3.1 there was a new option implemented when retrieving Image objects. When specifying the SingleItemExpected-switch it is expected, that none or exactly one object is contained in the result. If the retrieval returns more than one object, an error is raised that can be caught and handled in scripts.