Core/ThirdPartyDependencies-Module.psm1
$ErrorActionPreference = "Stop" function ConfigureChoco { try { choco | Out-Null choco upgrade chocolatey --limitoutput --confirm | Out-Null } catch { Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression | Out-Null } choco feature enable -n allowGlobalConfirmation | Out-Null RefreshEnvironment } function ConfigurePSGallery { $latestNuget = Find-PackageProvider -Name "NuGet" -Force $installedNuget = Get-PackageProvider -Name "Nuget" -ListAvailable | Select-Object -First 1 if ($latestNuget.version -gt $installedNuget.version) { Install-PackageProvider -Name "NuGet" -Source "PSGallery" -RequiredVersion $latestNuget.version -Force | Out-Null } Import-PackageProvider -Name "Nuget" -RequiredVersion $latestNuget.version -Force | Out-Null # Ensure Trusted, so that users are not prompted before installing modules from that source. Set-PSRepository -Name PSGallery -InstallationPolicy Trusted $latestPSGet = Find-PackageProvider -Name "PowerShellGet" $installedPSGet = Get-PackageProvider -Name "PowerShellGet" -ListAvailable | Select-Object -First 1 if ($latestPSGet.version -gt $installedPSGet.version) { Install-PackageProvider -Name "PowerShellGet" -Source "PSGallery" -RequiredVersion $latestPSGet.version -Force | Out-Null } Import-PackageProvider -Name "PowerShellGet" -RequiredVersion $latestPSGet.version -Force | Out-Null } function GetRequiredMaxSIFVersion { if($null -ne $SAFConfiguration.sitecore.version) { if ($SAFConfiguration.sitecore.version.Contains("9.0")) { return $SAFSitecore90SIFMaxVersion } if ($SAFConfiguration.sitecore.version.Contains("9.1")) { return $SAFSitecore91SIFMaxVersion } } return $SAFSitecore90SIFMaxVersion } function ImportSIF { EnableIISAdministration $repositoryURL = "https://sitecore.myget.org/F/sc-powershell/api/v2" $repositoryName = "SitecoreGallery" $existing = Get-PSRepository -Name $repositoryName -ErrorAction Ignore if ($null -eq $existing) { Register-PSRepository -Name $repositoryName -SourceLocation $repositoryURL -InstallationPolicy Trusted } # Ensure Trusted, so that users are not prompted before installing modules from that source. Set-PSRepository -Name $repositoryName -InstallationPolicy Trusted $sifVersion = GetRequiredMaxSIFVersion if (!(Get-Module -Name SitecoreInstallFramework -ListAvailable | Where-Object {$_.Version -lt $sifVersion})) { Install-Module -Name SitecoreInstallFramework -MaximumVersion $sifVersion -Repository $repositoryName -AllowClobber -Force } Get-Module -Name SitecoreInstallFramework | Remove-Module -Force Import-Module -Name SitecoreInstallFramework -MaximumVersion $sifVersion -Force -Global } Export-ModuleMember -Function "ConfigureChoco" Export-ModuleMember -Function "ConfigurePSGallery" Export-ModuleMember -Function "ImportSIF" |