Using powershell to disable O365 POP and IMAP from a user CSV list

%3CLINGO-SUB%20id%3D%22lingo-sub-896080%22%20slang%3D%22en-US%22%3EUsing%20powershell%20to%20disable%20O365%20POP%20and%20IMAP%20from%20a%20user%20CSV%20list%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-896080%22%20slang%3D%22en-US%22%3E%3CP%3EHow%20to%20use%20powershell%20to%20disable%20O365%20POP%20and%20IMAP%20from%20a%20user%20CSV%20list%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-896080%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExchange%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-896536%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20powershell%20to%20disable%20O365%20POP%20and%20IMAP%20from%20a%20user%20CSV%20list%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-896536%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F61448%22%20target%3D%22_blank%22%3E%40Marvin%20Oco%3C%2FA%3E%26nbsp%3BYou%20can%20use%20the%20Set-CASMailbox%20-Identity%20%3CUPN%3E%26nbsp%3B-PopEnabled%20%24false%20-ImapEnabled%20%24false%3C%2FUPN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-898641%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20powershell%20to%20disable%20O365%20POP%20and%20IMAP%20from%20a%20user%20CSV%20list%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-898641%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F61448%22%20target%3D%22_blank%22%3E%40Marvin%20Oco%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EConsider%20the%20CSV%20file%20%22Users.csv%22%20which%20contains%20username%20(or%20upn)%20of%20users%20with%20the%20column%20header%20%3CSTRONG%3E%3CEM%3EUserPrincipalName%3C%2FEM%3E%3C%2FSTRONG%3E%20and%20try%20the%20below%20commands.%3C%2FP%3E%3CPRE%3EImport-Csv%20'C%3A%5CUsers.csv'%20%7C%20ForEach-Object%20%7B%0ASet-CASMailbox%20-Identity%20%24_.%22UserPrincipalName%22%20-PopEnabled%20%24false%20-ImapEnabled%20%24false%0A%7D%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Super Contributor

How to use powershell to disable O365 POP and IMAP from a user CSV list?

 

thanks

 

 

2 Replies
Highlighted

@Marvin Oco You can use the Set-CASMailbox -Identity <UPN> -PopEnabled $false -ImapEnabled $false

Highlighted

@Marvin Oco 

 

Consider the CSV file "Users.csv" which contains username (or upn) of users with the column header UserPrincipalName and try the below commands.

Import-Csv 'C:\Users.csv' | ForEach-Object {
Set-CASMailbox -Identity $_."UserPrincipalName" -PopEnabled $false -ImapEnabled $false
}