PowerTip: Use PowerShell to Show Screensaver Info for Logged-on User

PowerTip: Use PowerShell to Show Screensaver Info for Logged-on User

  • Comments 5
  • Likes

Summary: Use Windows PowerShell to show screensaver info for a user who is logged on.

Hey, Scripting Guy! Question How can I easily use Windows PowerShell to show screensaver information for the currently logged-on interactive user?

Hey, Scripting Guy! Answer Use WMI to query the Win32_Desktop class, and filter on the logged-on user’s name:

Get-Wmiobject win32_desktop | where name -match $env:USERNAME

 

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • <p>Forgive me if I am wrong, but shouldn&#39;t that read:</p> <p>Get-Wmiobject win32_desktop | where {$_.name -match $env:USERNAME}</p>

  • <p>@Matt your syntax is PowerShell V2 syntax, mine was V3. Thank you for pointing this out.</p>

  • <p>After reading the comments from matt and ed wilson, my queries are cleared. I got an error when I executed it from powershell 2. Hey Ed, can you change the title so that everybody knows directly after reading it?</p> <p>Chaitanya.</p>

  • <p>Here - this works in both versions and is more efficient in a large terminal server environment.</p>

  • <p>Sorry - my paste didn&#39;t paste:</p> <p>Get-Wmiobject win32_desktop -filter &quot;name like &#39;%$env:USERNAME&#39;&quot;</p>