Generate the results in Yellow

  • Is there anyway, I can format the string to generate the results in Yellow/any other color? Please suggest.

    Function GET-Temppassword() {

    Param(

    [int]$length=10,

    [string[]]$sourcedata

    )

    #$alphabet="YYETHOGD5546*&6%$3#@%L";

    $ascii=$NULL;For ($a=33;$a –le 126;$a++) {$ascii+=,[char][byte]$a }

    For ($loop=1; $loop –le $length; $loop++) {

    $TempPassword+=($sourcedata | GET-RANDOM)

    }

    return $TempPassword

    }

    #GET-Temppassword –length 19 –sourcedata $alphabet #SEEAUBPYWBTCEFDICFZ

    write-host "Your Random Generated Password Is below: `n `r" -ForegroundColor Green

    GET-Temppassword –length 19 –sourcedata $ascii

    write-host "`n `r"

    Thanks.

  • I have managed to fix this.

    Thanks.

  • SQL-DBA-01 (3/27/2015)


    I have managed to fix this.

    Please share what you did. Thanks.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (3/27/2015)


    SQL-DBA-01 (3/27/2015)


    I have managed to fix this.

    Please share what you did. Thanks.

    Yes please SQL-DBA-01. Help others please 🙂

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • Sure Guys, I will reply tomorrow. My scripts are there in my other laptop.

    Thanks.

  • Hi Jeff

    I used the generate password code accordingly:

    clear-host

    Function GET-Temppassword1() {

    Param(

    [int]$length=10,

    [string[]]$sourcedata

    )

    #$alphabet="YYETHOGD5546*&6%$3#@%L";

    $ascii=$NULL;For ($a=33;$a –le 126;$a++) {$ascii+=,[char][byte]$a }

    For ($loop=1; $loop –le $length; $loop++) {

    $TempPassword+=($sourcedata | GET-RANDOM)

    }

    return $TempPassword

    }

    #GET-Temppassword –length 19 –sourcedata $alphabet #SEEAUBPYWBTCEFDICFZ

    write-host "Your Random Generated Password Is below: `n `r" -ForegroundColor GRAY

    $password1 = (GET-Temppassword1 –length 19 –sourcedata $ascii )

    $password2 = (GET-Temppassword1 –length 19 –sourcedata $ascii )

    $password3 = (GET-Temppassword1 –length 19 –sourcedata $ascii )

    write-host "`n `rPASSWORD1: `r"

    write-host $password1 -ForegroundColor YELLOW

    write-host "`n `rPASSWORD2: `r"

    write-host $password2 -ForegroundColor GREEN

    write-host "`n `rPASSWORD3: `r"

    write-host $password3 -ForegroundColor CYAN

    Thanks.

  • Thanks.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Nice one SQL-DBA-01.

    Have you thought of using:

    Write-Error

    Write-Warning

    Write-Verbose

    Write-Debug

    Write-Progress

    They can really help developing and using scripts. Also aids the self documenting aspect of it i.e. when appropriate why add a comment when you can add verbose description instead.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply