# Save-FLCAttachment Downloads the specified attachment from Fusion 360 Manage to a local directory. ## Syntax ```powershell Save-FLCAttachment -Workspace -ItemId -AttachmentId -DownloadPath [] ``` ```powershell Save-FLCAttachment -InputObject -DownloadPath [] ``` ## Parameters | Type | Name | Description | Optional | |---------------------------------------|--------------|-------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------| | String | Workspace | The name of the workspace that contains the item with the specified attachment. | no (optional when *InputObject* is used) | | Long | ItemId | The ID of the item to which the specified attachment belongs. | no (optional when *InputObject* is used) | | Long | AttachmentId | The ID of the attachment that will be downloaded. | no (optional when *InputObject* is used) | | [Item]() | InputObject | The Fusion 360 Manage Item whose associated Items are retrieved. The argument accepts pipeline input. | no (optional when Workspace, ItemId and AttachmentId are used) | | [DirectoryInfo][] | DownloadPath | The Path to a local directory where the attachment should be downloaded. If the destination directory does not exist, it will be created. | no | [DirectoryInfo]: https://docs.microsoft.com/en-us/dotnet/api/system.io.directoryinfo?redirectedfrom=MSDN&view=netframework-4.7.2 ## Return type [FileInfo]() ← On success.\ **empty** ← on failure. Exception/ErrorMessage can be accessed using [\$Error](). ## Remarks The Cmdlet downloads the specified *direct Attachment* and returns its download location. The passed **-Workspace** has to be [configured properly]() and must allow viewing/downloading the according Attachments in the [Attachments Tab](). Attachments that have the *same file name* will be downloaded with a *suffix*, for example "*SampleFile (1).png*" . For attachments that have multiple versions, the *latest version* is downloaded. ## Examples To use the examples below a [Fusion 360 Manage PLM demo]() Tenant is required: **Download a specific attachment of an Item in Fusion 360 Manage** ```powershell Connect-FLC -Tenant 'your_tenant_name' -ClientId 'your_client_id' -ClientSecret 'your_client_secret' -UserId 'your_email@example.com' $item = (Get-FLCItems -Workspace 'Change Orders' -Filter 'ITEM_DETAILS:NUMBER="CO000016"')[0] $attachments = $item | Get-FLCItemAssociations -Attachments $attachments | Where-Object {$_.Title -eq "GT220 Change Proposal"} | Save-FLCAttachment -DownloadPath 'C:\Temp\MyPictures' <# Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 02.07.2021 13:09 1344916 GT220 Change Proposal.png #> ``` **Download the related attachments of a header item that has BOM line items with attachments in its BOM in Fusion 360 Manage** ```powershell Connect-FLC -Tenant 'your_tenant_name' -ClientId 'your_client_id' -ClientSecret 'your_client_secret' -UserId 'your_email@example.com' $bomRows = Get-FLCBOM -Workspace 'Items and BOMs' -ItemId 7516 foreach($bomRow in $bomRows) { $relatedAttachments = $bomRow | Get-FLCItemAssociations -Attachments $relatedAttachments | Save-FLCAttachment -DownloadPath 'C:\Temp\Attachments' } ``` **Error handling, analyze why the attachment could not be downloaded to the specified directory, by using \$Error** ```powershell Connect-FLC -Tenant 'your_tenant_name' -ClientId 'your_client_id' -ClientSecret 'your_client_secret' -UserId 'your_email@example.com' $downloadedAttachment = Save-FLCAttachment -Workspace 'Tasks' -ItemId 7624 -AttachmentId 266 -DownloadPath '\\192.0.0.1\Some currently not available directory\' if(-not $downloadedAttachment ){ $Error[0].Exception #Returns "The network path was not found." } ```