Last active
August 20, 2017 19:51
-
-
Save robv8r/485fb6a1d68e08fc732fefe4fab2e7f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
param () | |
function Install-DscPullServerPrerequisites { | |
[CmdletBinding()] | |
param () | |
# If NuGet isn’t installed, install it. | |
$localProvider = Get-PackageProvider -Name NuGet -ListAvailable -ErrorAction SilentlyContinue | |
$provider = Find-PackageProvider -Name NuGet | |
if ($localProvider -eq $null) { | |
Write-Host "Installing NuGet Provider." | |
$provider | Install-PackageProvider -Force | |
} else { | |
Write-Host "NuGet Provider already installed." | |
} | |
$modules = @('PowerShellGet', 'PsDscResources', 'xPSDesiredStateConfiguration') | |
$modules |% { | |
$moduleName = $_ | |
$module = Find-Module -Name $moduleName | |
$installed = Get-InstalledModule -Name $moduleName -ErrorAction SilentlyContinue | |
if ($installed -eq $null) { | |
Write-Host "Installing $moduleName" | |
$module | Install-Module -Force | |
} elseif ($installed[0].Version -lt $module.Version) { | |
Write-Host "Updating $moduleName" | |
$module | Update-Module -Force | |
} | |
Write-Host "Importing Module '$moduleName'" | |
Import-Module -Name $moduleName -RequiredVersion $module.Version | |
} | |
} | |
Install-DscPullServerPrerequisites |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment