Converting the FileSystemObject's ParentFolder Property

Definition: Returns a reference to the parent of the specified file or folder.


Use the -parent parameter of the Split-Path cmdlet to retrieve the parent of a file or folder:

Split-Path C:\scripts -parent

To retrieve a reference to that file or folder, pipe the output to Get-Item:

$a = Split-Path C:\scripts -parent | Get-Item

See conversions of other FileSystemObject methods and properties.
Return to the VBScript to Windows PowerShell home page