Script to add "Last User" to the "Remote Desktop Users" group

We are currently going through the process of removing local admin rights on our pc's and we still need the ability for our users to remote desktop to their pc. I don't want to give everyone access to remote into all of our computers, only their primary. Is there a way of scripting this in KACE?



0 Comments   [ + ] Show comments

Answers (1)

Posted by: cmccracken 5 years ago
Orange Senior Belt

Hey Chad,

I think powershell can help with this one.

Make a powershell script with the following (verifying for your environment):

#Read the most recent inventory
[xml]$inventory = Get-Content C:\ProgramData\Dell\KACE\inventory.xml

#Get the last user
$user = $inventory.MachineStruct.LAST_USER.InnerText

#Add user to group
net localgroup "Remote Desktop Users" /add $user

Add the powershell script as a dependency to an online shell script (running as local system).  For the script text use:

powershell.exe -nologo -noninteractive -windowstyle hidden -executionpolicy bypass -noprofile -file DependencyNameHere.ps1

I tested the powershell script, but didn't test deploying it from the kbox (though the code to do so is from another powershell script I have) so please make sure you test it first.


Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