
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between Test-Path and Resolve-Path in PowerShell
Test-Path command checks if the particular path exists or not and returns the Boolean output (True or False) while Resolve-Path command displays the particular directory if exists otherwise throws an exception. For example,
For the path to exist,
Example
PS C:\> Test-Path C:\Temp\ True PS C:\> Resolve-Path C:\Temp\ Path ---- C:\Temp\
For the path doesn’t exist,
PS C:\> Test-Path C:\Temp11\ False PS C:\> Resolve-Path C:\Temp11\ Resolve-Path : Cannot find path 'C:\Temp11\' because it does not exist. At line:1 char:1 + Resolve-Path C:\Temp11\ + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Temp11\:String) [Resolve-Path], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.ResolvePathCommand
Resolve-Path is also used to get the file content using the wildcard character. For example,
Example
Resolve-Path C:\Temp\*
The above command will get all the files and folders inside the C:\temp path.
Resolve-Path C:\Temp\web*
The above command will get all the files from the C:\temp with the Web starting keyword.
Output
Path ---- C:\Temp\WebImages C:\Temp\web.html C:\Temp\web1.html
Advertisements