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

Nitech Inc 1 Reputation point
2021-04-30T12:05:31.61+00:00

Hello Genius Peeps,

My name is Mehul Mehta i am working as a software developer in Nitech stainless Inc.com 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
    2021-05-06T01:46:43.337+00:00

    Hi @Nitech Inc ,

    Have you ever tried this:

     Get-CASMailbox | Set-CASMailbox -ActiveSyncAllowedDeviceIDs $null  
          
     Import-Csv C:\list.csv |   
     ForEach{  
     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  
     }  
     Finally  
     {  
     }}  
    

    Since your issue is same with this thread: https://learn.microsoft.com/en-us/answers/questions/359416/exchange-bulk-import-from-csv-file-to-remove-from.html
    I think you could check it and if that doesn't meet your requirement, please let me know.

    Best regards,
    Lou


    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.