【发布时间】:2014-03-13 15:01:09
【问题描述】:
我创建了一个随机密码生成器,我需要将所有 10 个输出输出到一个 .txt 文件中
但我现在只有 1 行输出。
for ($i=1; $i -le 10; $i++){
$caps = [char[]] "ABCDEFGHJKMNPQRSTUVWXY"
$lows = [char[]] "abcdefghjkmnpqrstuvwxy"
$nums = [char[]] "2346789"
$spl = [char[]] "!@#$%^&*?+"
$first = $lows | Get-Random -count 1;
$second = $caps | Get-Random -count 1;
$third = $nums | Get-Random -count 1;
$forth = $lows | Get-Random -count 1;
$fifth = $spl | Get-Random -count 1;
$sixth = $caps | Get-Random -count 1;
$pwd = [string](@($first) + @($second) + @($third) + @($forth) + @($fifth) + @($sixth))
Write-Host $pwd
Out-File .\Documents\L8_userpasswords.txt -InputObject $pwd
}
当我打开 .txt 时,我只看到输出的 1 行而不是 10 行。
【问题讨论】: