English 中文(简体)
更新已经撰写的法典,我需要帮助每3个变量。
原标题:updating code already written, I need help for triple loops ForEach-Object to varie 3 variables

PowerShell

Link to original code text

我的法典如下:

FUNCTION NEW-ANSIBAR-16M
{
    [cmdletbinding()]
    PARAM (
            [PARAMETER(Mandatory, HelpMessage = "Enter a range of 16M color values, e.g. (1..255)")]
            [VALIDATENOTNULLOREMPTY()]
            [int[]]
            $RANGE_R,
            [int[]]
            $RANGE_G,
            [int[]]
            $RANGE_B,
            [Parameter(HelpMessage = "How many spaces do you want in the bar? This will increase the length of the bar.")]
            [int]
            $Spacing = 1
    )
    $ESC = "$([CHAR]0X1b)"
    $OUT = @()
    $BLANK = " " * $Spacing
    $out += $RANGE_R | ForEach-Object {         # ◄--- I need to include $Range_G and $Range_B.
        "$esc[48;2;$($_);$($_);$($_);1m$($blank)$esc[0m" 

        # now it s in shades of gray because it s still the same variable for the other 2 values ?

    }
    $OUT -JOIN ""
    
}

**NEW-ANSIBAR-16M -RANGE_R (1..255) -RANGE_G (100..150) -RANGE_B (100..150) -Spacing 1** 

Should I try iteratively ? Or is there another way to do it ?

我与其他人ForEach-Object进行了审判,但犯了错误。

Thank you very much ! I need this result bot brown degraded and return to normal.

“I

问题回答




相关问题
Mutually exclusive powershell parameters

SCENARIO I m writing a cmdlet for Powershell 2.0 using Visual Studio 2008 and .NET 3.5 the cmdlet requires 3 arguments. my intended grammar of the cmdlet is something like this: cmdletname [foo|...

Run a program from PowerShell with timeout

I ll write a script that runs a program and wait for it finished. But if the program is not finished within a specified time I want that the program is killed.

How to transpose data in powershell

I have a file that looks like this: a,1 b,2 c,3 a,4 b,5 c,6 (...repeat 1,000s of lines) How can I transpose it into this? a,b,c 1,2,3 4,5,6 Thanks

Powershell v2 remoting and delegation

I have installed Powershell V2 on 2 machines and run Enable-PsRemoting on both of them. Both machines are Win 2003 R2 and are joined to the same active directory domain and I can successfully run ...

PowerShell -match operator and multiple groups

I have the following log entry that I am processing in PowerShell I m trying to extract all the activity names and durations using the -match operator but I am only getting one match group back. I m ...

热门标签