private/test/Test-CommandCurl.ps1
|
function Test-CommandCurl { <# .SYNOPSIS Returns $true when curl.exe reports a version greater than zero. .NOTES Author: David Segura Company: Recast Software curl.exe ships with Windows 10 1803+ and is required by Install-MicrosoftWindowsAdk25H2, Install-MicrosoftWindowsAdk26H1, and Install-MicrosoftDeploymentToolkit for downloading installers. The explicit .exe suffix is used to avoid matching the PowerShell Invoke-WebRequest alias 'curl'. Dependencies: Module Functions: Install-MicrosoftDeploymentToolkit, Install-MicrosoftWindowsAdk25H2, Install-MicrosoftWindowsAdk26H1 Executables: curl.exe Windows Features: Windows ADK WinPE Addon #> [OutputType([bool])] param () $curlCommand = Get-Command -Name 'curl.exe' -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1 if ($null -eq $curlCommand) { return $false } try { $versionOutput = @(& $curlCommand.Path --version 2>$null) if ($LASTEXITCODE -ne 0 -or $versionOutput.Count -eq 0) { return $false } if ([string]$versionOutput[0] -notmatch '^curl\s+(?<Version>\d+(?:\.\d+){1,3})\b') { return $false } $curlVersion = $null if (-not [System.Version]::TryParse($Matches.Version, [ref]$curlVersion)) { return $false } return ($curlVersion -gt [System.Version]'0.0') } catch { return $false } } |