This works:
$psISE.Options.DebugBackgroundColor = '#FFC86400'
This doesn't:
$attribute = 'DebugBackgroundColor'
($psISE.Options)[$attribute] = '#FFC86400'
ERROR: Unable to index into an object of type Microsoft.PowerShell.Host.ISE.ISEOptions
I want to set option attributes in a foreach
loop using the $attribute
variable.
Is there a way to do this?
Just use double quotes after the dot:
$attribute = 'DebugBackgroundColor'
$psISE.Options."$attribute"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.