powershell: how to write-host value from [ref] variable

You would have probably tried:

write-host "the new value is $obj1.value"

and got corresponding output of

the new value is System.Management.Automation.PSReference.value

I think you did not notice the .value in the end of the output.

In strings you have to do something like this while accessing properties:

write-host "the new value is $($obj1.value)"

Or use string format, like this:

write-host ("the new value is {0}" -f $obj1.value)

Or assign value outside like $value = $obj1.value and use in string.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)