I'm very new to Powershell ISE and I'm not sure how to go about doing this.
I want to take strings (uxxxx axxxx name email) and have it return as a table with username, admin, and name (want to eventually automate emails). My code is currently like this:
$users = Get-Content ".\FileName.txt"
$line = "Username, Admin, Name, Email"
$parts = $line.Split(" ")
$Test = Foreach ($user in $users) {
Select-Object Username, Admin, Name
}
$Test | Sort-Object -Property Name | Out-GridView
This is just a watered down version of the code since it will be going through domains and authentication processes, but I was hoping someone could just help me get the table to work for now.
$linesuggests a comma separated values (CSV) so maybe you could useImport-Csvon the data instead ofGet-Content? You split$lineon spaces, which will leave the commas in$partswhich seems unhelpful - except you don't use$partsso nevermind I guess. Yourselect-objecthas no data being pipelined into it, which it would need, but you can't use select-object like that on lines coming from fromGet-Content. you can use Select-Object on the output of Import-Csv so if it's possible to use that, do.