Export (0) Print
Expand All
Expand Minimize

Converting the FileSystemObject's GetFileName Method


Windows PowerShell


Definition: Given a full path, returns the file portion of the path. For example, passing the path C:\Scripts\Test.txt to GetFileName will return Test.txt.

GetFileName


In PowerShell, use the Split-Path cmdlet with the -leaf parameter:


Split-Path C:\scripts\test.txt -leaf


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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft