我创建了一个 Azure Runbook PowerShell 脚本,该脚本使用 Get-PnPFile 存储来自 SharePoint 的文件,然后将其存储在 Azure 存储容器中。通常这是有效的。我理解它的方式是,在我的运行手册中,当我运行 Get-PnPFile 时,文件存储在虚拟运行手册本地驱动器上。但是,某些文件类型似乎没有被存储,例如:
- 可执行程序
- 压缩
- 文本
- rtf
- 点
- thmx
现在 .exe 我可以理解,但不是其他的。
错误消息是(当它尝试将文件上传到 Azure 存储时):
Set-AzStorageBlobContent : Can not find the specified file 'C:\Temp\qkamwig5.crx\2022.1.5\sites\abc\Documents IT Service\Template-CH-DE.rtf'.
At line:151 char:13
+ Set-AzStorageBlobContent -Container $container -File $fil ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-AzStorageBlobContent], ArgumentException
+ FullyQualifiedErrorId : ArgumentException,Microsoft.WindowsAzure.Commands.Storage.Blob.SetAzureBlobContentCommand
这是我的脚本的摘录,其中下载和上传发生:
try
{
#Download file
Get-PnPFile -Url $File.ServerRelativeUrl -Path $fileDownLoadPath -FileName $File.Name -AsFile
"Downloading file, Path: " + $fileDownLoadPath + " , File: " + $File.Name
#Upload file to storage
$container = "backups-testing";
$filepath = $fileDownLoadPath + "\" + $File.Name
"filepath:" + $filepath
Set-AzStorageBlobContent -Container $container -File $filepath -Blob $filepath -Force
#Delete temp file
Remove-Item $filepath
}
catch
{
$global:errorHappened = $true;
"An error happened in GetFolderFilesRecursively()"
$global:errorMessages.Add($error.Exception.Message + "`n");
$error.Exception.Message;
}
是否知道这些文件类型不能存储在该本地临时存储中,或者您认为问题出在什么地方?