I had a very interesting workshop with administrators and IT guys from a customer (a customer of a partner to be correct). One of the very first questions, like so often, was: Is it possible to install all PowerShell requirements for Office 365 with a single command?

The easy answer is: No, it is not… Sorry!
The true, and longer answer must be: There are a lot of scripts available on Technet, or GitHub (and elsewhere) that can do the job for you.

However, we then started to build an individual script that can do exactly that: Download and install all required PowerShell Modules for Office 365.

We defined the following requirements:

  • Do each step in an separate function (Agreed, that makes the code more complex)
  • Use an external parameter File (that contains the URL)
  • Make it robust (e.g. implement some error handling)

Here is what we created:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
[
  {
    "Name": "Windows Azure Active Directory module",
    "URL": "https://bposast.vo.msecnd.net/MSOPMW/Current/amd64/AdministrationConfig-EN.msi"
  },
  {
    "Name": "Sign in Assistant (SIA)",
    "URL": "http://download.microsoft.com/download/5/0/1/5017D39B-8E29-48C8-91A8-8D0E4968E6D4/en/msoidcli_64.msi"
  },
  {
    "Name": "Skype for Business Module",
    "URL": "https://download.microsoft.com/download/2/0/5/2050B39B-4DA5-48E0-B768-583533B42C3B/SkypeOnlinePowershell.exe"
  },
  {
    "Name": "SharePoint Module",
    "URL": "https://download.microsoft.com/download/0/2/E/02E7E5BA-2190-44A8-B407-BC73CA0D6B87/sharepointonlinemanagementshell_6112-1200_x64_en-us.msi"
  }
]

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
#requires -Version 4.0 -RunAsAdministrator

<#
		.SYNOPSIS
		Install Office 365 PowerShell Requirements

		.DESCRIPTION
		Install all Office 365 PowerShell Requirements

		.PARAMETER DownloadDirectory
		The target Directory for all Downloads

		.PARAMETER ConfigFile
		The JSON file that contain the URLs to process

		.EXAMPLE
		PS C:\> Get-Office365PSModules.ps1

		.EXAMPLE
		PS C:\> Get-Office365PSModules.ps1 -ConfigFile 'd:\config\PSModules.json'

		.EXAMPLE
		PS C:\> Get-Office365PSModules.ps1 -DownloadDirectory 'd:\Downloads'

		.EXAMPLE
		PS C:\> Get-Office365PSModules.ps1 -DownloadDirectory 'd:\Downloads' -ConfigFile 'd:\config\PSModules.json'

		.NOTES
		This file was created during a customer workshop. It might need to get a bit more care, but it works.

		We added the a minor feature to get the Hash of the downloaded file. The base function (Get-FileHash)
		needs PowerShell 4.0, the Required statement is updated for that. If you want to use it with PowerShell 3,
		just remove that function (Get-TargetFileHash) and it will work fine on PowerShell 3.0 again.
		We decided to implement this for one of the future features that they would like to have: Logging

		TODO: Transfer all the function to a basic script is the next step. Not that we must, just as part of the education 😉
		ISSUE: Documentation needs to be created (MAML)
#>

<#
		Copyright (c) 2017, Joerg Hochwald
		All rights reserved.

		Redistribution and use in source and binary forms, with or without modification,
		are permitted provided that the following conditions are met:
		1. 	Redistributions of source code must retain the above copyright notice, this
		list of conditions and the following disclaimer.
		2. 	Redistributions in binary form must reproduce the above copyright notice,
		this list of conditions and the following disclaimer in the documentation and/or
		other materials provided with the distribution.
		3. 	Neither the name of the copyright holder nor the names of its contributors may
		be used to endorse or promote products derived from this software without specific
		prior written permission.

		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
		OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
		AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
		IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
		INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
		OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
		CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
		NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
		THE POSSIBILITY OF SUCH DAMAGE.

		By using the Software, you agree to the License, Terms and Conditions above!
#>

param
(
	[Parameter(Position = 1)]
	[ValidateNotNullOrEmpty()]
	[string]$DownloadDirectory = 'C:\scripts\PowerShell\Download',
	[Parameter(Position = 1)]
	[string]$ConfigFile = 'Get-Office365PSModules.json'
)

#region Helpers
function Test-DotNETVersion
{
	<#
			.SYNOPSIS
			Check if a given Version is installed

			.DESCRIPTION
			Check if a given Version is installed on the local system.

			.PARAMETER DotNETVersion
			Display String for the Version. e.g. 4.5.2

			.PARAMETER DotNETRelease
			The DotNET Release Number. This is the Number that we try to find in the Registry.

			.EXAMPLE
			PS C:\> Test-DotNETVersion -DotNETVersion '4.5.2' -DotNETRelease '379893'

			.NOTES
			TODO: We need to find a better way to do that.

			You can Download it here: http://download.microsoft.com/download/E/2/1/E21644B5-2DF2-47C2-91BD-63C560427900/NDP452-KB2901907-x86-x64-AllOS-ENU.exe
			You might want to Download the latest (e.g. 4.6.x) instead, 4.5.2 is now the minimum!
	#>

	param
	(
		[Parameter(Mandatory = $true,
				ValueFromPipeline = $true,
				Position = 1,
		HelpMessage = 'Display String for the Version. e.g. 4.5.2')]
		[ValidateNotNullOrEmpty()]
		[string]$DotNETVersion,
		[Parameter(Mandatory = $true,
				ValueFromPipeline = $true,
				Position = 2,
		HelpMessage = 'The DotNET Release Number. This is the Number that we try to find in the Registry.')]
		[ValidateNotNullOrEmpty()]
		[String]$DotNETRelease
	)

	PROCESS
	{
		$DotNETInfo = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' -Name 'Release')
		if ($DotNETInfo.Release -lt $DotNETRelease)
		{
			Write-Error -Message "Microsoft DotNET $DotNETVersion, or newer, needs to be installed!" -ErrorAction Stop
			exit 1
		}
		else
		{
			Write-Verbose -Message "Microsoft DotNET $DotNETVersion, or newer, is installed."
		}
	}
}

function Test-TargetDirectory
{
	<#
			.SYNOPSIS
			Check if the target directory exists

			.DESCRIPTION
			We check if the target directory for the download exists. If nor, we just create it for more convenience.

			.PARAMETER CheckTarget
			The target Directory to check/create

			.EXAMPLE
			PS C:\> Test-TargetDirectory -CheckTarget 'C:\scripts\PowerShell\Download'
	#>

	param
	(
		[Parameter(Mandatory = $true,
				ValueFromPipeline = $true,
				Position = 1,
		HelpMessage = 'The target Directory to check/create')]
		[ValidateNotNullOrEmpty()]
		[string]$CheckTarget
	)

	PROCESS
	{
		if (Test-Path -Path $CheckTarget)
		{
			Write-Verbose -Message "$CheckTarget already exists..."
		}
		else
		{
			try
			{
				$null = (New-Item -Path $CheckTarget -ItemType Directory -Force -Confirm:$false -ErrorAction Stop -WarningAction SilentlyContinue)
			}
			catch
			{
				Write-Error -Message "Sorrry, unable to create $CheckTarget" -ErrorAction Stop
				exit 1
			}
		}
	}
}

