Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Adding Attachments to a Specific Item in SharePoint
WhatsApp
Manpreet Singh
10y
13.3
k
0
0
25
Blog
This is a major thing which is used in our day to day activities but also in our major Migration projects in which we need to move Dot Net applications to SharePoint.
Here is a PowerShell which will do that easily for you, Change the following details down in the script.
Open SharePoint 2010 Management Shell by going to Start >> All Programs >>SharePoint >>Microsoft SharePoint 2010 Products >> SharePoint 2010 Management Shell (Run as Administrator).
Run the following script.
[System.Reflection.Assembly]::LoadWithPartialName(
"Microsoft.SharePoint"
)
function AddAttachment($item, $filePath)
{
$bytes = [System.IO.File]::ReadAllBytes($filePath)
$item.Attachments.Add([System.IO.Path]::GetFileName($filePath),$bytes)
$item.Update()
}
$site = [Microsoft.SharePoint.SPSite](
"Your site name"
)
$web = $site.OpenWeb()
$list = $web.Lists[
"Your List name"
]
$item = $list.GetItemById(Your Id)
AddAttachment $item
"Your Document Name"
Adding Attachments to a Specific Item in SharePoint
Up Next
Add an attachment to the SharePoint 2010 list item using web service in powershell
Ebook Download
View all
Configure MinRole Search and Cloud Hybrid Features in SharePoint Server 2016 and Office 365
Read by 1.6k people
Download Now!
Learn
View all
Membership not found