Good. But drops to .NET ☺ I was avoiding that…
From: [email protected] [mailto:[email protected]] On Behalf Of Brian Desmond Sent: Thursday, October 12, 2017 7:53 PM To: [email protected] Subject: [NTSysADM] RE: PowerShell brainfart This works too gwmi Win32_UserProfile | where { $_.Sid -eq [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value } Thanks, Brian Desmond w – 312.625.1438 | c – 312.731.3132 From: [email protected]<mailto:[email protected]> [mailto:[email protected]] On Behalf Of Michael B. Smith Sent: Thursday, October 12, 2017 5:55 PM To: [email protected]<mailto:[email protected]> Subject: [NTSysADM] RE: PowerShell brainfart One liner: Get-CimInstance Win32_UserProfile |? { $_.SID -eq ( Get-CimInstance Win32_UserAccount |? { $_.Caption -eq ( Get-CimInstance Win32_ComputerSystem ).UserName } ).SID } From: [email protected]<mailto:[email protected]> [mailto:[email protected]] On Behalf Of James Rankin Sent: Thursday, October 12, 2017 4:24 PM To: [email protected]<mailto:[email protected]> Subject: [NTSysADM] RE: PowerShell brainfart Thankyou sir, that appears to work well indeed A kick in the right direction would have sufficed, but that’s sorted me nicely 😊 From: [email protected]<mailto:[email protected]> [mailto:[email protected]] On Behalf Of Michael B. Smith Sent: 12 October 2017 21:10 To: [email protected]<mailto:[email protected]> Subject: [NTSysADM] RE: PowerShell brainfart This isn’t the fastest (using .NET would be), but it’s easy to understand: $username = ( gwmi win32_computersystem ).username.ToString() $sid = ( gwmi win32_useraccount |? { $_.Caption -eq $username } ).SID gwmi win32_userprofile |? { $_.SID -eq $sid } From: [email protected]<mailto:[email protected]> [mailto:[email protected]] On Behalf Of James Rankin Sent: Thursday, October 12, 2017 3:45 PM To: [email protected]<mailto:[email protected]> Subject: [NTSysADM] PowerShell brainfart OK, I’m having a ditzy moment I’m trying to query profile type in PowerShell using gwmi Specifically gwmi win32_userprofile | select localpath, status But this returns all users on the machine – how can I make it return just the current user? I’m having a severe blonde moment – help! (Apologies to all blondes on the list) Cheers, [cid:[email protected]] [cid:[email protected]] [cid:[email protected]] James Rankin CTA ACA vExpert Technical Evangelist / Media Hound Howell Technology Group Office: 0191 4813446 Mobile: 07809 668579 Email: [email protected]<mailto:[email protected]> www.htguk.com<http://www.htguk.com/> | Twitter<https://twitter.com/htguk> | Linkedin<https://www.linkedin.com/in/markhtg> | Facebook<https://www.facebook.com/HTGUK> COMPANY INFORMATION Howell Technology Group Ltd is a limited company registered in England with registered number 5520670 and VAT registered number GB 862 666 004. Our registered office is at 2.30 One Trinity Green, Eldon Street, South Shields, Tyne & Wear, NE33 1SA CONFIDENTIALITY NOTICE This message is intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to us, and immediately and permanently delete it. Do not use, copy or disclose the information contained in this message or in any attachment. PRIVACY POLICY For information about how we process data and monitor communications please see our Privacy Policy. To log a ticket please follow the link. https://htguk.on.spiceworks.com/portal

