spo listitem attachment get
Gets an attachment from a list item
Usage
m365 spo listitem attachment get [options]
Options
-u, --webUrl <webUrl>URL of the site where the list item is located.
--listId [listId]ID of the list. Specify either
listTitle,listIdorlistUrl.--listTitle [listTitle]Title of the list. Specify either
listTitle,listIdorlistUrl.--listUrl [listUrl]Server- or site-relative URL of the list. Specify either
listTitle,listIdorlistUrl.--listItemId <listItemId>The ID of the list item.
-n, --fileName <fileName>Name of the file to get.
-h, --help [help]Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are
options,examples,remarks,permissions,response,full. Default isoptions.--query [query]JMESPath query string. See http://jmespath.org/ for more information and examples.
-o, --output [output]Output type.
json,text,csv,md,none. Defaultjson.--verboseRuns command with verbose logging.
--debugRuns command with debug logging.
Examples
Get an attachment from a list item by using list title.
m365 spo listitem attachment get --webUrl https://contoso.sharepoint.com/sites/project-x --listTitle "Demo List" --listItemId 147 --fileName "File1.jpg"
Get an attachment from a list item by using list URL.
m365 spo listitem attachment get --webUrl https://contoso.sharepoint.com/sites/project-x --listUrl "/sites/project-x/Lists/DemoList" --listItemId 147 --fileName "File1.jpg"
Response
- JSON
- Text
- CSV
- Markdown
{
"FileName": "File1.jpg",
"FileNameAsPath": {
"DecodedUrl": "File1.jpg"
},
"ServerRelativePath": {
"DecodedUrl": "/sites/project-x/Lists/DemoListAttachments/147/File1.jpg"
},
"ServerRelativeUrl": "/sites/project-x/Lists/DemoListAttachments/147/File1.jpg"
}
FileName : File1.jpg
FileNameAsPath : {"DecodedUrl":"File1.jpg"}
ServerRelativePath: {"DecodedUrl":"/sites/project-x/Lists/DemoListAttachments/147/File1.jpg"}
ServerRelativeUrl : /sites/project-x/Lists/DemoListAttachments/147/File1.jpg
FileName,ServerRelativeUrl
File1.jpg,/sites/project-x/Lists/DemoListAttachments/147/File1.jpg
# spo listitem attachment get --webUrl "https://contoso.sharepoint.com/sites/project-x" --listTitle "PnP PowerShell List" --listItemId "1" --fileName "File1.jpg"
Date: 7/20/2023
Property | Value
---------|-------
FileName | File1.jpg
ServerRelativeUrl | /sites/project-x/Lists/DemoListAttachments/147/File1.jpg