Thursday, May 12, 2016

PowerShell cmdlet of the Day : Test-Path

 

Believe me or not! you are going to use this cmdlet in almost all of your scripts.

By using Test-Path cmdlets, we can find if specific file / folder exists or now. If the file/folder does exists then the output is True, and if they don't then the output is False.

The basic usage of the cmdlet is simple, type the Test-Path cmdlet and in -Path parameter provide the name of file/folder which you want to test.

Test-Path -Path C:\temp\ad.txt

444

In above screenshot, the folder and file both exists, so the output of command in True.

555

In the above screenshot, neither the folder and file exists, so the output of command is false.

Cool! no :)

With Regards.
Aman Dhally
If you like, you can follow me on Twitter and Facebook. You can also check my “You Tube channel
for PowerShell video tutorials. You can download all of my scripts from “Microsoft
TechNet Gallery”.

 

No comments:

Post a Comment