forked from jdhitsolutions/PSScriptTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNew-Password.ps1
More file actions
47 lines (39 loc) · 1.34 KB
/
New-Password.ps1
File metadata and controls
47 lines (39 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#requires -version 5.1
#requires -module PSScriptTools
Function New-Password {
[cmdletbinding()]
Param(
[Parameter(Position = 0, Mandatory, ValueFromPipeline, HelpMessage = "Enter a 8+ character string to 'seed' the password.")]
[ValidateNotNullOrEmpty()]
[ValidateScript( { $_.length -ge 8 })]
[string]$SeedText
)
Begin {
Write-Detail "Starting $($myinvocation.mycommand)" -Prefix begin | Write-Verbose
$hash = @{
a = "@"
q = "$"
e = "3"
i = "!"
j = ";"
g = "}"
o = "*"
k = "<"
c = "<"
}
#define a temp file to store results
$tmpfile = New-RandomFileName -UseTempFolder -Extension log
} #begin
Process {
Write-Detail "Using seed '$SeedText'" | Write-Verbose
Format-String $SeedText -Randomize -Replace $hash -Case Alternate | Tee-Object -FilePath $tmpfile -Append
} #process
End {
Write-Detail "See $tmpfile for results." -Prefix end | Write-Verbose
Write-Detail "Ending $($myinvocation.mycommand)" -Prefix end | Write-Verbose
} #end
} #close New-Password
'applepies','PSMaster','skldjgb23' | New-Password -verbose
# New-Password PowerShell
# New-Password 'password' | New-Password
# New-RandomFilename | New-Password