Desktop of current logged on user
Posted by: Richard Siddaway
In this post http://itknowledgeexchange.techtarget.com/powershell/current-logged-on-user/ we discovered how to find the current logged on user. I want to extend that a bit and add the information about that users desktop.
We start with the script in our earlier post.
|
001
002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 |
## get session process
$proc = Get-WmiObject -Class Win32_SessionProcess | select Antecedent -First 1 $filt = ($proc -split "=")[2] -replace ‘"’,” -replace "}","" $ltype = DATA { ## get user $query2 = "ASSOCIATORS OF {Win32_UserAccount.Domain=’$($user.Domain)’" ` $desktop = Get-WmiObject -Query $query2 |
We add a query to get the desktop associated with the current user – - $query2
That query returns the information about the desktop. Its displayed after the user information and I’ve selected the items I want to display.
This is a good example of extending an existing script when you find out how to do a bit more digging.
I think we’ve about exhausted the WMI information on users and groups for now – so its time to find another topic.




