Power Automate (MS Flow):Extract attachment from SharePoint list using

preview_player
Показать описание
# Change to desired location
# This is the folder with the XML
$inputFolder = 'C:\Users\xyz\Folder''
# This is the folder where the attachments will be saved
$attachFolder = 'C:\Users\xyz\New folder'
#Count the number of files
$counter = 0
# Get all the XML files from the Input Folder
Get-ChildItem $inputFolder -Filter *.xml | `
Foreach-Object{
[ xml ] $fileContents = Get-Content -Path $_.FullName
$fileName = $_.Name
if (($base64) -and ($base64 -ne "") -and ($base64.Length -ne $null))
{
try
{
# get the bytes
$bytes = [Convert]::FromBase64String($base64)
$memStream = New-Object System.IO.MemoryStream (,$bytes)
$binaryReader = New-Object System.IO.BinaryReader $memStream
$header = New-Object Byte[] 16
$header = $binaryReader.ReadBytes($header.Length)
# Attachment Size
$attachSize = [int]$binaryReader.ReadUInt32()
# Attachment Name
$attachNameLength = [int]$binaryReader.ReadUInt32()*2
$attachNameBytes = $binaryReader.ReadBytes($attachNameLength)
$attachName = [System.Text.Encoding]::Unicode.GetString($attachNameBytes, 0, $attachNameLength - 2)
# Attachment
$attachmentFile = $binaryReader.ReadBytes($attachSize);
$attachPath = $attachFolder + '\' + $fileName.Replace(".xml", "") + ' - ' + $attachName
# Write off to the output folder
[IO.File]::WriteAllBytes($attachPath, $attachmentFile)
$counter ++
}
catch [Exception]
{
Write-Host "Failure on" $fileName "with base64 value length" $base64.Length
}


}
}
Write-Host $counter
Рекомендации по теме
Комментарии
Автор

Thank you very much, your video was exactly what I was looking for. Greetings from El Salvador.

amilvelas
Автор

needs to retrive and copy the attached files uploaded in the infopath Form to sharepoint list item attachment control

muni
Автор

So, what was those magical changes you made for removing the first flow save failed message?

anderstaranger
Автор

I want to add a mapping from share points list to attachments.
Is there any way to achieve that

viratsrivastava
Автор

I want to add the attachments to an email. Can you tell me how to do that?

gilliangammon