?
Solved

POwershell - How to pull the screen saver time out value

Posted on 2013-11-04
9
Medium Priority
?
1,958 Views
Last Modified: 2013-11-15
Hi EE

I am trying to pull from multiple machines what the value is set for the screen saver .
I am testing with the line below on one machine only and its not showing the correct seconds .. The screen saver is set via policy for 15 mins and when I run the line below
it shows the ScreenSaverTimeout to 600 seconds .. I was thinking I should see 900 seconds .. any idea why ?

Get-WmiObject -ComputerName (get-content c:\temp\wks.txt) Win32_Desktop
0
Comment
Question by:MilesLogan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 15

Expert Comment

by:Giovanni Heward
ID: 39622171
Here's a script you can use.

GetSetScreenSaverTimeOut.ps1

Param([switch]$debug, $value = 120)
Function Get-RegistryValue([ref]$in)
{
 Write-Debug $MyInvocation.MyCommand.name
 $in.value = (Get-ItemProperty -path $path -name $name).$name
} #end Get-RegistryValue

Function Set-RegistryValue($value)
{
 Write-Debug $MyInvocation.MyCommand.name
 Set-ItemProperty -Path $path -name $name -value $value
} #end Get-RegistryValue

Function Write-Feedback($in)
{
 Write-Debug $MyInvocation.MyCommand.name
 "The $name is set to $($in)"
} #end Write-Feedback

# *** Entry Point ***
if($debug) { $DebugPreference = "continue" }
$path = 'HKCU:\Control Panel\Desktop'
$name = 'ScreenSaveTimeOut'
$in = $null

Get-RegistryValue([ref]$in)
Write-Feedback($in)
Set-RegistryValue($value)
Get-RegistryValue([ref]$in)
Write-Feedback($in)

Open in new window


If the script is run with the –debug switch, the Write-Debug cmdlet will display additional information on the screen.
0
 
LVL 2

Author Comment

by:MilesLogan
ID: 39622181
Hi x66_x72_x65_x65 ..  where do I enter the machine(s) to check ?
0
 
LVL 15

Expert Comment

by:Giovanni Heward
ID: 39622190
As written, the script is designed to run locally.  You can deploy it via GPO.
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 39622198
Try..
GC c:\temp\wks.txt | %{
$Computer = $_
	If (Test-Connection $Computer -Quiet){
		Try {
		Get-WmiObject -ComputerName $Computer Win32_Desktop -EA STOP | Select @{N="Computer";e={$Computer}},Name,ScreenSaverActive,ScreenSaverTimeout
		}
		Catch{
		$_.Exception.Message | Select @{N="Computer";e={$Computer}},@{N="Name";e={$_}},ScreenSaverActive,ScreenSaverTimeout
		}
	}
	Else{
	"" | Select @{N="Computer";e={$Computer}},@{N="Name";e={"Computer not reachable"}},ScreenSaverActive,ScreenSaverTimeout
	}
} | Select Computer,Name,ScreenSaverActive,ScreenSaverTimeout | Export-Csv c:\temp\Wksreport.csv -NTI

Open in new window

I am getting the correct results.. Did you check the computer and see if the values set is same as in the result?
0
 
LVL 2

Author Comment

by:MilesLogan
ID: 39622254
Hi subsun .. this is exactly what I was looking for but .. the Wksreport.csv report is showing
600 for the ScreenSaverTimeout .. I am logged in to that test machine and the screen saver is set to 15 min by the policy assigned to the AD group that the machine object is a member of .. why would I not see 900 in the report ?
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39622283
Are you seeing it for the same user which GPO is applied? Is it reporting wring time for all computers?
0
 
LVL 2

Author Comment

by:MilesLogan
ID: 39622555
Hi Subsun ..  the GPO is working correct .. I logged in to a machine and see the correct time ( 15 mins ) but the report shows 10 mins .
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39623822
I will test and let you know as soon as I can..
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39651195
Today I got some time to test this.. If you are getting incorrect information with WMI. then probably the correct information is coming from registry..

HKEY_CURRENT_USER\Control Panel\Desktop\ScreenSaveTimeOut

You can access the CURRENT_USER  key from remote computer but problem is it will give you the registry key values for the specific user which you use to run the script..

You can use the following code against any of the computer and see if you get the correct result..

$Server = "ServerA" 
$objReg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('currentuser',$Server)
$objRegKey= $objReg.OpenSubKey("Control Panel\Desktop")
$objRegKey.GetValue("ScreenSaveTimeOut")

Open in new window

0

Featured Post

Four New Appliances. Same Industry-leading Speeds.

But don't take it from us.  The Firebox M370 is Miercom tested and Miercom approved, outperforming its competitors for stateless and stateful traffic throughput scenarios.  Learn more about the M370, M470, M570 and M670 and find the right solution for your organization today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question