PowerShell 中的 Azure 函数解压文件
Azure Function in PowerShell to untar file
我正在尝试将一些压缩成 .tar.gz 存档的文件转换成单个文件。为此,我需要先解压文件。
我已将 7z.exe 的副本加载到目录中,并且可以在本地调用命令
.z.exe x *.tar.gz
我已将 exe 与要执行的 运行.ps1 文件一起上传到 wwwroot/poshUntar 目录,然后使用在线编辑器我可以执行 powershell 脚本。我当然希望我的函数普遍失败,因为我没有提供变量值,但我不希望它在查找 7z.exe 文件
时出错
.z.exe : The term '.z.exe' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At D:\home\site\wwwroot\poshUntar\run.ps1:10 char:1
+ .z.exe x *.tar -o logs
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (.z.exe:String) [], CommandNot
FoundException
+ FullyQualifiedErrorId : CommandNotFoundException
在 PowerShell Azure 函数中调用可执行文件的正确方法是什么?
我相信你还需要上传7z.dll到wwwroot目录。
您可以尝试在您的脚本中使用以下代码段吗?
Set-Location D:\home\site\wwwroot\poshUntar
.z.exe x *.tar.gz
.z.exe x *.tar -ologs
我正在尝试将一些压缩成 .tar.gz 存档的文件转换成单个文件。为此,我需要先解压文件。
我已将 7z.exe 的副本加载到目录中,并且可以在本地调用命令
.z.exe x *.tar.gz
我已将 exe 与要执行的 运行.ps1 文件一起上传到 wwwroot/poshUntar 目录,然后使用在线编辑器我可以执行 powershell 脚本。我当然希望我的函数普遍失败,因为我没有提供变量值,但我不希望它在查找 7z.exe 文件
时出错.z.exe : The term '.z.exe' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At D:\home\site\wwwroot\poshUntar\run.ps1:10 char:1
+ .z.exe x *.tar -o logs
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (.z.exe:String) [], CommandNot
FoundException
+ FullyQualifiedErrorId : CommandNotFoundException
在 PowerShell Azure 函数中调用可执行文件的正确方法是什么?
我相信你还需要上传7z.dll到wwwroot目录。
您可以尝试在您的脚本中使用以下代码段吗?
Set-Location D:\home\site\wwwroot\poshUntar
.z.exe x *.tar.gz
.z.exe x *.tar -ologs