在 Windows Server 2016 上使用本机 tar PowerShell cmdlet
Use native tar PowerShell cmdlet on Windows Sever 2016
我有一个 PowerShell 脚本,是我使用 PowerShell 5.1.17763.771 在 Windows 10 设备上编写的。它获取 .tgz 文件的路径,将其解压缩,并将提取的文件夹放在另一个路径中。它使用一两年前添加到 PowerShell 的内置 tar
cmdlet 来执行此操作。它在我的机器上完全按照预期工作。
当 运行 在 Windows Server 2016 上使用相同的脚本时,它失败并指出 tar
是无法识别的 cmdlet。此服务器上的 PowerShell 版本 运行ning 是 5.1.14393.3471。我在服务器上每 Windows 更新一次 运行。如何让本机 tar
cmdlet 在 Windows Server 2016 上运行?是否缺少我缺少的 PowerShell 更新?我可以安装 Microsoft 创建的包含 tar
cmdlet 的模块吗?
tar
是 外部可执行文件 、tar.exe
,而不是 cmdlet,而 PowerShell 可以 调用 它,它与 PowerShell 无关。
在 Windows 10(自版本 1803 起),可以在 C:\WINDOWS\system32\tar.exe
.
找到
This blog post from 2017 announced the availability of tar.exe
, alongside curl.exe
in the context of containers. tar.exe
is compiled from the libarchive sources (BSD-licensed); build instructions for Windows.
在 Windows 服务器上,tar.exe
和 curl.exe
似乎首先包含在 Windows 服务器 2019 中。
尽管 Windows 10 有 tar 和 curl 的报告...它们不存在于 Windows 2016 数据中心...并尝试下载 tar来自 GNU... 是一个压缩的 tar 文件,因此也无济于事。
我有一个 PowerShell 脚本,是我使用 PowerShell 5.1.17763.771 在 Windows 10 设备上编写的。它获取 .tgz 文件的路径,将其解压缩,并将提取的文件夹放在另一个路径中。它使用一两年前添加到 PowerShell 的内置 tar
cmdlet 来执行此操作。它在我的机器上完全按照预期工作。
当 运行 在 Windows Server 2016 上使用相同的脚本时,它失败并指出 tar
是无法识别的 cmdlet。此服务器上的 PowerShell 版本 运行ning 是 5.1.14393.3471。我在服务器上每 Windows 更新一次 运行。如何让本机 tar
cmdlet 在 Windows Server 2016 上运行?是否缺少我缺少的 PowerShell 更新?我可以安装 Microsoft 创建的包含 tar
cmdlet 的模块吗?
tar
是 外部可执行文件 、tar.exe
,而不是 cmdlet,而 PowerShell 可以 调用 它,它与 PowerShell 无关。
在 Windows 10(自版本 1803 起),可以在 C:\WINDOWS\system32\tar.exe
.
This blog post from 2017 announced the availability of tar.exe
, alongside curl.exe
in the context of containers. tar.exe
is compiled from the libarchive sources (BSD-licensed); build instructions for Windows.
在 Windows 服务器上,tar.exe
和 curl.exe
似乎首先包含在 Windows 服务器 2019 中。
尽管 Windows 10 有 tar 和 curl 的报告...它们不存在于 Windows 2016 数据中心...并尝试下载 tar来自 GNU... 是一个压缩的 tar 文件,因此也无济于事。