PowerShell for Windows Admins

Aug 20 2014   7:49AM GMT

Split-Path serendipity

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

I’ve used Split-Path and its associated cmdlet Join-Path a lot when working with file system paths. Something I read today started me asking if it would work with URLs

 

It does:

 

£> Split-Path -Path ‘http://powershell.org/wp/forums/forum/windows-powershell-qa/’ -Leaf
windows-powershell-qa
£> Split-Path -Path ‘http://powershell.org/wp/forums/forum/windows-powershell-qa/’ -Parent
http:\\powershell.org\wp\forums\forum

 

£> Split-Path -Path ‘http://powershell.org/wp/forums/forum/windows-powershell-qa/’ -NoQualifier
//powershell.org/wp/forums/forum/windows-powershell-qa/
£> Split-Path -Path ‘http://powershell.org/wp/forums/forum/windows-powershell-qa/’ -Qualifier
http:

 

The –Resolve parameter won’t work because its not a file system path but if you need to play with URLs then could be useful.

 

Just for completeness Join-Path won’t work with URLs because its attempting to resolve the file path

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: