Good Morning,
I'm trying to format the output from the below PowerShell script into a table so it can be imported into an excel spreadsheet.
Get-ADGroupMember -Identity "GroupA" | ForEach-Object {
Get-ADUser -Identity $_.SamAccountName -Properties EmailAddress, LastLogonDate, Created |
Select-Object -Property Name, GivenName, Surname, UserPrincipalName, EmailAddress, Enabled, LastLogonDate, Created | Format-Table } > C:\Temp\GroupA.txt
But I can't get the formatting right. When I run the about script it comes out like:
Name GivenName Surname UserPrincipalName EmailAddress Enabled LastLogonDate Created
---- --------- ------- ----------------- ------------ ------- ------------- -------
Person A Person A Person.A@mathieu.company .co.uk PersonB@mathieu.company .co.uk True 11/03/2021 13:55:55 02/02/2021 09:43:25
Name GivenName Surname UserPrincipalName EmailAddress Enabled LastLogonDate Created
---- --------- ------- ----------------- ------------ ------- ------------- -------
Person B Person B Person.B@mathieu.company .co.uk PersonB@mathieu.company .co.uk True 11/03/2021 11:42:14 04/12/2020 14:53:45
I have added the -HideTableHeaders but i still get all the blank spaces and excel doesn't recognise the columns
Please help!!