Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, February 14, 2019 11:12 PM
Get-LocalGroupMember administrators | Where-Object {$_.PrincipalSource -eq 'MicrosoftAccount'} | Get-LocalUser
This code fails because I don't know how to trim the computer name from the local user account name. Can someone show me?
It's trying to send "computername\username".....Get-LocalUser wants the username.
adam
All replies (3)
Thursday, February 14, 2019 11:38 PM ✅Answered | 2 votes
Consider PS as a video game that requires you to learn how to use tokens and how to apply magical incantations. Your job is to find the incantation that converts the token to the secret required to pass.
(Get-LocalGroupMember administrators | Where-Object {$_.PrincipalSource -eq 'MicrosoftAccount'}).Name -split '\\' | select -last 1
\(ツ)_/
Thursday, February 14, 2019 11:44 PM
The longer method is this:
Get-LocalGroupMember administrators |
Where-Object { $_.PrincipalSource -eq 'MicrosoftAccount' } |
ForEach-Object{ Get-LocalUser -SID $_.SID } |
Select-Object name
\(ツ)_/
Thursday, February 14, 2019 11:54 PM
Awesome....makes sense! Thanks so much!
adam