【发布时间】:2021-12-14 01:06:43
【问题描述】:
PowerShell 的Invoke-WebRequest 提供-OutFile,将响应主体写入到文件中。
@('Global/JetBrains','Global/Vim','Global/VisualStudioCode','Global/macOS','Python','Terraform') `
| ForEach-Object {
Invoke-WebRequest -UseBasicParsing -Outfile "$Env:USERPROFILE/.gitignore" -Uri `
"https://raw.githubusercontent.com/github/gitignore/master/$PSItem.gitignore"
}
我想追加到文件$Env:USERPROFILE/.gitignore,似乎Invoke-WebRequest 不支持这个。我该怎么做?
另外,关于如何使这个 PowerShell 脚本更具可读性/简洁性的任何提示?
注意:我使用的是 PowerShell 版本 5.1.19041.1237。
【问题讨论】:
标签: powershell append invoke-webrequest