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

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


Comments (5)

  1. jrv says:

    Here – this works in both versions and is more efficient in a large terminal server environment.

  2. jrv says:

    Sorry – my paste didn't paste:

    Get-Wmiobject win32_desktop -filter "name like '%$env:USERNAME'"

  3. Matt says:

    Forgive me if I am wrong, but shouldn't that read:

    Get-Wmiobject win32_desktop | where {$_.name -match $env:USERNAME}

  4. Ed Wilson says:

    @Matt your syntax is PowerShell V2 syntax, mine was V3. Thank you for pointing this out.

  5. chaitanya says:

    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?


Skip to main content