PowerShell/Community-Blog

Update request - How can I determine if a folder exists?

doctordns opened this issue · 4 comments

Request that this post from the older Scripting guys blog be updated and added.

Summary of the update request

Can this snippet be used as a solution? 🤔

"Test script if folder exists"
$path = Read-Host -Prompt 'Please enter a path '
if (Test-Path $path) {
    "Path exists!"
} else {
    "Path doesn't exist."
}

That would indeed be a solution. Works in Windows PowerShell too. I'd rewrite this slightly for the blog:

$Folder = 'C:\Windows'
"Test to see if folder [$Folder]  exists"
if (Test-Path -Path $Folder) {
    "Path exists!"
} else {
    "Path doesn't exist."
}

All you have to do now is to write the article?

can be closed, as the blog post is released.

resolved by #36 - closing this issue.