Skip to content

Commit 3be6920

Browse files
authored
Rename script and improve README details
Updated script name and enhanced documentation for license removal script.
1 parent 63de32c commit 3be6920

1 file changed

Lines changed: 30 additions & 4 deletions

File tree

README.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ PowerShell-Scripts/
3030
│ └── watch_X_job3.ps1
3131
│ └── Audit-AllUsersRolePerms.ps1
3232
│ └── Get-DisabledUsersLicenses.ps1
33-
│ └── RemoveM365LicensesfromDisabledUsers3.ps1
33+
│ └── RemoveM365LicensesfromDisabledUsers.ps1
3434
│ └── Inspect-AzWebAppSecurity-Consolidated.ps1
3535
│ └── Audit-NeverSucceedingMailForwardingRules.ps1
3636
│ └── Review-TeamsLifecycleCleanupCandidates.ps1
@@ -249,11 +249,37 @@ An optional per-user summary consolidates each disabled account’s licenses and
249249
```
250250

251251
---
252-
### `RemoveM365LicensesfromDisabledUsers3.ps1`
252+
### `RemoveM365LicensesfromDisabledUsers.ps1`
253253

254-
Enumerates disabled users and (by default in dry‑run) identifies and exports their assigned license names; when not in dry‑run it removes direct user licenses and logs actions.
255-
Prerequisites: An active Graph session (Connect-MgGraph) with User.ReadWrite.All and Directory.ReadWrite.All consent, Microsoft Graph PowerShell modules installed, sufficient admin rights to change licenses
254+
Audits disabled Microsoft Entra users with effective license assignments and exports detailed license-source and action-summary reports. The script distinguishes directly assigned licenses from group-based licensing and operates in audit-only mode by default. Direct licenses can be removed only through the explicit -Execute switch, with support for approved-user CSV input, targeted UPNs, -WhatIf, confirmation prompts, and detailed action logging. Reuses the current Microsoft Graph PowerShell session and does not request new consent automatically.
256255

256+
Audit Mode
257+
```powershell
258+
# Reuse an existing Microsoft Graph session.
259+
Connect-MgGraph -Scopes "User.Read.All", "Organization.Read.All" -NoWelcome
260+
261+
# Audit all disabled licensed member accounts.
262+
# No licenses are removed.
263+
.\RemoveM365LicensesfromDisabledUsers.ps1
264+
```
265+
266+
Removal Mode
267+
```powershell
268+
# Reuse an existing Microsoft Graph session with license-management permission.
269+
Connect-MgGraph -Scopes "User.Read.All", "Organization.Read.All", "LicenseAssignment.ReadWrite.All" -NoWelcome
270+
271+
# Preview the removal of directly assigned licenses from users
272+
# listed in a reviewed CSV. No licenses are removed with -WhatIf.
273+
.\RemoveM365LicensesfromDisabledUsers.ps1 `
274+
-ApprovedUsersCsv ".\approved-users.csv" `
275+
-Execute `
276+
-WhatIf
277+
278+
# After reviewing the preview, remove -WhatIf to execute.
279+
.\RemoveM365LicensesfromDisabledUsers.ps1 `
280+
-ApprovedUsersCsv ".\approved-users.csv" `
281+
-Execute
282+
```
257283

258284

259285

0 commit comments

Comments
 (0)