<# .SINOPSIS Generate credentials for service accounts. .DESCRIPTION Uses a login name list to generate a password for each login and export credentials to csv file, that can be imported into Keepass. Author: Antonio Sotelo Email: .EXAMPLE loginnames.txt contains login names for the service accounts, the script generate a password for each login name and export credentials to csv file. .\Create-CSVFile -loginsFile "c:\loginnames.txt" -csvFile "c:\SvcAccounts.csv" -verbose .LINKS References: How to export data to CSV in PowerShell? http://stackoverflow.com/questions/21047185/how-to-export-data-to-csv-in-powershell Generate a random and complex passwords https://gallery.technet.microsoft.com/scriptcenter/Generate-a-random-and-5c879ed5 .NOTES Use KeePass 2.28 to import csv file using Generic CSV Importer. Then you can export from it and import to Keepass 1.28 #> [CmdletBinding()] Param ( [Parameter(Mandatory=$false)] [string]$csvFile = "c:\SvcAccounts.csv", [string]$loginsFile = "loginnames.txt" ) #Load password generator function . .\New-SWRandomPassword.ps1 $Accounts = Get-Content $loginsFile $results = @() Write-Verbose "Generating passwords for each user in the list." foreach ($Account in $Accounts) { Write-Verbose "Generating password for $Account" $Password = New-SWRandomPassword -MinPasswordLength 16 -MaxPasswordLength 16 $Credentials = @{ 'Login Name' = $Account Password = $Password } $results += New-Object PSObject -Property $Credentials } Write-Verbose "Finished generating passwords, exporting credentials to $csvFile file." $results | export-csv -Path $csvFile -NoTypeInformation
Thursday, March 26, 2015
Automate generation of credentials for service accounts
Labels:
Active Directory,
Passwords,
PowerShell,
Service Account
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment