SOLVED

Unable to change screensaver active to 0 via powershell - intune

Bronze Contributor

Hi all,

I have used this locally on a device which works :

$RegistryPath = "HKCU:\Control Panel\Desktop"

$RegistryName = "screensaveactive"

$NewValue = "0"

Set-ItemProperty -Path $RegistryPath -Name $RegistryName -Value $NewValue

However when I run this via intune even tho the script succeeds it doesnt change to 0?

Where am I going wrong? How do I get it to work?

18 Replies
Hi,

Would I run this as user?
Yes, it's HKCU (Current User)
This still doesnt work, any ideas?
Please elaborate. Are the values there after deploying the script? Using Win32 or the Scripts pane?

The value doesnt change from 1 to 0 for savescreenactive

I use script to do it not win32 - even though the script succeeds the value doesnt change

 

I did get a response here : https://learn.microsoft.com/en-us/answers/questions/1327706/unable-to-change-screensaver-active-to-0... which did indicate I needed to change HKCU to HKU but that didnt work / failed on deployment. 

 

As a user, I tested it again in a powershell prompt, and it works fine... You do run the script as a user, right?
Yes running as user, works if I do it locally on the machine but if I upload the script via the script blade on intune and have run as user on and other 2 options as off no luck
Could you try a start-transcript c:\programdata\log.txt before the script and a stop-transcript after (First and last line). What does the log say?
I have set this to deploy as so:

start-transcript c:\programdata\log.txt
Write-Host "Disabling Screensaver"
Set-ItemProperty "HKCU:\Control Panel\Desktop" -Name ScreenSaveActive -Value 0 -Type DWord
& powercfg -x -monitor-timeout-ac 0
& powercfg -x -monitor-timeout-dc 0
Stop-transcript

Is that correct?
Yes, test this first... not sure if a user can write there, but I think so... Deploy the script to a test user, check the log
Oh wait I have been deploying this script to the device but setting "Run this script using the logged on credentials" as on is this correct I dont need to deploy it to the user instead do i?
You do need to deploy it to the user :grinning_face_with_sweat:

@Harm_Veenstra 

 

 

Ahhh my bad I apologies! Ill deploy to the user also can you check if this is correct:

 

Screenshot 2023-07-14 at 08.05.26.png

Seems ok, you're using a group with just users now?
Yes ahha Sorry about that I misunderstood, I am just waiting for policy to deploy

Hi @Harm_Veenstra 

 

That sill didnt work

 

Screen.PNG

 

error.PNG

best response confirmed by AB21805 (Bronze Contributor)
Solution
I added the script to my tenant and deployed it to my user, and the value was changed to 0. I changed it to your value (320), changed the script (Changed the log file name), and uploaded it again to Intune. The script ran on my client, and the value is back to 0. It just works... Not sure what is happening to your machine... Do you have a Configuration Profile which sets the ScreenSaver time-out? You have to exclude the group that you use for this script on that Configuration Profile
1 best response

Accepted Solutions
best response confirmed by AB21805 (Bronze Contributor)
Solution
I added the script to my tenant and deployed it to my user, and the value was changed to 0. I changed it to your value (320), changed the script (Changed the log file name), and uploaded it again to Intune. The script ran on my client, and the value is back to 0. It just works... Not sure what is happening to your machine... Do you have a Configuration Profile which sets the ScreenSaver time-out? You have to exclude the group that you use for this script on that Configuration Profile

View solution in original post