Category filter

Script to set Screensaver on Windows

A screensaver is set to turn on after a period of inactivity of the user. It can be used as a medium to display your brand when the screen is idle. It is also used to prevent others from viewing personal content when the user is away for a short while. You can set a screensaver on your Windows devices remotely using Hexnode’s custom script feature.

Disclaimer:

The Sample Scripts provided below are adapted from third-party Open-Source sites.

Script to fetch SID

To change the screensaver, we need to specify the user’s security identifier (SID), or we should change the screensaver for every user on that device. To get the SID of any user, run the command:

Get-WmiObject -gets instances of WMI classes or information about the available WMI classes.

Select-Object -selects specified properties of an object or set of objects.

Script to set screensaver

Once the SID of a user is known, the screensaver of a specific user can be changed by providing their SID. Run the script:

If the SID of the user is specified as an argument, then the screensaver will be set only for that specific user. The script accepts an argument $userSID to change the screensaver of the corresponding user.

If no arguments are passed in place of SID, screensavers will be set for all the users in the device.

Notes:

  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository