Wednesday, December 28, 2016

PowerShell v2 v3 Testing to see if a Folder or File Exists

,
These are mainly for me to jot down as reminders for myself. If I want to determine if file system object is a file (leaf) or folder (directory) I can use these two tests:

  1. Test folder: Test-Path -PathC: est -PathTypeContainer
  2. Test file: Test-Path -PathC: est -PathType Leaf 
$False, in these cases, can indicate two things:
  1. The item does not exist
  2. The item is not the PathType indicated
Be sure you know which you are testing for.

0 comments to “PowerShell v2 v3 Testing to see if a Folder or File Exists”

Post a Comment

 

Computer Info Copyright © 2016 -- Powered by Blogger