Get-SCDirectoryChildItem

Gets all files and subdirectories in the specified directory on a virtual machine host or on a library server managed by VMM.

Syntax

Get-SCDirectoryChildItem
   -VMHost <Host>
   -Path <String>
   [<CommonParameters>]
Get-SCDirectoryChildItem
   -LibraryServer <LibraryServer>
   -Path <String>
   [<CommonParameters>]

Description

The Get-SCDirectoryChildItem cmdlet gets all files and subdirectories immediately under the specified directory on a virtual machine host or on a library server managed by Virtual Machine Manager (VMM). If you specify a share path (such as \ServerName\ShareName\Directory\FileName), the subdirectories of the share path are returned.

If you use the Get-SCDirectoryChildItem cmdlet to retrieve files and subdirectories on a library server, you must specify a path to a valid library share. For example, the share path to the default library share installed by Setup when you first install VMM is: \VMMServerName.DomainName.com\MSSCVMMLibrary

Examples

Example 1: Get the files and subdirectories for the specified path on a VMM host

PS C:\> $VMHost = Get-SCVMHost -ComputerName "VMHost01"
PS C:\> Get-SCDirectoryChildItem -VMHost $VMHost -Path "C:\"

The first command gets the host object named VMHost01 from the VMM database and stores the object in the $VMHost variable.

The second command displays the name and other information about each file and subdirectory immediately under the C:\ drive on VMHost01.

Example 2: Get the subdirectories for the specified path on a library server

PS C:\> $LibServ = Get-SCLibraryServer -VMMServer "VMMServer01.Contoso.com" -ComputerName "FileServer01.Contoso.com"
PS C:\> Get-SCDirectoryChildItem -LibraryServer $LibServ -Path "\\FileServer01.Contoso.com\MSSCVMMLibrary"

The first command gets the library server object named FileServer01 from VMMServer01 and stores the object in the $LibServ variable.

The second command displays the name, parent directory, and other information about each file stored in the directory for the default library share on FileServer01. You must specify the complete path to the library share.

Note: This example assumes that the default VMM library share (MSSCVMMLibrary) is used in your environment. To get the names of library shares, type Get-SCLibraryShare | Select Name.

Required Parameters

-LibraryServer

Specifies a VMM library server object.

Type:LibraryServer
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-Path

Specifies the destination path for the operation.

Example formats:

  • Local path: -Path "F:\"
  • UNC path: -Path "\\Library\Templates"
  • Volume GUID path: -Path "\\?\Volume{4703c1ea-8ae7-11db-b473-00123f7603e3}\"
  • VMware ESX path: -Path "\[storage1\]\MyVMwareFolderForVMs\MyVM.vmx"
  • Citrix XenServer path: -Path "Local storage\[99b6212f-b63d-c676-25f9-d6c460992de7\]"

This parameter accepts wildcard characters for a UNC path.

Example format:

UNC path: -Path "\\VMHostServer\MyVMs\*VM*"

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-VMHost

Specifies a virtual machine host object. VMM supports Hyper-V hosts, VMware ESX hosts, and Citrix XenServer hosts.

For more information about each type of host, see the Add-SCVMHost cmdlet.

Type:Host
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False

Outputs

VMHostFileInformation

This cmdlet returns a VMHostFileInformation object.