Sunday 11 January 2009

Get-Screensaver.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     Determine if a computer screen saver requires a password. 
  4. .DESCRIPTION 
  5.     This script is a re-write of script 2 on the MSDN site (see 
  6.     below for link). This script also displays the user name for 
  7.     each desktop and the screen saver executable. 
  8. .NOTES 
  9.     File Name  : Get-Screensaver.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell V2 CTP3 
  12. .LINK 
  13.     Script published to: 
  14.     http://www.pshscripts.blogspot.com 
  15.     Adapted from MSDN: 
  16.     http://msdn.microsoft.com/en-us/library/aa394591(VS.85).aspx 
  17. .EXAMPLE 
  18.     PS c:\foo> .\Get-Screensaver.ps1 
  19.     5 desktops found as follows 
  20.     Desktop      : NT AUTHORITY\SYSTEM 
  21.     Screen Saver : logon.scr 
  22.     Secure       : False 
  23.  
  24.     Desktop      : NT AUTHORITY\LOCAL SERVICE 
  25.     Screen Saver : %SystemRoot%\System32\logon.scr 
  26.     Secure       : False 
  27.  
  28.     Desktop      : NT AUTHORITY\NETWORK SERVICE 
  29.     Screen Saver : %SystemRoot%\System32\logon.scr 
  30.     Secure       : False 
  31.   Win
  32.     Desktop      : Cookham\tfl 
  33.     Screen Saver : %Systemroot%\tflscreensaver.scr 
  34.     Secure       : False 
  35.  
  36.     Desktop      : .DEFAULT 
  37.     Screen Saver : logon.scr 
  38.     Secure       : False 
  39. #> 
  40.  
  41. ## 
  42. #  Start of script 
  43. ## 
  44.  
  45. $Computer = "." 
  46. $Desktops = Get-WMIObject -class Win32_Desktop -ComputerName $computer 
  47. "{0} desktops found as follows" -f $desktops.count 
  48. foreach ($desktop in $desktops) { 
  49. "Desktop      : {0}"  -f $Desktop.Name 
  50. "Screen Saver : {0}"  -f $desktop.ScreensaverExecutable 
  51. "Secure       : {0} " -f $desktop.ScreenSaverSecure 
  52. "" 

No comments: