{"id":12557,"date":"2015-03-30T04:58:00","date_gmt":"2015-03-30T04:58:00","guid":{"rendered":"https:\/\/viewmyprojects.com\/winwirewp\/?p=12557"},"modified":"2023-11-29T14:18:04","modified_gmt":"2023-11-29T14:18:04","slug":"automating-sharepoint-online-using-powershell-and-csom","status":"publish","type":"post","link":"https:\/\/viewmyprojects.com\/winwirewp\/blog\/automating-sharepoint-online-using-powershell-and-csom\/","title":{"rendered":"Automating SharePoint Online using PowerShell and CSOM"},"content":{"rendered":"\n<p>We always think of having automation solution while deploying components in office 365 projects. I can also say it\u2019s really challenging moving list, libraries, all out of the box development from Dev to other sites.<\/p>\n\n\n\n<p>Using PowerShell and CSOM Combination, we can write script to automate deployment process.I have implemented few of the scripts to automate the deployment process, which I will be explaining in further articles.Let\u2019s start with \u201cHow to connect Office 365 site from PowerShell editor?\u201d<\/p>\n\n\n\n<p>We have to prepare our machine to write script .Here is interesting part you can write the scripts in SharePoint (On-Premise) server or we can use our local system to write script.<\/p>\n\n\n\n<p>Open windows power shell ISE with Run as administrator.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"412\" height=\"212\" src=\"https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/PowerShell-ISE.webp\" alt=\"\" class=\"wp-image-18285\" srcset=\"https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/PowerShell-ISE.webp 412w, https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/PowerShell-ISE-300x154.webp 300w\" sizes=\"auto, (max-width: 412px) 100vw, 412px\" \/><\/figure>\n\n\n\n<p>If you get below error with respect to Machine policy then we just need to change the Execution policy of the system.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"57\" src=\"https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Error-300x57-1.webp\" alt=\"\" class=\"wp-image-18286\"\/><\/figure>\n\n\n\n<p>Update Execution Policy as per below command but you need administrator access to run this command. Open the PowerShell editor as an administrator and then update the execution policy.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"245\" height=\"25\" src=\"https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Execution-Policy.webp\" alt=\"\" class=\"wp-image-18287\" style=\"width:1035px;height:auto\"\/><\/figure>\n\n\n\n<p>As said earlier I am writing the scripts in my local system, so I need to keep all SharePoint DLL\u2019s in local folder to provide the reference in script.You can copy the DLL\u2019s from SharePoint server or download it from below URL .http:\/\/www.microsoft.com\/en-ie\/download\/details.aspx?id=35585<\/p>\n\n\n\n<p>I have created Library folder to keep all required .DLL files, which I\u2019m referring in the code.Below code will create Term sets based on provided XML inputs.<\/p>\n\n\n\n<p>Script Code:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"423\" height=\"1024\" src=\"https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Script-Code-1-423x1024-1.webp\" alt=\"\" class=\"wp-image-18288\" srcset=\"https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Script-Code-1-423x1024-1.webp 423w, https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Script-Code-1-423x1024-1-124x300.webp 124w\" sizes=\"auto, (max-width: 423px) 100vw, 423px\" \/><\/figure>\n\n\n\n<p>XML Input Values:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"494\" src=\"https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/XML-Input-Values-1024x494-1.webp\" alt=\"\" class=\"wp-image-18289\" srcset=\"https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/XML-Input-Values-1024x494-1.webp 1024w, https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/XML-Input-Values-1024x494-1-300x145.webp 300w, https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/XML-Input-Values-1024x494-1-768x371.webp 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>We always think of having automation solution while deploying components in office 365 projects. I can also say it\u2019s really challenging moving list, libraries, all out of the box development from Dev to other sites. Using PowerShell and CSOM Combination, we can write script to automate deployment process.I have implemented few of the scripts to&hellip; <a class=\"more-link\" href=\"https:\/\/viewmyprojects.com\/winwirewp\/blog\/automating-sharepoint-online-using-powershell-and-csom\/\">Continue reading <span class=\"screen-reader-text\">Automating SharePoint Online using PowerShell and CSOM<\/span><\/a><\/p>\n","protected":false},"author":100,"featured_media":16811,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_eb_attr":"","_uag_custom_page_level_css":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-12557","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","entry"],"acf":[],"featured_image_src":"https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Automating-SharePoint-Online-using-PowerShell-and-CSOM-graphic.webp","author_info":{"display_name":"Sambita","author_link":"https:\/\/viewmyprojects.com\/winwirewp\/author\/sambita\/"},"views":3581,"uagb_featured_image_src":{"full":["https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Automating-SharePoint-Online-using-PowerShell-and-CSOM-graphic.webp",800,440,false],"thumbnail":["https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Automating-SharePoint-Online-using-PowerShell-and-CSOM-graphic-150x150.webp",150,150,true],"medium":["https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Automating-SharePoint-Online-using-PowerShell-and-CSOM-graphic-300x165.webp",300,165,true],"medium_large":["https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Automating-SharePoint-Online-using-PowerShell-and-CSOM-graphic-768x422.webp",750,412,true],"large":["https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Automating-SharePoint-Online-using-PowerShell-and-CSOM-graphic.webp",750,413,false],"1536x1536":["https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Automating-SharePoint-Online-using-PowerShell-and-CSOM-graphic.webp",800,440,false],"2048x2048":["https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Automating-SharePoint-Online-using-PowerShell-and-CSOM-graphic.webp",800,440,false],"post-thumbnail":["https:\/\/viewmyprojects.com\/winwirewp\/wp-content\/uploads\/2023\/11\/Automating-SharePoint-Online-using-PowerShell-and-CSOM-graphic.webp",800,440,false]},"uagb_author_info":{"display_name":"Sambita","author_link":"https:\/\/viewmyprojects.com\/winwirewp\/author\/sambita\/"},"uagb_comment_info":0,"uagb_excerpt":"We always think of having automation solution while deploying components in office 365 projects. I can also say it\u2019s really challenging moving list, libraries, all out of the box development from Dev to other sites. Using PowerShell and CSOM Combination, we can write script to automate deployment process.I have implemented few of the scripts to&hellip;&hellip;","_links":{"self":[{"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/posts\/12557","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/users\/100"}],"replies":[{"embeddable":true,"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/comments?post=12557"}],"version-history":[{"count":2,"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/posts\/12557\/revisions"}],"predecessor-version":[{"id":18290,"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/posts\/12557\/revisions\/18290"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/media\/16811"}],"wp:attachment":[{"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/media?parent=12557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/categories?post=12557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/viewmyprojects.com\/winwirewp\/wp-json\/wp\/v2\/tags?post=12557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}