$filepath = "C:\Scripts\Logs"
$date = Get-Date -Format "dd.MM.yyyy HH:mm:ss"
$tapejob = Get-VBRTapeJob -Name "GFS Backup to Tape"
$tapejob | Disable-VBRJob
$status = Get-VBRTapeJob -Name "GFS Backup to Tape"
if ($status.Enabled -eq "False")
{"$date Der Backup To Tape Job wurde erfolgreich deaktiviert." | Out-File "$filepath\DisableTapeJobLog.txt" -Append}
elseif ($status.Enabled -eq "True")
{"$date Der Backup To Tape Job wurde nicht erfolgreich deaktiviert." | Out-File "$filepath\DisableTapeJobLog.txt" -Append}
else
{"$date Irgendwas stimmt hier nicht. :-)" | Out-File "$filepath\DisableTapeJobLog.txt" -Append}
Everything is working fine, the if-statement excluded. It doesn't matter which value the variable $status results. The if-statement results always in the else condition.
Is it quite possible to work with the properties of a Cmdlet result in an if-statement?
It is possible. However wrapping True/False values in double quotes in your if/else flow makes them strings, not booleans.
And by default powershell doesn't do type conversion unless you instruct it. So you need to present True/False as actual booleans preppending a $ sign instead of using double quotes to make it work: