I am new to PowerShell from .Net world. I am trying to write some if statement like the blow
#1
if (((Get-Item $pf).Exist))
{
$password = [xml]( Get-Content $pf)
}
#2
if (((Get-Item $pf) | Select-Object Exist))
{
$password = [xml]( Get-Content $pf)
}
#3
$result=(Get-Item $pf).Exist
if($result)
{
$password = [xml]( Get-Content $pf)
}
Questions: Both #2 and #3 will work as expected, however, I am also expecting #1 to work as in .Net, but it seems always evaluate to false, so the statement never get executed. I am a little confused here, can someone explain me why #1 is not working as what I would expect?