Change Get-PWFolders to throw error on missing folder rather than warning

Can you change Get-PWFolders to throw a catchable error rather than just issue a warning?

$pwf = Get-PWFolders -FolderPath "Folder 1\Folder 2"
if ($pwf -eq $null) {
    folder doesn't exist?
    do stuff?
}

try {
    $pwf = Get-PWFolders -FolderPath "Folder 1\Folder 2"
} catch {
    Error definitely occurred
}

I prefer the 2nd coding example as it allows me to catch different error types and seems the more powershell appropriate way

Parents Reply Children
No Data