Create multiple tiny CSV files from a large one – with PowerShell

Some time ago I wrote an article how to split a large CSV file by using categories that are used inside: Splitting up a big CSV file to multiple smaller CSV files using PowerShell

Sometimes you just want to separate a large file to smaller ones, e.g. because you are having trouble with large Exchange migration batches. I am starting to make Exchange migration batches not larger than 20 users because during the last weeks and months I very often face the problem that Migration batches just stuck and do nothing – without any error or further message. Most times they run, some few times… just nothing..

Read more

Exchange Online PowerShell with Multifactor (updated)

PowerShell is great.

MFA is great (and secure).

Exchange Online is great.

We all know that. So everybody could think combining these 3 great factors will be a very great experience when you start an Exchange Online remote session with an MFA-secured account? Haha. This is the most annoying connection in PowerShell. Microsoft what did you smoke when you programmed that?

You want to know what I talk about? Then read this article carefully:

Connect to Exchange Online PowerShell using multi-factor authentication

Let me summarize the article.. You have to:

  • open a web browser
  • sign in to the O365 admin center using your MFA secured account
  • (or directly to Exchange Online if you know the URL)
  • go to the “hybrid” configuration
  • download an AddIn
  • Install it
  • use it in PowerShell

Yeah. During the last weeks I often had the problem that the addin cannot be loaded with this error (no matter which browser I use: IE, Edge, FF; Chrome, Opera):

ExchO2

The error talks about browser and application security zones. I will continue investigating this but for now I am still looking for the solution.

So there must be another (easier?) way. I found out 2 ways which I want to explain to you:

Option 1: Manually loading the Exchange Online MFA module from the Assembly Cache

Everything downloaded must be saved somewhere temporarily. Following the instructions on this site and some tests figured out that it works well:

http://blog.zomputer.hu/content/exchange-online-powershell-toebbfaktoros-azonositassal-mfa

The only thing you have to do in advance is to download this module one time on your computer. With other words: follow the instructions from MS I’ve mentioned above. Or get the DLL maybe from another computer.

Option 2: Find a good module with PowershellGet

You can find more information about PowershellGet here:

Install PowerShellGet on your computer

Make PowershellGet a trusted repository

Now you can find the available modules by using this command:

Find-Module *Exchange* | Select Name,Description | Format-Table -Wrap

The module “ExchangOnlineShell” supports MFA. So give it a try:

Install-Module ExchangeOnlineShell

Get-Command -Module ExchangeOnlineShell

The first command is for the installation, the second one to see the implemented commands. You see a command named “Connect-EOShell”. Issuing it opens the typical MFA prompt:

Connect-EOShell

ExchO1.png

For those of you that don’t like “download and run” unknown software because of security reasons: The module is installed to the path “C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineShell\2.0.2”. Here you can have a look at the script which are executed by the command. And as you can see, the script delivered script is containing the necessary DLL for the Exchange Online session šŸ™‚

Option 3 (the one you should prefer): Use ExoV2

ExoV2 is the newest PowerShell module for connecting to Exchange Online and available via PSGallery. You can easily install it:

Install-Module ExchangeOnlineManagement

… more about ExoV2 coming soon in another separete post.

Make PowershellGet a trusted repository

After installing PowershellGet you can make us of this powerful repository to find modules and scripts you need for your personal happiness or current tasks you have to do with PowerShell.

Click here to learn how to install PowerShellGet on your computer

After you’ve installed PowershellGet and start installing modules, you always see warnings like this:

AzurePS4

As the message is already telling you (yep, sometimes it is really a good idea to read the messages on the screen šŸ˜‰ ), you can trust the repo to avoid that message in future. For those who still don’t like reading PowerShell messages and prefer reading this article, here is the command:

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted

Install PowerShellGet on your computer

PowerShell is continuously evolving, that means that for some modules you don’t get an installer anymore. You have to use PowershellGet.

But how to get it? In the following table I’ve summarized the ways:

Scenario Install instructions
Windows 10
Windows Server 2016
Included in Windows Management Framework (WMF) 5.0. This is aready shipped and ready-to-go with the Windows OS
I want to upgrade to PowerShell 5
  1. Install the latest version of WMF
  2. Run the following command:
    Install-Module PowerShellGet -Force
I am running on a version of Windows with PowerShell 3 or PowerShell 4 Get the PackageManagement modules

  1. Run the following command:
    Install-Module PowerShellGet -Force

Read theĀ official articleĀ on docs.microsoft.com.

Now you can issue the following command to see how powerful this module is to find the module of your needs:

Get-Command -Module PowershellGet

Using a Mac or Linux? No problem. ReadĀ this articleĀ first to learn how to use PowerShell on your device.