PowerShell免费软件

最新消息,powershell,10多年的癌症被治好了!

 

问:癌症是指什么?

答:
powershell一直有个特性,它的管道会传递对象,请看:
'abc' | ForEach-Object {$_.toupper()} #返回ABC
它管道传递的是【字符串对象】。它会把管道左面的【内容】强行对象化。这导致【二进制数据经管道传输】有问题。
常见的问题场景是:管道下载图片损坏;压缩程序经管道传递损坏;二进制程序经管道import传递失败等。
例:

curl.exe https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png > a:\pscode\TEMP_2023\temp152\b.png

 


输出的图片,和在网页上另存为的图片,大小不一致。

 

关于修复的版本:psv7.4-preview4


上述命令,我在psv7.4-preview4中亲自试验。下载的文件和我用网页另存的文件,完全相同。
建议去官网,下载安装psv7.4-preview4:
https://github.com/PowerShell/PowerShell/releases


问:和哪些管道相关?


答: 和【|】,【>】相关。


问:低于psv7.4-preview4的老版本,怎么解决这个癌症的?


答:低于psv7.4-preview4,没解决这个癌症。
缓解方法是:在powershell中用cmd /c,或bash -c。如:

cmd /c "curl.exe https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png > a:\pscode\TEMP_2023\temp152\c.png"

 

关于10年:

https://github.com/PowerShell/PowerShell/issues/1908
上述问题提交于7年前,但何止7年。powershell没开源之前一直就有这个问题。甚至超过15年了!


相关链接:


https://github.com/PowerShell/PowerShell/issues/1908
https://github.com/MicrosoftDocs/PowerShell-Docs/issues/10134
https://github.com/PowerShell/PowerShell/pull/17857


这证明了,没有做不到,只有想不到。爱.net人,你要多给powershell贡献啊。别总想着白嫖。

---谢谢观看,完---

 

posted on 2023-06-30 18:12  PowerShell免费软件  阅读(223)  评论(0编辑  收藏  举报

导航