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

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?
LVL 1
Anonymous KHIT EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
$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

MaheshArchitectCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Anonymous KHIT EngineerAuthor 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.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

MaheshArchitectCommented:
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 SpecialistCommented:
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 EngineerAuthor Commented:
Hi! Shaun,

Any other areas I can investigate into why the client's PC has this error message?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.