multicloud365
  • Home
  • Cloud Architecture
    • OCI
    • GCP
    • Azure
    • AWS
    • IAC
    • Cloud Networking
    • Cloud Trends and Innovations
    • Cloud Security
    • Cloud Platforms
  • Data Management
  • DevOps and Automation
    • Tutorials and How-Tos
  • Case Studies and Industry Insights
    • AI and Machine Learning in the Cloud
No Result
View All Result
  • Home
  • Cloud Architecture
    • OCI
    • GCP
    • Azure
    • AWS
    • IAC
    • Cloud Networking
    • Cloud Trends and Innovations
    • Cloud Security
    • Cloud Platforms
  • Data Management
  • DevOps and Automation
    • Tutorials and How-Tos
  • Case Studies and Industry Insights
    • AI and Machine Learning in the Cloud
No Result
View All Result
multicloud365
No Result
View All Result

AzureAD Stale Units Cleanup | Tech Wizard

admin by admin
July 4, 2025
in Azure
0
AzureAD Stale Units Cleanup | Tech Wizard
399
SHARES
2.3k
VIEWS
Share on FacebookShare on Twitter


We now have not too long ago written this PowerShell magic by following the Microsoft documentation.

How To: Handle stale units in Azure AD

This script has been parameterized to do a number of capabilities as per your wants.

Stipulations for this resolution:

Obtain the answer from beneath git hub hyperlink: (AzureMobileStaleDeviceCleanup.ps1)

https://github.com/VikasSukhija/Downloads

Obtain the answer from PowerShell Gallery:

https://www.powershellgallery.com/packages/AzureMobileStaleDeviceCleanup

Set up-Script -Identify AzureMobileStaleDeviceCleanup


Script will auto generate the password first time when it runs and can put it aside as encrypted in the identical folder.

Script has been added with default parameters, however you’ll be able to change as per your surroundings or simply add it to when working it as proven beneath.

 

Syntax for working the Script:

Reportonly:

. AzureMobileStaleDeviceCleanup.ps1 -LastActivityDisableDays 180 -LastActivityDeleteDays 365 -Operation Report -smtpserver ‘smtpserver.labtest.com’ -from ‘DoNotRespond@labtest.com’ -erroremail ‘Studies@labtest.com’ -CountofChanges 100

By default, lastactivitydisabledays is about to 90 and LastActivityDeleteDays is about to 120 however you’ll be able to replace it to what ever you need when working it as proven above.

Equally, you’ll be able to select the operation as Disable, Take away or DisableAndRemove.

 

Disable: This implies script will discover the units which have ‘ApproximateLastLogonTimeStamp‘ earlier than LastActivityDisableDays parameter (This operation will disable the machine in azureAD)

Take away: This implies script will discover the units which have ‘ApproximateLastLogonTimeStamp‘ earlier than LastActivityDeleteDays parameter (This operation will take away the machine in azureAD)

DisableAndRemove: This implies script will discover the units which have ‘ApproximateLastLogonTimeStamp‘ between LastActivityDisableDays and LastActivityDeleteDays (Disable these Units)

 

Script will even discover units which have ‘ApproximateLastLogonTimeStamp‘ earlier than LastActivityDeleteDays parameter (take away these units)

If you find yourself able to deploy it in prod, don’t forget to un hash the beneath instructions that has been used contained in the script to disable and take away units.

We’re nonetheless testing it and never but put to prod for the shopper so releasing it as it’s, last model could change a bit.

#Set-AzureADDevice -Objectid $Gadget.ObjectID -AccountEnabled $false

#Take away-AzureADDevice -ObjectId $Deleted.ObjectID

 

Right here is the snippet of the report it is going to generate.


I hope this PowerShell magic will enable you to in eradicating stale units out of your surroundings.

You possibly can schedule it to run every day or weekly as pe your wants.

(Account used for working it’s in bypass MFA or it’s worthwhile to do app registration and certification approach in case your surroundings is strict on MFA’s)

 

Thanks for studying and downloading….

Tech Wizard

https://techwizard.cloud

https://syscloudpro.com/

PowerShell Quick Observe

 

Tags: AzureADCleanupDevicesStaleTechWizard
Previous Post

The way to Monitor, Diagnose, and Clear up Gradient Points in Basis Fashions

Next Post

Episode 20: All-in-One AI Advertising Platform for SMBs

Next Post
Episode 15: Reflecting on 2024 and Wanting Forward to AI in 2025 | Rick’s AI Panel

Episode 20: All-in-One AI Advertising Platform for SMBs

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Trending

The State of Utility Danger: Key Findings Reveal Widespread Safety Vulnerabilities

The State of Utility Danger: Key Findings Reveal Widespread Safety Vulnerabilities

January 23, 2025
PowerShell – Report on Azure Disks throughout Group

PowerShell – Report on Azure Disks throughout Group

May 1, 2025
The clock is ticking: Monetary cyberattacks are extra harmful than ever

The clock is ticking: Monetary cyberattacks are extra harmful than ever

May 3, 2025
6 Methods That Prime Fuels Amazon’s Retail Development

6 Methods That Prime Fuels Amazon’s Retail Development

June 25, 2025
How Google constructed Pixel’s AI Add Me function

How Google constructed Pixel’s AI Add Me function

January 28, 2025
The Job Marketplace for Microsoft 365 Directors

The Job Marketplace for Microsoft 365 Directors

May 2, 2025

MultiCloud365

Welcome to MultiCloud365 — your go-to resource for all things cloud! Our mission is to empower IT professionals, developers, and businesses with the knowledge and tools to navigate the ever-evolving landscape of cloud technology.

Category

  • AI and Machine Learning in the Cloud
  • AWS
  • Azure
  • Case Studies and Industry Insights
  • Cloud Architecture
  • Cloud Networking
  • Cloud Platforms
  • Cloud Security
  • Cloud Trends and Innovations
  • Data Management
  • DevOps and Automation
  • GCP
  • IAC
  • OCI

Recent News

What The Knowledge Actually Says

What The Knowledge Actually Says

July 19, 2025
Construct real-time journey suggestions utilizing AI brokers on Amazon Bedrock

Construct real-time journey suggestions utilizing AI brokers on Amazon Bedrock

July 19, 2025
  • About Us
  • Privacy Policy
  • Disclaimer
  • Contact

© 2025- https://multicloud365.com/ - All Rights Reserved

No Result
View All Result
  • Home
  • Cloud Architecture
    • OCI
    • GCP
    • Azure
    • AWS
    • IAC
    • Cloud Networking
    • Cloud Trends and Innovations
    • Cloud Security
    • Cloud Platforms
  • Data Management
  • DevOps and Automation
    • Tutorials and How-Tos
  • Case Studies and Industry Insights
    • AI and Machine Learning in the Cloud

© 2025- https://multicloud365.com/ - All Rights Reserved