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 (38 loc) · 1.3 KB
/
New-Password.ps1
File metadata and controls
47 lines (38 loc) · 1.3 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 -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
} #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
# New-Password PowerShell
# 'applepies','PSMaster','skldjgb23' | new-password -verbose
# New-Password 'password' | New-Password
# New-RandomFilename | New-Password