function Get-TargetFile
{
	<#
			.SYNOPSIS
			Download a File from Microsoft

			.DESCRIPTION
			This function downloads a file from a given URL by using System.Net.WebClient.

			.PARAMETER SourceFile
			The URL for the File that you would like to download. The URL must contain the Filename!

			.PARAMETER TargetDirectory
			The target Directory for the Download.

			.PARAMETER proxy
			Enable basic proxy Support

			.EXAMPLE
			PS C:\> Get-TargetFile -SourceFile 'https://bposast.vo.msecnd.net/MSOPMW/Current/amd64/AdministrationConfig-EN.msi' -TargetDirectory 'C:\scripts\PowerShell\Download'

			.NOTES
			If you do NOT like the System.Net.WebClient method, you might change this to Invoke-WebRequest or use Start-BitsTransfer (Needs the BITS PowerShell Module)

			Proxy Support: This is really just a quick example and you might need to adopt and tweak it a bit to fit to you needs
	#>

	param
	(
		[Parameter(Mandatory = $true,
				ValueFromPipeline = $true,
				Position = 1,
		HelpMessage = 'The URL for the File that you would like to download.')]
		[ValidateNotNullOrEmpty()]
		[string]$SourceFile,
		[Parameter(Mandatory = $true,
				ValueFromPipeline = $true,
				Position = 2,
		HelpMessage = 'The target Directory for the Download.')]
		[string]$TargetDirectory,
		[switch]$proxy
	)

	BEGIN
	{
		# Extract the Name of the File from the URL
		[string]$TargetFile = ($SourceFile.Substring($SourceFile.LastIndexOf('/') + 1))
		[string]$DLTarget = ($TargetDirectory + '\' + $TargetFile)

		# Just a messure a bit
		$start_time = (Get-Date)
	}

	PROCESS
	{
		try
		{
			if ($proxy)
			{
				<#
						This quick example use the system configuration (same as IE) for Proxy Support.
						In the example we use you actual credentials to authenticate at the proxy.

						This is really just a quick example and you might need to adopt and tweak it a bit to fit to you needs
				#>

				# use the setting from "Internet Option" e.g. the same as IE/Edge
				$proxy = [Net.WebRequest]::GetSystemWebProxy()

				# The Proxy credentials, see bellow
				$proxy.Credentials = [Net.CredentialCache]::DefaultCredentials

				# We need to create the object now, cause we modify it then
				$request = New-Object -TypeName System.Net.WebCLient

				# There are proxy credentials only, has nothing to to with download credentials
				$request.UseDefaultCredentials = $true
				$request.Proxy.Credentials = $request.Credentials

				# Fire the request (via the proxy of cause)
				$request.DownloadFile($SourceFile, $DLTarget)
			}
			else
			{
				# No proxy needed, we do it native
				$null = ((New-Object -TypeName System.Net.WebClient).DownloadFile($SourceFile, $DLTarget))
			}
		}
		catch
		{
			Write-Error -Message "Unable to Download $TargetFile to $TargetDirectory"
		}
	}

	END
	{
		# Nothing fancy, just here to meassure stuff
		Write-Verbose -Message "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"
	}
}

function Test-TargetFile
{
	<#
			.SYNOPSIS
			Check if we have downloaded the file already

			.DESCRIPTION
			We check if we downloaded the file already in the past, you can force the download... just in case

			.PARAMETER SourceFile
			The URL for the File that you would like to check. The URL must contain the Filename!

			.PARAMETER TargetDirectory
			The target Directory for the Download. This is the place where we check if the source file exists.

			.PARAMETER force
			If you use this switch, we delete the file and enforce the download.

			.EXAMPLE
			PS C:\> Test-TargetFile -SourceFile 'https://bposast.vo.msecnd.net/MSOPMW/Current/amd64/AdministrationConfig-EN.msi' -TargetDirectory 'C:\scripts\PowerShell\Download'

			.EXAMPLE
			PS C:\> Test-TargetFile -SourceFile 'https://bposast.vo.msecnd.net/MSOPMW/Current/amd64/AdministrationConfig-EN.msi' -TargetDirectory 'C:\scripts\PowerShell\Download' -Force

			.NOTES
			The FORCE Switch deletes the existing file without any further interaction.
	#>

	param
	(
		[Parameter(Mandatory = $true,
				ValueFromPipeline = $true,
				Position = 1,
		HelpMessage = 'The URL for the File that you would like to check.')]
		[ValidateNotNullOrEmpty()]
		[string]$SourceFile,
		[Parameter(Mandatory = $true,
				ValueFromPipeline = $true,
				Position = 2,
		HelpMessage = 'The target Directory for the Download.')]
		[string]$TargetDirectory,
		[switch]$force
	)

	BEGIN
	{
		# Extract the Name of the File from the URL
		[string]$TargetFile = ($SourceFile.Substring($SourceFile.LastIndexOf('/') + 1))

		# Build the target (Directory + Filename)
		[string]$CheckTarget = ($TargetDirectory + '\' + $TargetFile)

		if ($force)
		{
			if (Test-Path -Path $CheckTarget)
			{
				Write-Verbose -Message "Remove File: $TargetFile"
				$null = (Remove-Item -Path $CheckTarget -Force -Confirm:$false -ErrorAction Stop -WarningAction SilentlyContinue)
			}
		}
	}

	PROCESS
	{
		if (Test-Path -Path $CheckTarget)
		{
			Write-Verbose -Message "File: $TargetFile exists."
		}
		else
		{
			# Get the given File
			try
			{
				Get-TargetFile -SourceFile $SourceFile -TargetDirectory $TargetDirectory -ErrorAction Stop -WarningAction SilentlyContinue
			}
			catch
			{
				Write-Error -Message "Unable to Download $TargetFile to $TargetDirectory."
			}
		}
	}
}

function Get-TargetFileHash
{
	<#
			.SYNOPSIS
			Wrapper for Get-FileHash

			.DESCRIPTION
			Wrapper for Get-FileHash to get (and just that) get the hash info of the newly downloaded File.

			.PARAMETER SourceFile
			The URL for the File that you would like to check. The URL must contain the Filename!

			.PARAMETER TargetDirectory
			The target Directory for the Download. This is the place where we check if the source file exists.

			.EXAMPLE
			PS C:\> Get-TargetFileHash -SourceFile 'https://bposast.vo.msecnd.net/MSOPMW/Current/amd64/AdministrationConfig-EN.msi' -TargetDirectory 'C:\scripts\PowerShell\Download'

			.NOTES
			Just a minor helper function
	#>

	param
	(
		[Parameter(Mandatory = $true,
				ValueFromPipeline = $true,
				Position = 1,
		HelpMessage = 'The URL for the File that you would like to check.')]
		[ValidateNotNullOrEmpty()]
		[string]$SourceFile,
		[Parameter(Mandatory = $true,
				ValueFromPipeline = $true,
				Position = 2,
		HelpMessage = 'The target Directory for the Download.')]
		[string]$TargetDirectory
	)

	BEGIN
	{
		# Extract the Name of the File from the URL
		[string]$TargetFile = ($SourceFile.Substring($SourceFile.LastIndexOf('/') + 1))

		# Build the target (Directory + Filename)
		[string]$CheckTarget = ($TargetDirectory + '\' + $TargetFile)
	}

	PROCESS
	{
		if (Test-Path -Path $CheckTarget)
		{
			try
			{
				$FileHash = ((Get-FileHash -Path $CheckTarget -ErrorAction Stop -WarningAction SilentlyContinue).Hash)
				Write-Verbose -Message "The Hash of $TargetFile is $FileHash"
			} catch
			{
				Write-Warning -Message "Unable to get the Hash Info for $CheckTarget"
			}
		}
		else
		{
			Write-Warning -Message "Unable to find $CheckTarget"
		}
	}
}

function Read-ConfigFile
{
	<#
			.SYNOPSIS
			Read the JSON Config

			.DESCRIPTION
			Read the JSON based Configuration File that contains all the Files we would like to process.

			.PARAMETER config
			Fully-Qualified Name of the JSON Configuration File.

			.EXAMPLE
			PS C:\> Read-ConfigFile -config 'd:\config\PSModules.json'

			.NOTES
			You might want to use an CSV or XML File... I like JSON more!
	#>

	param
	(
		[Parameter(Mandatory = $true,
				ValueFromPipeline = $true,
				Position = 1,
		HelpMessage = 'Fully-Qualified Name of the JSON Configuration File.')]
		[ValidateNotNullOrEmpty()]
		[string]$config
	)

	BEGIN
	{
		if (-not (Test-Path -Path $config))
		{
			Write-Error -Message 'Unable to find the configuration File. Please check...' -ErrorAction Stop
			exit 1
		}
	}

	PROCESS
	{
		try
		{
			# Read the JSON File
			$JSONInfo = ((Get-Content -Path $config) -join "`n" | ConvertFrom-Json -ErrorAction Stop -WarningAction SilentlyContinue)

			# Dump it
			Write-Output -InputObject $JSONInfo -NoEnumerate
		}
		catch
		{
			Write-Error -Message 'Unable to process the configuration File. Please check...' -ErrorAction Stop
			exit 1
		}
	}
}

function Install-TargetModule
{
	<#
			.SYNOPSIS
			Install the given Module

			.DESCRIPTION
			Install the given PowerShell Module

			.PARAMETER SourceFile
			A description of the SourceFile parameter.

			.PARAMETER TargetDirectory
			A description of the TargetDirectory parameter.

			.EXAMPLE
			PS C:\> Install-TargetModule -SourceFile 'https://bposast.vo.msecnd.net/MSOPMW/Current/amd64/AdministrationConfig-EN.msi' -TargetDirectory 'C:\scripts\PowerShell\Download'

			.NOTES
			TODO: Check if installed?
			TODO: Logging for the installation?
	#>

	param
	(
		[Parameter(Mandatory = $true,
				ValueFromPipeline = $true,
				Position = 1,
		HelpMessage = 'The URL for the File that you would like to process.')]
		[ValidateNotNullOrEmpty()]
		[string]$SourceFile,
		[Parameter(Mandatory = $true,
				ValueFromPipeline = $true,
				Position = 2,
		HelpMessage = 'The target Directory for the Download.')]
		[ValidateNotNullOrEmpty()]
		[string]$TargetDirectory
	)

	BEGIN
	{
		# Extract the Name of the File from the URL
		[string]$TargetFileName = ($SourceFile.Substring($SourceFile.LastIndexOf('/') + 1))

		# Build the target (Directory + Filename)
		[string]$FQTarget = ($TargetDirectory + '\' + $TargetFileName)

		# Helper to get the Extension
		$Extension = [IO.Path]::GetExtension($TargetFileName)
	}

	PROCESS
	{
		if ($Extension -eq '.exe')
		{
			# Process the EXE based installer
			try
			{
				$null = (Start-Process -FilePath $FQTarget -ArgumentList '/quiet /norestart' -Wait -ErrorAction Stop -WarningAction SilentlyContinue)
			}
			catch
			{
				Write-Error -Message "Unable to install $TargetFileName" -ErrorAction Stop
			}
		}
		elseif ($Extension -eq '.msi')
		{
			# Process the MSI Installer
			try
			{
				$null = (Start-Process -FilePath msiexec.exe -ArgumentList "/i $FQTarget /quiet /passive /norestart" -Wait -ErrorAction Stop -WarningAction SilentlyContinue)
			}
			catch
			{
				Write-Error -Message "Unable to install $TargetFileName" -ErrorAction Stop
			}
		}
		else
		{
			# Whoops
			Write-Error -Message "Unable to process $TargetFileName" -ErrorAction Stop
		}
	}
}

function Invoke-ProcessModule
{
	<#
			.SYNOPSIS
			Wrapper function to process each File

			.DESCRIPTION
			Just a wrapper to call all related functions

			.PARAMETER SourceFile
			The URL for the File that you would like to process. The URL must contain the Filename!

			.PARAMETER TargetDirectory
			The target Directory for the Download. This is the place where we check if the source file exists.

			.EXAMPLE
			PS C:\> Invoke-ProcessTarget -SourceFile 'https://bposast.vo.msecnd.net/MSOPMW/Current/amd64/AdministrationConfig-EN.msi' -TargetDirectory 'C:\scripts\PowerShell\Download'

			.NOTES
			Just a wrapper around all our functions
	#>

	param
	(
		[Parameter(Mandatory = $true,
				ValueFromPipeline = $true,
				Position = 1,
		HelpMessage = 'The URL for the File that you would like to process.')]
		[ValidateNotNullOrEmpty()]
		[string]$SourceFile,
		[Parameter(Mandatory = $true,
				ValueFromPipeline = $true,
				Position = 2,
		HelpMessage = 'The target Directory for the Download.')]
		[ValidateNotNullOrEmpty()]
		[string]$TargetDirectory
	)

	PROCESS
	{
		# Test if we have the File and download it if not
		Test-TargetFile -SourceFile $SourceFile -TargetDirectory $DownloadDirectory

		# Get the Hash (For later logging feature)
		Get-TargetFileHash -SourceFile $SourceFile -TargetDirectory $DownloadDirectory

		# Install
		Install-TargetModule -SourceFile $SourceFile -TargetDirectory $DownloadDirectory
	}
}
#endregion Helpers

<#
		Now we execute our functions
#>

# Check if we have DotNET 4.5.2 installed. Might require 4.6 soon!
Test-DotNETVersion -DotNETVersion '4.5.2' -DotNETRelease '379893'

# Check if the Target exists
Test-TargetDirectory -CheckTarget $DownloadDirectory

# Get the Module Infos and URL
$AllModule = (Read-ConfigFile -config $ConfigFile)

# Process each Module
foreach($Module in $AllModule)
{
	[string]$ModuleName = ($Module.Name)
	[string]$ModuleURL  = ($Module.URL)

	Write-Output -InputObject "Processing: $ModuleName"
	Invoke-ProcessModule -SourceFile $ModuleURL -TargetDirectory $DownloadDirectory
}

If you can’t see the Source, your browser don’t support Java scripts (Shame on you, by the way) and you need to open the Gist directly on GitHub.

Feel free to use this sample and please adopt it if something is not like you want it. That is the main reason I decided to publish this.