背景
有时候我们想在未进行一些环境设置,或者工具使用者电脑中执行一段初始化脚本,为了简化使用者的理解成本,通常给使用者一段代码执行初始化电脑中的设置,尤其是这段初始化脚本比较长的时候。
脚本制作者
比如将需要执行的命令上传到 github,从 github 得到下载链接 https://raw.githubusercontent.com/xxx/xxx.cmd
脚本使用者
替换 DownloadURL 为预期 url,复制到 PowerShell / CMD 并运行
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::Tls12              $DownloadURL = 'https://xxxx.cmd'              $FilePath = "$env:TEMP\IAS.cmd"              try {              Invoke-WebRequest -Uri $DownloadURL -UseBasicParsing -OutFile $FilePath              
} catch {              Write-Error $_              Return              
}              if (Test-Path $FilePath) {              Start-Process $FilePath -Wait              $item = Get-Item -LiteralPath $FilePath              $item.Delete()              
}
步骤1-打开命令行 / CMD / PowerShell

步骤2-复制并选择粘贴
