Step-wise user profile revoke process in Mac.

Deleting Unwanted User Profiles from macOS and Windows using JumpCloud


Deleting Unwanted User Profiles from macOS and Windows using JumpCloud

Overview

This guide provides steps to identify and remove unwanted/suspended user profiles from macOS and Windows systems through JumpCloud Commands. It ensures that only the desired user accounts remain active, improving system hygiene and security.


MacOS Instructions

  1. Go to the JumpCloud Admin Portal.

  2. Navigate to Commands+ Add New Command.

  3. Select the macOS checkbox.

  4. In the Command section, paste the below script.

🔄 IMPORTANT: Replace "username_to_revoke" with the username you want to retain/enable.

🧾 Script (macOS Bash)

#!/bin/bash

# Set 'armed' to true if you want the script to actually delete users
armed=false

# Define the specific user you want to enable
target_user="username_to_revoke"

## DO NOT MODIFY BELOW THIS LINE ##

# Enable (reactivate) the specific user first
echo "Enabling user: $target_user"

# Remove the DisabledUser flag to enable the account
sudo dscl . -delete "/Users/$target_user" AuthenticationAuthority ";DisabledUser;"
if [[ $? -eq 0 ]]; then
    echo "User $target_user has been successfully enabled."
else
    echo "Failed to enable user $target_user or user is already enabled."
fi

# Now proceed to find and (optionally) delete all disabled users
IFS=$'\n'
for x in $(dscl . -list /Users); do
    if dscl . -read "/Users/$x/" | grep -q DisabledUser; then
        if [[ ! "$x" =~ "_jumpcloudserviceaccount" ]]; then
            echo "Found disabled user account: $x."
            if [[ "$armed" == true ]]; then
                echo "Deleting disabled user account: $x"
                sudo sysadminctl -deleteUser "$x"
            fi
        fi
    fi
done

exit 0

⚠️ Tips:

  • Set armed=true to actually delete the unwanted users.

  • Always test the script with armed=false to review the output before deleting.


Windows Instructions

  1. Go to the JumpCloud Admin Console.

  2. Navigate to Commands+ Add New Command.

  3. Check the box for Windows and ensure PowerShell is selected.

  4. Paste the following script in the Command section.

🔄 IMPORTANT: Replace "user name" with the user account(s) you want to preserve.

🧾 Script (PowerShell)

# User(s) to keep
$usersToKeep = @("user name")

# Get all local users
$allUsers = Get-LocalUser

foreach ($user in $allUsers) {
    if ($usersToKeep -notcontains $user.Name) {
        Write-Host "Disabling user: $($user.Name)"
        Disable-LocalUser -Name $user.Name

        Write-Host "Deleting user: $($user.Name)"
        Remove-LocalUser -Name $user.Name
    } else {
        Write-Host "Preserving user: $($user.Name)"
    }
}

📝 Notes:

  • Ensure you have the necessary admin rights on devices.

  • Use caution before setting scripts to delete accounts – review and test before going live.

  • Monitor the Command results in JumpCloud for success/failure status.


✅ Summary

Using these tailored scripts, IT administrators can efficiently clean up user profiles on macOS and Windows while preserving necessary accounts — all through JumpCloud Commands.

    • Related Articles

    • How to Access a macOS User Profile Using the FileVault Recovery Key (When the User Password Is Not Working)

      How to Access a macOS User Profile Using the FileVault Recovery Key (When the User Password Is Not Working) If a Mac user forgets their password or the system does not accept it, you can regain access to the user profile using the FileVault Recovery ...
    • Mac User Profile Locked/Disabled – Resolution Guide

      Issue Summary Name: Mac User Profile Got Locked/Disabled Possible Reasons for Locked/Disabled Account 1. Exceeding the allowed number of incorrect password attempts. 2. Jumpcloud password doesn’t match the local account. it may trigger a lockout 3. ...
    • Deploy SentinelOne Agent Using JumpCloud Commands (Windows, macOS, Linux)

      Deploy SentinelOne Agent Using JumpCloud Commands (Windows, macOS, Linux) This guide explains how to install the SentinelOne Endpoint Agent on Windows, macOS, and Linux devices using JumpCloud Commands. Each command automatically downloads the ...
    • Suspended Mac user unlock

      Re-Enable a Disabled Mac User Account When you remove access to a Mac from a user in JumpCloud, the user account is disabled, not deleted. The user’s files and data are preserved, but disabled users will not appear on: The macOS login screen System ...
    • JC Go Extension Deployment via JumpCloud (macOS & Windows)

      JC Go Extension is deployed to user device via Jumpcloud. Browsers ✅ macOS Browser Deployment Method Google Chrome .plist/.xml Microsoft Edge .plist/.xml Brave .plist/.xml ✅ Windows Browser Deployment Method Google Chrome PowerShell Microsoft Edge ...