Im very new to powershell and learning on the fly. I need to create a simple (or I thought) script to grab a CSV file from a URI. I need to export it to a CSV while also adding two new columns that uses information already in the CSV. This is what I have so far, and I'm sure its mostly wrong but I'm trying.
Invoke-RestMethod -uri https://gist.githubusercontent.com/cdituri/6bb69329f50efb7b79f7e5a2bf31597d/raw/77e918ed2384195ea137587acc69e6acfe376d15/users.csv |Select-Object FirstName,LastName,UPN,Password |
ForEach-Object {$UPN = $Firstname + "." + $Lastname + "@domain.com"} |
ForEach-Object {$password = function Get-RandomCharacters($length, $characters) {
$random = 1..$length | ForEach-Object { Get-Random -Maximum $characters.length }
$private:ofs=""
return [String]$characters[$random]
}
function Scramble-String([string]$inputString){
$characterArray = $inputString.ToCharArray()
$scrambledStringArray = $characterArray | Get-Random -Count $characterArray.Length
$outputString = -join $scrambledStringArray
return $outputString
} }
$password = Get-RandomCharacters -length 5 -characters 'abcdefghiklmnoprstuvwxyz'
$password += Get-RandomCharacters -length 1 -characters 'ABCDEFGHKLMNOPRSTUVWXYZ'
$password += Get-RandomCharacters -length 1 -characters '1234567890'
$password += Get-RandomCharacters -length 1 -characters '!"§$%&/()=?}][{@#*+'
Write-Host $password
$password = Scramble-String $password
Write-Host $password
Select-Object UPN,password |
Export-Csv -path C:\Output.csv
Any help would be very much appreciated.