How do I list the results of AD Computers SID and export them into Excel in various columns?

Anonymous KH
Anonymous KH used Ask the Experts™
on
Dear Experts,

I have quite a nuber of times users having this error message when thry try to login to their computers

"Group Policy Client Service failed to sign in"

I suspect that their computers were cloned using the same SID.

I am able to use PowerShell to display the SID of the UserAccount,

Get-WmiObject -class Win32_UserAccount | Format-Table AccountType, Caption, Domain, SID, FullName, Name -AutoSize

I tried to export them using

Get-WmiObject -class Win32_UserAccount | Format-Table AccountType, Caption, Domain, SID, FullName, Name -AutoSize | Export-CSV Computerlist.csv -NoTypeInformation

but I got lost of gibberish in the first left column only

How do the same for the Computer SID and export them into Excel in various columns?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
$localaccountsid = get-WMIObject  -Query "SELECT SID FROM Win32_UserAccount WHERE LocalAccount = 'True'" | Select-Object -First 1 -ExpandProperty SID
$MachineSID      = ($p = $LocalAccountSID -split "-")[0..($p.Length-2)]-join"-"

Open in new window

Architect
Distinguished Expert 2018
Commented:
instead of format table use select method

Format table and csv are two different formats

Get-WmiObject -class Win32_UserAccount | Select AccountType, Caption, Domain, SID, FullName, Name | Export-CSV C:\exports\Computerlist.csv -NoTypeInformation

Open in new window

Anonymous KHIT Engineer

Author

Commented:
Thanks Mahesh,

I have executed your command but instead of using C:\exports\, I just key in computerlist.csv directly, because somehow the powerhell is not able to save it at that path.

Maybe due to permission.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

MaheshArchitect
Distinguished Expert 2018

Commented:
ya, perhaps PS don't get direct permissions to drive root to create files and folder, you may already create folder and then point and ensure PS is started with run as administrator
Shaun VermaakTechnical Specialist
Awarded 2017
Distinguished Expert 2018

Commented:
I am by no means for computers with duplicate SIDs but it will not cause "Group Policy Client Service failed to sign in" error
Anonymous KHIT Engineer

Author

Commented:
Hi! Shaun,

Any other areas I can investigate into why the client's PC has this error message?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial