i know that I can check if a variable exists with
if ($null -eq "aaa"){set-variable -name "aaa"}
Can someone eplain why I never get into any catch block if I try this
try
{
Get-Variable -Name 'aaa'
}
catch [System.Management.Automation.ItemNotFoundException]
{
Set-Variable -Name 'aaa'
}
catch
{
Set-Variable -Name 'aaa'
}