Can someone explain why this is evaluating like this? I want to trap the error in case the registry key doesn’t exist, so I’m using the inline pipe operator, but the results are perplexing:
Q: value "fDenyTSConnections" of key "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" of registry
A: 1
I: singular registry key value
Q: (value "fDenyTSConnections" of key "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" of registry as string) = "1"
A: True
I: singular boolean
Q: False
A: False
I: singular boolean
Q: ( (value "fDenyTSConnections" of key "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" of registry as string) = "1" | False )
E: Incompatible types.
Q: ( ((value "fDenyTSConnections" of key "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" of registry as string) = "1") as string | "False" )
A: True
I: singular string
Q: ( ((value "fDenyTSConnections" of key "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" of registry as string) = "1") as string | "False" ) = "True"
A: True
I: singular boolean
So, in order to end up with a boolean, I have to turn a boolean into a string and compare it to the string “True”? Are booleans not allowed as return values in pipe operations? I cannot find the documentation on error trapping to try to verify this on my own.
– John