# Get-ERPMedia Cmdlet to download the attached media link of a specified entity from the ERP-System. ## Syntax ```powershell Get-ERPMedia [[-EntitySet] ] [[-Keys] ] [[-File] ]] [] ``` ## Parameters | Type | Name | Description | Optional | |----------------------|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| | String | EntitySet | The EntitySet name where the item is located.
It is also possible to specify additional namespaces or the whole url (e.g MaterialService/Materials, ) | no | | Hashtable / PSObject | Keys | The reference properties for the searching item | no | | String | File | Path where the file should be downloaded (e.g C:\\Temp\\myFile.txt). In case a file with the same name already exists it will be overwritten. | no | | no | ## Return type **Bool**:\ **\$true** ← on success.\ **\$false** ← on failure. Exception/ErrorMessage can be accessed using [\$Error]().\ If the cmdlet fails due to error responses returned by the ERP system, the \$Error variable provides a [WebRequestException]() . ## Remarks The Cmdlet is used to download the [Media Link Entries (MLEs)]() from the specified entity to the specified location.\ In case a file with the same name already exists in the specified location it will be overwritten. Also the appropriate folder structure will be created if it doesn´t exists. ## Examples In the following examples we are using public OData Services () for demonstration purposes: **Download media from the Advertisement entity** ```powershell Connect-Erp -Service "http://services.odata.org/V3/OData/OData.svc" Get-ERPMedia -EntitySet "Advertisements" -Keys @{"ID" = [Guid]"db2d2186-1c29-4d1e-88ef-a127f521b9c6"} -File "C:\Temp\TestMedia.txt" ``` **Error handling, analyze why the Media Resource could not be downloaded to the specified directory, by using \$Error** ```powershell Connect-Erp -Service "https://services.odata.org/V3/OData/OData.svc" $result = Get-ERPMedia -EntitySet "Advertisements" -Keys @{"ID" = [Guid]"db2d2186-1c29-4d1e-88ef-a127f521b9c6"} -File "C:\Temp\AdvertismentText.txt" if(-not $result){ $Error[0].Exception #"Access to the path 'C:\Temp\AdvertismentText.txt' is denied. } ```