Rabu, 28 Desember 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.

lamsim

About lamsim

Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.

Subscribe to this Blog via Email :