How to access a property from an object using a variable name?

后端 未结 1 570
遥遥无期
遥遥无期 2021-01-18 16:45

This works:

$psISE.Options.DebugBackgroundColor = \'#FFC86400\'

This doesn\'t:

$attribute = \'DebugBackgroundColor\' 
($psI         


        
相关标签:
1条回答
  • 2021-01-18 17:08

    Just use double quotes after the dot:

    $attribute = 'DebugBackgroundColor'
    $psISE.Options."$attribute"
    
    0 讨论(0)
提交回复
热议问题