March 27, 2015 at 1:12 pm
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.
March 27, 2015 at 1:31 pm
I have managed to fix this.
Thanks.
March 27, 2015 at 3:06 pm
SQL-DBA-01 (3/27/2015)
I have managed to fix this.
Please share what you did. Thanks.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 29, 2015 at 8:57 am
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!!!
March 29, 2015 at 9:10 am
Sure Guys, I will reply tomorrow. My scripts are there in my other laptop.
Thanks.
March 29, 2015 at 7:12 pm
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.
March 29, 2015 at 7:31 pm
Thanks.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 30, 2015 at 3:57 am
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