Any suggestions? Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize

Converting the FileSystemObject's Name Property


Windows PowerShell


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

Name


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


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


Returns:


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

Show:
© 2016 Microsoft