Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Remov Active Sync from disabled accounts

$
0
0

I have come up with a script that should remove Active Syncs from user accounts that are disabled, but i would also like to export the display name and alias to a csv. I don't know if my export-csv is in the right spot to get all of the accounts. Below is the script:

Powershell
#Variables$FilePath="C:\Scripts\ActiveSync\removed-eas.csv"$OuDomain=""$StaleDevices=Get-Mailbox-resultsizeunlimited-OrganizationalUnit$OuDomain|ForEach{Get-ActiveSyncDeviceStatistics-Mailbox:$_.Identity}`|where{$_.ExchangeUserAccountControl-match'AccountDisabled'}|select-expandIdentityforeach($devicein$StaleDevices){Remove-ActiveSyncDevice-Identity$device-confirm:$true}|Select-ObjectDisplayName,Alias|Export-Csv$FilePath-NoTypeInformation

Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>