0
votes

trying to array slice the get-psreadlineoption command. I want to select all strings containing the word 'Color' and then input those to 'set-psreadline' to set all colors. I do not understand how this all works in powershell. It's an array, right? I can just loop over it like this:

foreach($a in $i) { $i; if ($i -contains 'MemberColor') {$i;} }

But that gives no output. I also cannot access it as an array:

get-psreadlineoption[21..36] get-psreadlineoption['EditMode']

Does not work. Basically what I want to do is:

foreach (get-psreadlines[21..36]) { $array = append(<string that contains 'Color'>) } foreach ($a in $array) { set-psreadline($a, ...)}

How would I go about doing this?

(P.S. I just want to set all those colors to the same color in a concise manner as possible)

get-psreadlineoption, is a function not a (array) variable. To access the properties returned by the function: (get-psreadlineoption).EditModeiRon
Cool, thanks. So how can I loop over those attributes?Athylus
(get-psreadlineoption).ForEach{ $_ }iRon