I've found this article where the author describes how to upload custom images. So what I would like to do now is have it rotate randomly every few minutes.

Seems like something that would work great with the scheduled task system.


Turns out that the contributors to the Sitecore PowerShell Extensions module thought of everything. Bundled with the module is a script under the script module Random desktop background. The script is apparently an adaptation from a POC by John West.

There is an integration point library called LoggedIn which in essence runs this script:

$path = [Sitecore.IO.FileUtil]::MapPath([Sitecore.Configuration.Settings]::WallpapersPath)
$files = [System.IO.Directory]::GetFiles($path)
$user = Get-User -Identity $username -Authenticated
$which = (New-Object System.Random).Next($files.Length - 1)
$user.Profile.SetCustomProperty("Wallpaper", [Sitecore.IO.FileUtil]::UnmapPath($files[$which]))

The script queries all of the wallpaper images then randomly assigns one to the selected user. Note that the script runs within the context of the logged in user.

Enable the sample module by checking and saving the item. These are disabled by default since they may not be the desired behavior for everyone.

Enable Module

The basic idea is that any script which appears below the pipeline integration will get executed. In this example, the LoggedIn pipeline executes the Random desktop background image script every time a user is logged in. You can have many modules with the LoggedIn integration point added, and each child script will get executed.


Documentation on the pipelines


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.