Submitted By: Kent Finkle
Uses Windows PowerShell to verify that a folder exists.
# Script name: ExistsDir.ps1 # Created on: 2006-09-18 # Author: Kent Finkle # Purpose: Verify Whether or Not a Directory Exists with PowerShell. function Exists-Dir($path) { if ([IO.Directory]::Exists($path)) { return $true; } else { return $false; } } $path = "c:\scripts\" if (Exists-Dir($path)) { $msg = [string]::concat($path, " exists"); } else { $msg = [string]::concat($path, " does not exist"); } [Console]::WriteLine($msg); $path = "c:\scripts2\" if (Exists-Dir($path)) { $msg = [string]::concat($path, " exists"); } else { $msg = [string]::concat($path, " does not exist"); } [Console]::WriteLine($msg);
# Script name: ExistsDir.ps1 # Created on: 2006-09-18 # Author: Kent Finkle # Purpose: Verify Whether or Not a Directory Exists with PowerShell. function Exists-Dir($path) { if ([IO.Directory]::Exists($path)) { return $true; } else { return $false; } } $path = "c:\scripts\" if (Exists-Dir($path)) { $msg = [string]::concat($path, " exists"); } else { $msg = [string]::concat($path, " does not exist"); } [Console]::WriteLine($msg); $path = "c:\scripts2\" if (Exists-Dir($path)) { $msg = [string]::concat($path, " exists"); } else { $msg = [string]::concat($path, " does not exist"); } [Console]::WriteLine($msg);