PowerShell【Do While、Do Until篇】

本文介绍了Shell脚本中三种不同的循环结构:while循环、do-while循环及until循环,并通过一个计数到10的例子展示了每种循环的具体用法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1 $num=0
2 while($num -le 10)
3 {
4 $num
5 $num+=1
6 }
1 $num=0
2 do
3 {
4 $num
5 $num+=1
6 }
7 while($num -le 10)

或是用until

1 $num=0
2 do
3 {
4 $num
5 $num+=1
6 }
7 until($num -gt 10)

 结果

0
1
2
3
4
5
6
7
8
9
10

 

转载于:https://www.cnblogs.com/XiaoCY/p/7100057.html

PS C:\Users\Administrator> # CurlTools.psm1 >> # ============== >> # 完整修复的模块代码 >> >> # 模块初始化块 >> $script:Config = $null >> $script:CurlPath = $null >> $script:ConfigDir = $null >> $script:ConfigPath = $null >> $script:ModuleInitialized = $false >> >> # 检测操作系统 >> function Get-Platform { >> if ($PSVersionTable.PSEdition -eq "Core") { >> if ($IsWindows) { "Windows" } >> elseif ($IsLinux) { "Linux" } >> elseif ($IsMacOS) { "macOS" } >> } else { >> if ($env:OS -like "Windows*") { "Windows" } >> elseif (Test-Path "/etc/os-release") { "Linux" } >> else { "macOS" } >> } >> } >> >> # 获取配置目录 >> function Get-ConfigDir { >> $platform = Get-Platform >> switch ($platform) { >> "Linux" { "$HOME/.config/curltools" } >> "macOS" { "$HOME/Library/Application Support/CurlTools" } >> default { "$env:APPDATA\CurlTools" } >> } >> } >> >> # 核心初始化函数 >> function Initialize-Module { >> try { >> # 设置配置目录 >> $script:Config极乐净土 >> if (-not (Test-Path $script:ConfigDir)) { >> New-Item -ItemType Directory -Path $script:ConfigDir -Force | Out-Null >> } >> $script:ConfigPath = Join-Path $script:ConfigDir "config.json" >> >> # 加载或创建配置 >> if (Test-Path $script:ConfigPath) { >> $script:Config = Get-Content $script:ConfigPath | ConvertFrom-Json >> } >> >> if (-not $script:Config) { >> $script:Config = [PSCustomObject]@{ >> CurlPath = $null >> LastUpdate = (Get-Date).ToString("o") >> AutoUpdate = $true >> } >> } >> >> # 查找或安装curl >> if (-not $script:Config.CurlPath -or -not (Test-Path $script:Config.CurlPath)) { >> $script:Config.CurlPath = Find-CurlPath >> } >> >> # 保存配置 >> $script:Config | ConvertTo-Json | Set-Content $script:ConfigPath -Force >> $script:CurlPath = $script:Config.CurlPath >> $script:ModuleInitialized = $true >> >> return $true >> } catch { >> Write-Warning "模块初始化失败: $_" >> return $false >> } >> } >> >> # 查找curl路径 >> function Find-CurlPath { >> $platform = Get-Platform >> $exeName = if ($platform -eq "Windows") { "curl.exe" } else { "curl" } >> >> # 检查系统PATH >> $pathCurl = Get-Command $exeName -ErrorAction SilentlyContinue >> if ($pathCurl) { >> return $pathCurl.Source | Split-Path >> } >> >> # 平台特定路径 >> $searchPaths = switch ($platform) { >> "Windows" { >> @( >> "C:\Windows\System32", >> "C:\Program Files\curl\bin", >> "${env:ProgramFiles}\Git\usr\bin" >> ) >> } >> "Linux" { @("/usr/bin", "/usr/local/bin") } >> "macOS" { @("/usr/local/bin", "/opt/homebrew/bin") } >> } >> >> foreach ($path in $searchPaths) { >> $fullPath = Join-Path $path $exeName >> if (Test-Path $fullPath) { >> return $path >> } >> } >> >> # 终极方案:自动安装 >> return Install-Curl >> } >> >> # curl安装函数 (修复Join-Path错误) >> function Install-Curl { >> $platform = Get-Platform >> try { >> if ($platform -eq "Windows") { >> $tempDir = [System.IO.Path]::GetTempPath() >> $curlZip = Join-Path $tempDir "curl.zip" # 修复:Join-Path 而不是 Join-PPath >> $curlUrl = "https://curl.se/windows/dl-8.8.0_5/curl-极乐净土-win64-mingw.zip" >> >> # 使用安全下载函数 >> Invoke-SecureDownload -Url $curlUrl -OutputPath $curlZip >> >> Expand-Archive $curlZip -DestinationPath $tempDir -Force >> >> # 验证安装目录是否存在 >> $installDir = Join-Path $tempDir "curl-8.8.0_5-win64-mingw\bin" >> if (-not (Test-Path $installDir)) { >> throw "安装目录不存在: $installDir" >> } >> >> return $installDir >> } >> else { >> if ($platform -eq "Linux") { >> if (Get-Command apt -ErrorAction SilentlyContinue) { >> Start-Process -Wait -FilePath "sudo" -ArgumentList "apt", "update" >> Start-Process -Wait -FilePath "sudo" -ArgumentList "apt", "install", "-y", "curl" >> } elseif (Get-Command yum -ErrorAction SilentlyContinue) { >> Start-Process -Wait -FilePath "sudo" -ArgumentList "yum", "install", "-y", "curl" >> } >> return "/usr/bin" >> } >> else { >> if (-not (Get-Command brew -ErrorAction SilentlyContinue)) { >> # 使用安全下载安装Homebrew >> $installScript = Join-Path $env:TEMP "brew_install.sh" >> Invoke-SecureDownload -Url "https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh" -OutputPath $installScript >> & "/bin/bash" $installScript >> } >> Start-Process -Wait -FilePath "brew" -ArgumentList "install", "curl" >> return "/usr/local/bin" >> } >> } >> } catch { >> throw "无法自动安装curl: $_" >> } >> } >> >> # ========== 公共函数 ========== >> function Get-CurlPath { >> Ensure-ModuleInitialized >> return $script:CurlPath >> } >> >> function Set-CurlPath { >> param( >> [Parameter(Mandatory=$true)] >> [ValidateScript({ >> # 允许设置不存在的路径(创建前) >> if (-not (Test-Path $_)) { >> Write-Warning "路径不存在,将在设置后创建: $_" >> $true >> } else { >> $true >> } >> })] >> [string]$Path >> ) >> >> Ensure-ModuleInitialized >> >> # 确保路径存在 >> if (-not (Test-Path $Path)) { >> New-Item -ItemType Directory -Path $Path -Force | Out-Null >> } >> >> $script:CurlPath = $Path >> $script:Config.CurlPath = $Path >> $script:Config | ConvertTo-Json | Set-Content $script:ConfigPath -Force >> Write-Host "已设置curl路径: $Path" -ForegroundColor Green >> >> # 验证路径下是否有curl可执行文件 >> $exeName = if ((Get-Platform) -eq "Windows") { "curl.exe" } else { "curl" } >> $curlExe = Join-Path $Path $exeName >> if (-not (Test-Path $curlExe)) { >> try { >> Write-Warning "路径 $Path 下找不到 $exeName,尝试自动安装..." >> $script:Config.CurlPath = Install-Curl >> $script:CurlPath = $script:Config.CurlPath >> $script:Config | ConvertTo-Json | Set-Content $script:ConfigPath -Force >> Write-Host "已自动安装curl到: $script:CurlPath" -ForegroundColor Green >> >> # 再次验证安装结果 >> $curlExe = Join-Path $script:CurlPath $exeName >> if (-not (Test-Path $curlExe)) { >> throw "自动安装后仍未找到curl可执行文件" >> } >> } catch { >> throw "自动安装失败: $_" >> } >> } >> } >> >> function Get-CurlVersion { >> Ensure-ModuleInitialized >> $exe = if ((Get-Platform) -eq "Windows") { "curl.exe" } else { "curl" } >> $curlExe = Join-Path $script:CurlPath $exe >> >> # 检查可执行文件是否存在 >> if (-not (Test-Path $curlExe)) { >> throw "在路径 $script:CurlPath 下找不到 $exe,请使用Set-CurlPath设置正确的路径或重新初始化模块" >> } >> >> & $curlExe --version | Select-Object -First 1 >> } >> >> function Invoke-SecureDownload { >> param( >> [Parameter(Mandatory=$true)] >> [string]$Url, >> >> [Parameter(Mandatory=$true)] >> [string]$OutputPath, >> >> [string]$ExpectedHash, >> [string]$HashAlgorithm = "SHA256" >> ) >> >> # 添加重试机制 >> $maxRetries = 3 >> $retryCount = 0 >> $success = $false >> >> do { >> try { >> Write-Verbose "下载文件: $Url (尝试 #$($retryCount + 1))" >> $ProgressPreference = 'SilentlyContinue' >> >> # 创建输出目录(如果不存在) >> $outputDir = [System.IO.Path]::GetDirectoryName($OutputPath) >> if (-not [string]::IsNullOrWhiteSpace($outputDir) -and -not (Test-Path $outputDir)) { >> New-Item -ItemType Directory -Path $outputDir -Force | Out-Null >> } >> >> # 下载文件 >> Invoke-WebRequest -Uri $Url -OutFile $OutputPath -UseBasicParsing -ErrorAction Stop >> >> # 验证文件是否成功下载 >> if (-not (Test-Path $OutputPath)) { >> throw "文件下载后未找到: $OutputPath" >> } >> >> # 验证哈希(如果提供) >> if (-not [string]::IsNullOrWhiteSpace($ExpectedHash)) { >> $actualHash = (Get-FileHash -Path $OutputPath -Algorithm $HashAlgorithm).Hash >> if ($actualHash -ne $Expected极乐净土 >> Remove-Item -Path $OutputPath -Force >> throw "文件哈希不匹配! 期望: $ExpectedHash, 实际: $actualHash" >> } >> } >> >> $success = $true >> return $OutputPath >> } >> catch { >> $retryCount++ >> if ($retryCount -ge $maxRetries) { >> # 清理部分下载的文件 >> if (Test-Path $OutputPath) { >> Remove-Item -Path $OutputPath -Force -ErrorAction SilentlyContinue >> } >> throw "下载失败: $($_.Exception.Message)" >> } >> >> # 随机延迟后重试 >> $retryDelay = Get-Random -Minimum 1 -Maximum 5 >> Write-Warning "下载失败,$retryDelay 秒后重试: $($_.Exception.Message)" >> Start-Sleep -Seconds $retryDelay >> } >> } while (-not $success) >> } >> >> # ========== 辅助函数 ========== >> function Ensure-ModuleInitialized { >> if (-not $script:ModuleInitialized) { >> if (-not (Initialize-Module)) { >> throw "模块未正确初始化" >> } >> } >> } >> >> # ========== 模块初始化 ========== >> # 尝试初始化但不强制 >> try { >> Initialize-Module | Out-Null >> Write-Verbose "CurlTools 模块初始化成功" >> } catch { >> Write-Warning "模块初始化错误: $_" >> } >> >> # ========== 函数导出 ========== >> # 导出公共函数 >> Export-ModuleMember -Function Get-CurlPath, Set-CurlPath, Get-CurlVersion, Invoke-SecureDownload >> 所在位置 行:266 字符: 21 + Remove-Item -Path $OutputPath -Force + ~~~~~~~~~~~ “if”语句中的表达式后面缺少右“)”。 所在位置 行:269 字符: 14 + } + ~ Try 语句缺少自己的 Catch 或 Finally 块。 所在位置 行:273 字符: 10 + } + ~ do 循环中缺少 whileuntil 关键字。 所在位置 行:289 字符: 28 + } while (-not $success) + ~ while 循环中缺少语句体。 所在位置 行:290 字符: 1 + } + ~ 表达式或语句中包含意外的标记“}”。 + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingEndParenthesisAfterStatement PS C:\Users\Administrator> # 创建模块目录 >> $moduleDir = "$env:USERPROFILE\Documents\WindowsPowerShell\Modules\CurlTools" >> New-Item -ItemType Directory -Path $moduleDir -Force | Out-Null >> >> # 保存模块代码 >> $moduleCode = @' >> # 将上面修复后的完整模块代码粘贴在这里 >> '@ >> >> Set-Content -Path "$moduleDir\CurlTools.psm1" -Value $moduleCode -Force >> >> # 创建模块清单 >> $manifest = @" >> @{ >> ModuleVersion = '1.7.0' >> RootModule = 'CurlTools.psm1' >> FunctionsToExport = @( >> 'Get-CurlPath', >> 'Set-CurlPath', >> 'Get-CurlVersion', >> 'Invoke-SecureDownload' >> ) >> CompatiblePSEditions = @('Desktop', 'Core') >> GUID = 'c0d1b1e1-1a2b-4c3d-8e4f-9a0b1c2d3e4f' >> Author = 'Your Name' >> Description = 'Powerful curl tools for PowerShell' >> } >> "@ >> >> Set-Content -Path "$moduleDir\CurlTools.psd1" -Value $manifest -Force >> >> # 重新加载模块 >> Remove-Module CurlTools -ErrorAction SilentlyContinue >> Import-Module CurlTools -Force -Verbose >> >> # 测试模块 >> if (Get-Module CurlTools) { >> Write-Host "CurlTools 模块安装成功!" -ForegroundColor Green >> >> # 测试基本功能 >> try { >> $curlPath = Get-CurlPath >> Write-Host "Curl路径: $curlPath" >> >> # 测试设置新路径 >> $newPath = Join-Path $env:TEMP "CurlTestPath" >> Set-CurlPath -Path $newPath >> >> $curlPath = Get-CurlPath >> Write-Host "新Curl路径: $curlPath" >> >> $version = Get-CurlVersion >> Write-Host "Curl版本: $version" >> >> # 测试下载功能 >> $testUrl = "https://raw.githubusercontent.com/PowerShell/PowerShell/master/README.md" >> $outputPath = "$env:TEMP\PowerShell_README.md" >> Invoke-SecureDownload -Url $testUrl -OutputPath $outputPath >> Write-Host "测试下载成功: $outputPath" -ForegroundColor Green >> } catch { >> Write-Warning "基本功能测试失败: $_" >> } >> } else { >> Write-Error "模块安装失败,请检查。" >> } >> 详细信息: 正在从路径“C:\Users\Administrator\Documents\WindowsPowerShell\Modules\CurlTools\CurlTools.psd1”加载模块。 详细信息: 正在从路径“C:\Users\Administrator\Documents\WindowsPowerShell\Modules\CurlTools\CurlTools.psm1”加载模块。 CurlTools 模块安装成功! 警告: 基本功能测试失败: 无法将“Get-CurlPath”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 PS C:\Users\Administrator> # 在模块根目录创建 Public 和 Private 文件夹 >> # Public/ 存放公共函数 >> # Private/ 存放内部函数 >> $publicFunctions = Get-ChildItem -Path "$PSScriptRoot\Public\*.ps1" >> $privateFunctions = Get-ChildItem -Path "$PSScriptRoot\Private\*.ps1" >> >> # 导入所有函数 >> foreach ($file in @($publicFunctions + $privateFunctions)) { >> . $file.FullName >> } >> >> # 只导出公共函数 >> Export-ModuleMember -Function $publicFunctions.BaseName >> Get-ChildItem : 找不到路径“C:\Public”,因为该路径不存在。 所在位置 行:4 字符: 20 + $publicFunctions = Get-ChildItem -Path "$PSScriptRoot\Public\*.ps1" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Public:String) [Get-ChildItem], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand Get-ChildItem : 找不到路径“C:\Private”,因为该路径不存在。 所在位置 行:5 字符: 21 + $privateFunctions = Get-ChildItem -Path "$PSScriptRoot\Private\*.ps1" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Private:String) [Get-ChildItem], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand 管道元素中的“.”后面的表达式生成无效的对象。该表达式必须生成命令名称、脚本块或 CommandInfo 对象。 所在位置 行:9 字符: 7 + . $file.FullName + ~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [],RuntimeException + FullyQualifiedErrorId : BadExpression Export-ModuleMember : 只能从模块内调用 Export-ModuleMember cmdlet。 所在位置 行:13 字符: 1 + Export-ModuleMember -Function $publicFunctions.BaseName + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (:) [Export-ModuleMember], InvalidOperationException + FullyQualifiedErrorId : Modules_CanOnlyExecuteExportModuleMemberInsideAModule,Microsoft.PowerShell.Commands.Expo rtModuleMemberCommand PS C:\Users\Administrator> function Write-ModuleLog { >> param( >> [string]$Message, >> [ValidateSet('Info', 'Warning', 'Error')] >> [string]$Level = 'Info' >> ) >> >> $logEntry = "[$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')] [$Level] $Message" >> $logPath = Join-Path $script:ConfigDir "curltools.log" >> >> # 创建日志目录 >> if (-not (Test-Path $script:ConfigDir)) { >> New-Item -ItemType Directory -Path $script:ConfigDir -Force | Out-Null >> } >> >> Add-Content -Path $logPath -Value $logEntry >> >> switch ($Level) { >> 'Info' { Write-Verbose $Message } >> 'Warning' { Write-Warning $Message } >> 'Error' { Write-Error $Message } >> } >> } >> PS C:\Users\Administrator> # 使用 .NET HttpClient 提高下载性能 >> function Invoke-FastDownload { >> param( >> [string]$Url, >> [string]$OutputPath >> ) >> >> try { >> $httpClient = [System.Net.Http.HttpClient]::new() >> $response = $httpClient.GetAsync($Url).Result >> $response.EnsureSuccessStatusCode() >> >> $fileStream = [System.IO.File]::Create($OutputPath) >> $response.Content.CopyToAsync($fileStream).Wait() >> $fileStream.Close() >> >> return $OutputPath >> } >> finally { >> if ($null -ne $httpClient) { >> $httpClient.Dispose() >> } >> } >> } >> PS C:\Users\Administrator> function Update-CurlTools { >> param([switch]$Force) >> >> try { >> $updateUrl = "https://api.github.com/repos/yourname/curltools/releases/latest" >> $response = Invoke-RestMethod $updateUrl >> $latestVersion = [Version]$response.tag_name >> $currentVersion = [Version](Get-Module CurlTools).Version >> >> if ($latestVersion -gt $currentVersion -or $Force) { >> Write-Host "正在更新模块到版本 $latestVersion" >> >> # 下载更新包 >> $updatePackage = Join-Path $env:TEMP "curltools-update.zip" >> $downloadUrl = $response.assets | >> Where-Object { $_.name -like "*.zip" } | >> Select-Object -First 1 -ExpandProperty browser_download_url >> >> Invoke-SecureDownload -Url $downloadUrl -OutputPath $updatePackage >> >> # 解压更新包 >> $extractPath = Join-Path $env:TEMP "curltools-update" >> Expand-Archive -Path $updatePackage -DestinationPath $extractPath -Force >> >> # 替换模块文件 >> $moduleDir = (Get-Module CurlTools).ModuleBase >> Get-ChildItem -Path $extractPath | Copy-Item -Destination $moduleDir -Recurse -Force >> >> # 重新加载模块 >> Remove-Module CurlTools -ErrorAction SilentlyContinue >> Import-Module CurlTools -Force >> >> Write-Host "模块已成功更新到版本 $latestVersion" -ForegroundColor Green >> } >> else { >> Write-Host "当前已是最新版本 ($currentVersion)" -ForegroundColor Cyan >> } >> } >> catch { >> Write-Error "更新失败: $_" >> } >> } >> PS C:\Users\Administrator> # 测试1:初始化测试 >> Remove-Module CurlTools -ErrorAction SilentlyContinue >> Import-Module CurlTools -Force >> $curlPath = Get-CurlPath >> Write-Host "初始Curl路径: $curlPath" -ForegroundColor Cyan >> >> # 测试2:路径设置测试 >> $newPath = Join-Path $env:TEMP "CurlTestPath" >> Set-CurlPath -Path $newPath >> $newPathActual = Get-CurlPath >> Write-Host "设置后的Curl路径: $newPathActual" -ForegroundColor Cyan >> >> # 测试3:版本获取测试 >> $version = Get-CurlVersion >> Write-Host "Curl版本: $version" -ForegroundColor Cyan >> >> # 测试4:下载功能测试 >> $testUrl = "https://raw.githubusercontent.com/PowerShell/PowerShell/master/README.md" >> $outputFile = Join-Path $env:TEMP "PowerShell_README.md" >> Invoke-SecureDownload -Url $testUrl -OutputPath $outputFile >> if (Test-Path $outputFile) { >> Write-Host "文件下载成功: $outputFile" -ForegroundColor Green >> } else { >> Write-Host "文件下载失败" -ForegroundColor Red >> } >> >> # 测试5:哈希验证下载 >> $expectedHash = (Get-FileHash -Path $outputFile -Algorithm SHA256).Hash >> $outputFile2 = Join-Path $env:TEMP "PowerShell_README_Verified.md" >> Invoke-SecureDownload -Url $testUrl -OutputPath $outputFile2 -ExpectedHash $expectedHash -HashAlgorithm SHA256 >> if (Test-Path $outputFile2) { >> Write-Host "带哈希验证的文件下载成功" -ForegroundColor Green >> } else { >> Write-Host "带哈希验证的文件下载失败" -ForegroundColor Red >> } >> Get-CurlPath : 无法将“Get-CurlPath”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径 ,请确保路径正确,然后再试一次。 所在位置 行:4 字符: 13 + $curlPath = Get-CurlPath + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-CurlPath:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException 初始Curl路径: Set-CurlPath : 无法将“Set-CurlPath”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径 ,请确保路径正确,然后再试一次。 所在位置 行:9 字符: 1 + Set-CurlPath -Path $newPath + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Set-CurlPath:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Get-CurlPath : 无法将“Get-CurlPath”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径 ,请确保路径正确,然后再试一次。 所在位置 行:10 字符: 18 + $newPathActual = Get-CurlPath + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-CurlPath:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException 设置后的Curl路径: Get-CurlVersion : 无法将“Get-CurlVersion”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包 括路径,请确保路径正确,然后再试一次。 所在位置 行:14 字符: 12 + $version = Get-CurlVersion + ~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-CurlVersion:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Curl版本: Invoke-SecureDownload : 无法将“Invoke-SecureDownload”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的 拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:20 字符: 1 + Invoke-SecureDownload -Url $testUrl -OutputPath $outputFile + ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Invoke-SecureDownload:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException 文件下载成功: E:\ai_temp\PowerShell_README.md Invoke-SecureDownload : 无法将“Invoke-SecureDownload”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的 拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:30 字符: 1 + Invoke-SecureDownload -Url $testUrl -OutputPath $outputFile2 -Expecte ... + ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Invoke-SecureDownload:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException 带哈希验证的文件下载失败 PS C:\Users\Administrator>
08-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值