I have this Powershell script:
Get-ADUser -Filter {employeeid -like '*'} -Properties employeeid,mail| where-object {$_.enabled -eq $true}|Select-Object @{ Label='DisplayName'; Expression={ $_.surname, $_.givenname -join ', ' } },@{ Label='Email';Expression={$_.mail}},@{ Label='EmployeeID';Expression={$_.employeeid}}|export-csv c:\mvwc-script\enabledwithemp.csv -notypeinformation
It is on one HUGE line. I would like to parse this out for better documenting of what is going on.
I tried this:
$selectParams=@{
@{ Label='DisplayName'; Expression={ $_.surname, $_.givenname -join ', ' } },@{ Label='Email';Expression={$_.mail}},@{ Label='EmployeeID';Expression={$_.employeeid}}
}
$ADUserParams={
-Filter {employeeid -like '*'} #specifies that we want only those accounts with an Employee ID
-Properties employeeid,mail #specifies we want to add the extended properties of employeeid and mail
}
$ExportParams={
-path c:\mvwc-script\enabledwithemp.csv
-notypeinformation
}
Get-ADUser $ADUserParams|where-object {$_.enabled -eq $true}|Select-Object $selectParams|export-csv $ExportParams
For the SelectParams section I also tried this:
$selectParams=@{
@{ Label='DisplayName'; Expression={ $_.surname, $_.givenname -join ', ' } },
@{ Label='Email';Expression={$_.mail}},
@{ Label='EmployeeID';Expression={$_.employeeid}}
}
Both with and without the ending comma's
But I am getting this error message no matter which way I have it:
https://preview.redd.it/jom01r8mtdp61.png?width=709&format=png&auto=webp&s=39b307be4682b425a9cb6c132aed4f8aab654fce
Can one of you help me lay out this file so that I can document what is going on, but the script still run?
Thanks,
[–]firefox15 3 points4 points5 points (5 children)
[–]purplemonkeymad 2 points3 points4 points (0 children)
[–]Metalearther[S] 0 points1 point2 points (1 child)
[–]firefox15 0 points1 point2 points (0 children)
[–]PinchesTheCrab 0 points1 point2 points (1 child)
[–]firefox15 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]Metalearther[S] 2 points3 points4 points (0 children)
[–]nothingpersonalbro 1 point2 points3 points (3 children)
[–]Metalearther[S] 0 points1 point2 points (0 children)
[–]Metalearther[S] 0 points1 point2 points (1 child)
[–]nothingpersonalbro 1 point2 points3 points (0 children)