如何查看PowerShell在线文件的文件藏书?

发布于 2025-01-23 06:53:23 字数 778 浏览 0 评论 0原文

好吧,我正在向Chris Titus Tech的终极Windows Toolkit提出拉扯请求,并且我想进行一些检查是否已更新。但是当我尝试跑步时:

Get-FileHash -Algorithm SHA256 https://raw.githubusercontent.com/fgclue/etcher/master/desktop.ini

它只是说:

Get-Filehash:找不到驱动器。不存在带有“ HTTPS”名称的驱动器。 我想让它看起来像这样:

$hash = Get-FileHash -Algorithm SHA256 URL
$chash = Get-FileHash -Algorithm SHA256 win10debloat.ps1

if ($hash -ne $chash){
     Write-Host "There is an update!"
     Write-Host "Update?"
     $Opt = Read-Host "Choice"     
     if (Opt -ne y){
          exit
     }
     if (Opt -ne yn){
          Start-Process "https://github.com/ChrisTitusTech/win10script/"
          Write-Host Please download the new version and close this windows.
     }
}

So well, I am making a pull request to Chris Titus Tech's Ultimate Windows Toolkit, and I wanna make something that checks if it's updated. But when I try running:

Get-FileHash -Algorithm SHA256 https://raw.githubusercontent.com/fgclue/etcher/master/desktop.ini

It just says:

Get-FileHash: Cannot find drive. A drive with the name 'https' does not exist.
And I want to make it look something like this:

$hash = Get-FileHash -Algorithm SHA256 URL
$chash = Get-FileHash -Algorithm SHA256 win10debloat.ps1

if ($hash -ne $chash){
     Write-Host "There is an update!"
     Write-Host "Update?"
     $Opt = Read-Host "Choice"     
     if (Opt -ne y){
          exit
     }
     if (Opt -ne yn){
          Start-Process "https://github.com/ChrisTitusTech/win10script/"
          Write-Host Please download the new version and close this windows.
     }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清风疏影 2025-01-30 06:53:23

您可以使用 webrespenseobject.rawcontentstream property 来自

$uri = 'https://raw.githubusercontent.com/fgclue/etcher/master/desktop.ini'
$req = Invoke-WebRequest $uri

# get the hash of the local file
$localHash = Get-FileHash myfilehere.ext -Algorithm SHA256
# get the remote file hash
$remoteHash = Get-FileHash -InputStream $req.RawContentStream -Algorithm SHA256
# and compare
if($localHash.Hash -eq $remoteHash.Hash) {
    'all good'
}
else {
    'should update here'
}

You can use the WebResponseObject.RawContentStream Property from the object outputted by Invoke-WebRequest to check if the remote file and the local file are the same:

$uri = 'https://raw.githubusercontent.com/fgclue/etcher/master/desktop.ini'
$req = Invoke-WebRequest $uri

# get the hash of the local file
$localHash = Get-FileHash myfilehere.ext -Algorithm SHA256
# get the remote file hash
$remoteHash = Get-FileHash -InputStream $req.RawContentStream -Algorithm SHA256
# and compare
if($localHash.Hash -eq $remoteHash.Hash) {
    'all good'
}
else {
    'should update here'
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文