Hello Ridanh,
You can use something like that :
$dt = (Get-Date).AddDays(-400)
Get-AzureADDevice -All:$true | Where {$_.ApproximateLastLogonTimeStamp -le $dt} | Remove-AzureADDevice
Regards,
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi All,
I have used the below script to disable devices in Azure AD from a set period of time, where 90 is the number of days.
$dt = (Get-Date).AddDays(-90)
Get-AzureADDevice -All:$true | Where {$_.ApproximateLastLogonTimeStamp -le $dt} | Set-AzureADDevice -AccountEnabled $false
Would anybody know a similar script to delete devices from a set period of time eg 400 days or would know what I can do to change the above around to use as i need.
thanks
Hello Ridanh,
You can use something like that :
$dt = (Get-Date).AddDays(-400)
Get-AzureADDevice -All:$true | Where {$_.ApproximateLastLogonTimeStamp -le $dt} | Remove-AzureADDevice
Regards,
Hi, i have tried the below and have error returned
PS C:\WINDOWS\system32> $dt = (Get-Date).AddDays(-1400)
PS C:\WINDOWS\system32> $dt = (Get-Date).AddDays(-1400) Get-AzureADDevice -All:$true | Where {$_.ApproximateLastLogonTimeStamp -le $dt} | Remove-AzureADDevice
At line:1 char:33