I would like to deploy icons on the current user’s desktop. This is currently being done using group policy as part of the user’s logon. Is there a way to achieve this using Worklets?
Is there an evaluation script I can run to figureout the currently logged on user? Then a remediation script to run that will create the icons on the current logged on user’s desktop?
Page 1 / 1
There’s some code in this worklet that creates a shortcut:
that you could repurpose.
This worklet has code that will grab the current user:
Between the two you could make a worklet that grabs the current user, then puts a shortcut in their desktop folder. You’d want all of the code in the remediation section. For the evaluation you could use exit 1 to make it run every time, or you could check for the presence of the shortcut first.
Let me know if you have any issues getting that to work and I’m happy to help out.
Perfect! This is amazing. The information you have shared is enough for me to work out the necessary Powershell code. Thank you 😍
wootwoot! i have addressing this on my todo list, as well…while domain joined, many of my systems are beyond the consistent reach of GPO policies. 🤬🤮🤬
i would legit be interested to see how you wrote this script block out!?
how i attacked this: i broke this down into three unique blocks ( a] add a shortcut to a website for current user, ,b] add a shortcut to an application for the current user, and dc] add a shortcut to a website for all users).
to place a shortcut to a website on the current user desktop:
# System variable
$CurrentUser = (Get-WmiObject -class win32_process | Where-Object name -Match explorer).getowner().user
# Variables :: define target, name, & location of your shortcut
$Target = "https://google.com"
$ShortcutName = "Google.url"
$Location = "c:\Users\${CurrentUser}\Desktop\"
# Work zone :: No variables/edits below
# if Windows 10 (due to user folder locations):
if ( Environment]::OSVersion.Version.Major -ge 10) {
# create a variable referencing a Wscript.Shell COM Object
This returns the currently logged on user’s name (this may go awry if there is more than one user logged on but it’s rare). It might make sense to check for this scenario and abort the script if it’s detected.
Returns the DNS name of the domain the computer is joined to. This is just an additional check to ensure the computer the Automox agent is running on is a corporate computer.
This allows allows me to dynamically generate the user profile path. It’s quite easy to iterate through all the paths returned and figure out which belongs to $strCurrentUserName
Glad that I was able to point you in the right direction @jesumyip!