Private/New-RandomPassword.ps1
|
function New-RandomPassword { ################################################################################ ##### ##### ##### New-RandomPassword ##### ##### ################################################################################ Param([string] $param1, [string] $param2) $CurrentFunction = Get-FunctionName Write-Log -Message "### Start Function $CurrentFunction ###" $StartRunTime = (Get-Date).ToString($Script:DateFormatLog) #################### main code | out- host ##################### $Hozi = "HERRHOZI".ToCharArray() $chars = "abcdefghijkmnopqrstuvwxyzABCEFGHJKLMNPQRSTUVWXYZ1234567890".ToCharArray() $nums = "1234567890".ToCharArray() $schars = "+-$!".ToCharArray() $newPassword = "" 1..9 | ForEach-Object { $newPassword += $chars | Get-Random } 1..1 | ForEach-Object { $newPassword += $nums | Get-Random } 1..1 | ForEach-Object { $newPassword += $schars | Get-Random } 1..1 | ForEach-Object { $newPassword += $nums | Get-Random } 1..1 | ForEach-Object { $newPassword += $schars | Get-Random } 1..1 | ForEach-Object { $newPassword += $Hozi | Get-Random } Write-Log -Message " >> New Password: $newPassword" ######################## main code ############################ $runtime = Get-RunTime -StartRunTime $StartRunTime Write-Log -Message " Run Time: $runtime [h] ###" Write-Log -Message "### End Function $CurrentFunction ###" return $newPassword } |