From 83c29df043ce91d37a0c463ed854e78caba53984 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Fri, 27 Oct 2017 14:45:08 -0700 Subject: [fetchDependency] Fix compat with Powershell 2 --- scripts/fetchDependency.ps1 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1 index df03878eb..90de17717 100644 --- a/scripts/fetchDependency.ps1 +++ b/scripts/fetchDependency.ps1 @@ -8,6 +8,11 @@ function Test-Command($commandName) return [bool](Get-Command -Name $commandName -ErrorAction SilentlyContinue) } +function Test-CommandParameter($commandName, $parameterName) +{ + return (Get-Command $commandName).Parameters.Keys -contains $parameterName +} + function Test-Module($moduleName) { return [bool](Get-Module -ListAvailable -Name $moduleName) @@ -51,7 +56,16 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) $ProxyAuth = !$WC.Proxy.IsBypassed($url) if ($ProxyAuth) { - $ProxyCred = Get-Credential -Message "Enter credentials for Proxy Authentication" + if (Test-CommandParameter -commandName 'Get-Credential' -parameterName 'Message') + { + $ProxyCred = Get-Credential -Message "Enter credentials for Proxy Authentication" + } + else + { + "Enter credentials for Proxy Authentication" + $ProxyCred = Get-Credential + } + $PSDefaultParameterValues.Add("Start-BitsTransfer:ProxyAuthentication","Basic") $PSDefaultParameterValues.Add("Start-BitsTransfer:ProxyCredential",$ProxyCred) $WC.Proxy.Credentials=$ProxyCred -- cgit v1.2.3