Converting the FileSystemObject's Name Property

Definition: Gets or sets the name of the specified file or folder.


You can use the Name property to retrieve the name of a file or folder:

$a = Get-Item C:\Scripts\Test.txt



The Name property in PowerShell is read-only. However, setting the FileSystemObject Name property is the same as renaming a file or folder, which is the same as moving a file or folder to the same location but with a new name. This example “renames” C:\temp to C:\temp2:

Move-Item C:\temp C:\temp2

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