PowerShell Automation – Microsoft Entra ID Group Cleanup
Budget / Salary£20–250
TypeFreelance project
LocationRemote
Posted3 hours ago
I need a hardened PowerShell script that an IT service-desk analyst can run to remove all applicable group memberships from a specified Microsoft Entra ID (Azure AD) user as part of the employee leaver/offboarding process.
The current proof-of-concept works, but it needs additional robustness, security controls, error handling and operational documentation to make it suitable for regular service-desk use.
What needs to be built
* A single .ps1 PowerShell script that connects to Microsoft Entra ID using the Microsoft Graph PowerShell SDK.
* Validate that the target user account exists before making any changes.
* Enumerate the user’s current group memberships.
* Safely remove the applicable group memberships.
* Include appropriate safeguards to prevent accidental processing of the wrong account.
* Exit with clear success or failure codes.
* Provide clear messages to the service-desk analyst throughout the process.
Documentation
Please provide:
* A quick-start/support guide explaining prerequisites, installation, parameters and how to run the script.
* Inline PowerShell help within the script.
* Instructions explaining the rollback/recovery process where applicable.
* A README explaining assumptions, known limitations and recommendations for future security hardening.
Security and operational requirements
* The script must verify that the operator has the appropriate Microsoft Entra permissions before any changes are made.
* Insufficient permissions must be detected early and the script must stop safely without partially processing the account.
* Authentication must not require hard-coded or plain-text passwords, secrets or credentials.
* Use the Microsoft Graph PowerShell SDK where appropriate.
* Include proper parameter validation.
* Use structured try/catch error handling.
* Include appropriate confirmation/safety checks before destructive operations.
Audit logging
Every significant action should be recorded, including:
* Script start and completion
* Authentication/connection status
* Target user validation
* Groups identified
* Each group removal attempt
* Successful removals
* Failed removals
* Exceptions and errors
Logs should be produced in an easily consumable format such as CSV or JSON and should be suitable for integration with SIEM/searching workflows.
Acceptance criteria
1. Running:
.\Remove-UserGroups.ps1 -UserPrincipalName
should complete without unhandled errors when the operator has the required permissions and the target account is valid.
2. The audit log must record the start time, target account, group membership actions and final completion status.
3. Running the script without the required permissions must produce a clear and actionable error and must not partially process the account.
4. Network/API failures must be handled gracefully and reported clearly.
5. The script must not contain hard-coded passwords, secrets or credentials.
6. Documentation must be clear enough for a new service-desk analyst to follow without additional coaching.
Deliverables
* Remove-UserGroups.ps1
* Support-Desk-Guide.pdf or .md
* README_Assumptions_Limitations.md
The finished solution should be production-focused, maintainable and written according to good PowerShell and Microsoft Entra security practices.
Important: Please explain any assumptions you make and highlight any Microsoft Entra/Graph API limitations that affect the solution.
The current proof-of-concept works, but it needs additional robustness, security controls, error handling and operational documentation to make it suitable for regular service-desk use.
What needs to be built
* A single .ps1 PowerShell script that connects to Microsoft Entra ID using the Microsoft Graph PowerShell SDK.
* Validate that the target user account exists before making any changes.
* Enumerate the user’s current group memberships.
* Safely remove the applicable group memberships.
* Include appropriate safeguards to prevent accidental processing of the wrong account.
* Exit with clear success or failure codes.
* Provide clear messages to the service-desk analyst throughout the process.
Documentation
Please provide:
* A quick-start/support guide explaining prerequisites, installation, parameters and how to run the script.
* Inline PowerShell help within the script.
* Instructions explaining the rollback/recovery process where applicable.
* A README explaining assumptions, known limitations and recommendations for future security hardening.
Security and operational requirements
* The script must verify that the operator has the appropriate Microsoft Entra permissions before any changes are made.
* Insufficient permissions must be detected early and the script must stop safely without partially processing the account.
* Authentication must not require hard-coded or plain-text passwords, secrets or credentials.
* Use the Microsoft Graph PowerShell SDK where appropriate.
* Include proper parameter validation.
* Use structured try/catch error handling.
* Include appropriate confirmation/safety checks before destructive operations.
Audit logging
Every significant action should be recorded, including:
* Script start and completion
* Authentication/connection status
* Target user validation
* Groups identified
* Each group removal attempt
* Successful removals
* Failed removals
* Exceptions and errors
Logs should be produced in an easily consumable format such as CSV or JSON and should be suitable for integration with SIEM/searching workflows.
Acceptance criteria
1. Running:
.\Remove-UserGroups.ps1 -UserPrincipalName
should complete without unhandled errors when the operator has the required permissions and the target account is valid.
2. The audit log must record the start time, target account, group membership actions and final completion status.
3. Running the script without the required permissions must produce a clear and actionable error and must not partially process the account.
4. Network/API failures must be handled gracefully and reported clearly.
5. The script must not contain hard-coded passwords, secrets or credentials.
6. Documentation must be clear enough for a new service-desk analyst to follow without additional coaching.
Deliverables
* Remove-UserGroups.ps1
* Support-Desk-Guide.pdf or .md
* README_Assumptions_Limitations.md
The finished solution should be production-focused, maintainable and written according to good PowerShell and Microsoft Entra security practices.
Important: Please explain any assumptions you make and highlight any Microsoft Entra/Graph API limitations that affect the solution.
Apply on Freelancer →
Project sourced from Freelancer.com. Applications happen directly on the original platform — we never collect your data.