Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista Tutorial - how to get logged-in user credentials?

Reply
 
Old 09-02-2007   #1 (permalink)
Hal Rottenberg
Guest


 
 

how to get logged-in user credentials?

9# [System.Net.CredentialCache]:efaultCredentials | fl

UserName :
Password :
Domain :

10# [System.Net.CredentialCache]:efaultNetworkCredentials | fl

UserName :
Password :
Domain :

The above were my best guess so far, but they're blank!

Maybe I'm trying too hard; env:USERNAME and env:USERDOMAIN will get me
two-thirds of the way there.

--

Hal Rottenberg
blog: http://halr9000.com
powershell category:
http://halr9000.com/article/category...ng/powershell/

My System SpecsSystem Spec
Old 09-02-2007   #2 (permalink)
Hal Rottenberg
Guest


 
 

Re: how to get logged-in user credentials?

Replying to myself here... I found these useful bits in my profile which PSCX
put there:

Set-PscxVariable NTIdentity ([Security.Principal.WindowsIdentity]::GetCurrent())

Set-PscxVariable NTAccount
($NTIdentity.User.Translate([Security.Principal.NTAccount]))

11# $ntaccount

Value
-----
EL-GUAPO\Hal

--

Hal Rottenberg
blog: http://halr9000.com
powershell category:
http://halr9000.com/article/category...ng/powershell/
My System SpecsSystem Spec
Old 09-03-2007   #3 (permalink)
IT Staff
Guest


 
 

Re: how to get logged-in user credentials?


[Security.Principal.WindowsIdentity]::getcurrent().name



"Hal Rottenberg" <hal@xxxxxx> wrote in message
news:%23jqEmnd7HHA.4584@xxxxxx
Quote:

> Replying to myself here... I found these useful bits in my profile which
> PSCX put there:
>
> Set-PscxVariable NTIdentity
> ([Security.Principal.WindowsIdentity]::GetCurrent())
>
> Set-PscxVariable NTAccount
> ($NTIdentity.User.Translate([Security.Principal.NTAccount]))
>
> 11# $ntaccount
>
> Value
> -----
> EL-GUAPO\Hal
>
> --
>
> Hal Rottenberg
> blog: http://halr9000.com
> powershell category:
> http://halr9000.com/article/category...ng/powershell/

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Re: Cannot use ie7 when logged on as a standard user?? Vista security
Different user credentials Vista networking & sharing
User Profile Bad if this user is not first user logged onto Vista Vista account administration
Remember last user logged on Vista account administration
finding the logged on user (user name) with powershell using WMI? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46