[DBG]: PS C:\Windows\system32>>> echo [uint32]::maxvalue
[uint32]::maxvalue
and
[DBG]: PS C:\Windows\system32>>> $mv = [uint32]::maxvalue
[DBG]: PS C:\Windows\system32>>> echo $mv
4294967295
I am sure powershell has some perfectly good reason for doing this :-). Is there someway i can tell it not to do it. I am actually passing and int to a function and sometimes I want to pass maxvalue
I know I can do
$mv = [uint32]::maxvalue
MyFunc $mv
I am wondering if there is something like
MyFunc ([uint32]::maxvalue)
MyFunc `[uint32::maxvalue`
etc
The reason why is that the
echocommand is interpreting the argument as astringand not an arbitrary value. Hence in the first example it’s printing out the argument literally vs. interpreting it as a value. In the second case though it’s being interpreted as an expression and being assigned to a value.You can reproduce this behavior by creating a function yourself that echos the output to the console.
You can also force the
echofunction to interpret it as a value by using()s to specify it’s an expression