Looking to create Atera Script to list Local Users and another to remove listed Local Users
Hi. I want to find someone who can help me develop a "relatively" automated solution to list all the local windows users on a group of Windows 10 PCs. Ideally this script could be run using an IT Automation assigned to the group of PCs and the results would be saved on the PC running the Atera Portal.
Then I'd like to develop a script that would remove a list of local users from a specific PC.
So far, I have figured out I can use the PS cmdlets Get-LocalUser and Remove-LocalUser and run these from the Manage/Powershell menu, but that still has me going to each PC and the output is displayed on the screen. Would like to automate this further and have output generate in a more useable fashion.
Please reply if you are interested.
Comments
-
HI!
I've seen some scripts that do this in the Atera Shared Script Library: https://app.atera.com/new/admin/scripts If you search for "Lists local users on PC" there will be a script that pops up that you can clone and use in your environment. Once you get it into your environment, you can run it on all or select machines. Totally up to you on your scope. Likewise after you clone it, you can add the Remove local users command and run it as an administrator to complete.
I'm not 100% sure how to have it say export at as report locally, meaning run this on x machines then output to a single file or report in my environment. May you could create reporting folder under the admin account on each machine and have the report saved there, then at least you would have known location on where to grab the reports. Just an idea, but that would be a cool feature to have.
Sincerely,
Kim
1 -
I just submitted a script that might do what you are looking for with some minor tweaking.
Just be careful since it's a wildcard search and will purge the user and the profile folder.Enummerate the list of users $removeUser = Get-LocalUser -Name "{[User_Search_Name]}" | Select-Object -ExpandProperty Name Remove all of the users in the array foreach ($currUser in $removeUser)
{
Write-Output $currUser } try {
Remove-LocalUser -Name $currUser -erroraction Stop
} catch {
Write-Output "Unable to locate any users."
Exit 0
}
# Get the path to the user's profile folder
$profilePath = "C:\Users\$currUser"
# Check if the profile folder exists
if (Test-Path $profilePath) {
# Remove the profile folder
Remove-Item $profilePath -Recurse -Force
Write-Output "Profile folder for $currUser has been removed."
} else {
Write-Output "Profile folder for $currUser does not exist."
}2 -
I have been working on something very similar.
After creating your scripts, set them up through IT Automation. You will be able to download the results.
I have a powershell script that lists all local users, status and group membership.
Based on those results, I have a cmd line script that removes specified users, and adds others.I am new at posting here and haven't quite figured out how to post my scripts …
2 -
Excited to see what you have.
You can add a "Code Block" from the paragraph button on the left
Paragraph > Quotes > Code Block3
Topics
- All Topics
- 41 Getting started
- 25 Read before posting
- 8 Meet and greet
- 238 General
- 64 News and announcements
- 1 Swag
- 1 Roadmap updates
- 79 Resources
- 12 Knowledge Base
- 16 Webinars
- 1 Shared Script Library
- 2 Blog
- 19 Pro Tips
- 27 Got an idea?
- 3 Atera Academy
- 2 ActionAI
- 1 Copilot
- 140 Remote Monitoring and Management
- 84 Remote Monitoring
- 27 Patch Management
- 106 Professional Services Automation
- 65 Helpdesk
- 17 Billing
- 21 Reporting
- 37 Integrations & add-ons
- 20 Integrations
- 10 Add-ons
- 103 Scripting and automations
- 61 Scripts
- 30 Automations