Exchange Bulk import from .csv file to remove from Allow and then Allow.

Nitech Inc 1 Reputation point

Hello Genius Peeps,

My name is Mehul Mehta i am working as a software developer in Nitech stainless so my question is

Thought maybe I could turn here for some help! Does anyone know of a Powershell script I could run on our Exchange server for to the following:

1) We would initially want to clear all or current mobile devices from all the users

2) Then re-add their specific mobile device ID that we received from them to the ALLOW list

Is there some sort of .csv and script I can create to make this process fast?

We found the following scripts to remove all from ALLOW and to add to ALLOW

Clear all Allow
Set-CASMailbox -Identity username -ActiveSyncAllowedDeviceIDs $null

Add to Allow
Set-CASMailbox -Identity username -ActiveSyncAllowedDeviceIDs @{add='DeviceId'}

And maybe after running this script if theres also a quick way to show the results were made to the accounts? Using this command? Get-CASMailbox -Identity username | fl activesync*

Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,226 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Zhengqi Lou-MSFT 8,856 Reputation points Microsoft Vendor

    Hi @Nitech Inc ,

    Have you ever tried this:

     Get-CASMailbox | Set-CASMailbox -ActiveSyncAllowedDeviceIDs $null  
     Import-Csv C:\list.csv |   
     try {  
     Set-CASMailbox -Identity $_.UserName -ActiveSyncAllowedDeviceIDs $_.DeviceId -ErrorAction Stop  
     Write-Output "Successfully Done $_" | Out-File "C:\added.csv" -Append  
     catch [System.Exception]   
     Write-Output "$_" | Out-File "c:\error.csv" -Append  

    Since your issue is same with this thread:
    I think you could check it and if that doesn't meet your requirement, please let me know.

    Best regards,

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.