{"id":1970,"date":"2026-07-01T00:59:17","date_gmt":"2026-07-01T00:59:17","guid":{"rendered":"https:\/\/www.ultrex-kb.com\/?p=1970"},"modified":"2026-07-01T00:59:17","modified_gmt":"2026-07-01T00:59:17","slug":"managing-local-entra-id-azure-ad-profiles-via-powershell","status":"publish","type":"post","link":"https:\/\/www.ultrex-kb.com\/?p=1970","title":{"rendered":"Managing Local Entra ID (Azure AD) Profiles via PowerShell"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Objective: Safely identify and remove cached Entra ID user profiles on local Windows devices to free up disk space and resolve profile issues.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br>Note on net user:<br>The standard <code>net user<\/code> command only queries the local Security Account Manager (SAM) database. Because Entra ID users authenticate against the cloud, Windows does not create a local SAM account for them, making them invisible to <code>net user<\/code>. The methods below must be used instead.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br><strong>1. How to View Profiles via PowerShell<\/strong><br>To get a quick list of all user profiles currently cached on a machine, run the following command in an elevated PowerShell prompt.<br><em>Entra ID profiles can be identified by their SID, which always begins with S-1-12-1.<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-CimInstance Win32_UserProfile | Select-Object LocalPath, SID<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. How to Safely Remove Profiles via PowerShell<\/strong><br>WARNING: Never delete a user\u2019s folder directly from <code>C:\\Users<\/code>. Doing so leaves orphaned SID entries in the registry (<code>ProfileList<\/code>). If that user logs into the device again, Windows will fail to load their profile and force them into a temporary profile (<code>C:\\Users\\TEMP<\/code>).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br>To cleanly wipe both the file system directory and the associated registry keys, run PowerShell as an Administrator and use the <code>Remove-CimInstance<\/code> command.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br><strong>Method A: Remove by SID (Recommended)<br><\/strong>Copy the SID from the viewing step and run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-CimInstance Win32_UserProfile | Where-Object { $_.SID -eq \"S-1-12-1-YOUR-SID-HERE\" } | Remove-CimInstance<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Method B: Remove by Folder Path<br><\/strong>If you prefer to target the exact folder name located in <code>C:\\Users<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-CimInstance Win32_UserProfile | Where-Object { $_.LocalPath -like \"*\\TargetUsername\" } | Remove-CimInstance<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. Essential Diagnostic Commands: <\/strong><code>quser<\/code><strong> and <\/strong><code>dsregcmd<\/code><br>Before removing a profile or when troubleshooting an Entra ID login issue, you should use these two built-in command-line tools to understand the current state of the machine.<br><strong>Checking Active Sessions with <\/strong><code>quser<\/code><br>While <code>Get-CimInstance<\/code> shows you every profile <em>saved<\/em> on the disk, it doesn&#8217;t tell you if the user is currently using the machine.<br>Run this in CMD or PowerShell:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>quser<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>What it does:<\/strong> Displays all currently active or disconnected login sessions on the machine.<\/li>\n\n\n\n<li><strong>Why use it:<\/strong> Always run <code>quser<\/code> before deleting a profile to ensure the target user doesn&#8217;t currently have a locked\/disconnected session running in the background. You cannot cleanly delete a profile that is actively loaded into memory.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Checking Cloud Connectivity with <\/strong><code>dsregcmd \/status<\/code><br>If an Entra ID user is failing to log in, or their profile isn&#8217;t syncing properly, the issue might be with the device itself rather than the user profile.<br>Run this in CMD or PowerShell (no admin required):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dsregcmd \/status<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>What it does:<\/strong> Outputs the complete Azure AD\/Entra ID registration status of the local device.<\/li>\n\n\n\n<li><strong>What to look for:<\/strong><br>\u2022 <strong>AzureAdJoined : YES<\/strong> (Under Device State): Confirms the machine is successfully joined to the client&#8217;s cloud tenant.<br>\u2022 <strong>AzureAdPrt : YES<\/strong> (Under SSO State): Confirms the user has a valid Primary Refresh Token. If this says NO, the user&#8217;s cloud credentials are out of sync or expired, which will break access to local Office apps and OneDrive.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Appendix: The GUI Method<\/strong><br>If technicians prefer a visual interface, or if you are doing a bulk cleanup on a single machine, use the native Windows tool:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the Run dialog (<code>Win + R<\/code>) or CMD.<\/li>\n\n\n\n<li>Type <code>sysdm.cpl<\/code> and press Enter.<\/li>\n\n\n\n<li>Navigate to the <strong>Advanced<\/strong> tab.<\/li>\n\n\n\n<li>Under the <strong>User Profiles<\/strong> section, click <strong>Settings<\/strong>.<\/li>\n\n\n\n<li>Select the target profile from the list and click <strong>Delete<\/strong>.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">This executes the same safe removal process as the PowerShell commands above.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Objective: Safely identify and remove cached Entra ID user profiles on local Windows devices to free up disk space and resolve profile issues.<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[116,5,98,137,1,120],"tags":[],"class_list":["post-1970","post","type-post","status-publish","format-standard","hentry","category-intune-and-entra","category-it","category-it-knowledge-base-articles","category-powershell","category-uncategorized","category-windows","post-preview"],"_links":{"self":[{"href":"https:\/\/www.ultrex-kb.com\/index.php?rest_route=\/wp\/v2\/posts\/1970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ultrex-kb.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ultrex-kb.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ultrex-kb.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ultrex-kb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1970"}],"version-history":[{"count":1,"href":"https:\/\/www.ultrex-kb.com\/index.php?rest_route=\/wp\/v2\/posts\/1970\/revisions"}],"predecessor-version":[{"id":1971,"href":"https:\/\/www.ultrex-kb.com\/index.php?rest_route=\/wp\/v2\/posts\/1970\/revisions\/1971"}],"wp:attachment":[{"href":"https:\/\/www.ultrex-kb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ultrex-kb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ultrex-kb.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}