{"id":918,"date":"2016-01-19T19:17:42","date_gmt":"2016-01-19T19:17:42","guid":{"rendered":"https:\/\/regroove.ca\/stellark\/?p=918"},"modified":"2023-02-24T18:54:11","modified_gmt":"2023-02-24T18:54:11","slug":"sharepoint-online-invite-external-users-with-powershell","status":"publish","type":"post","link":"https:\/\/regroove.ca\/stellark\/2016\/01\/19\/sharepoint-online-invite-external-users-with-powershell\/","title":{"rendered":"SharePoint Online Invite External Users with PowerShell"},"content":{"rendered":"\n<p>Ever wished you could bulk invite external users to your SharePoint Online site?<\/p>\n\n\n\n<p>Turns out you can. Here&#8217;s the PowerShell.<\/p>\n\n\n\n<p>A couple notes:<\/p>\n\n\n\n<ol>\n<li>This assumes you have installed the Microsoft SharePoint Online SDK v16 <a href=\"https:\/\/www.microsoft.com\/en-ca\/download\/details.aspx?id=42038\">https:\/\/www.microsoft.com\/en-ca\/download\/details.aspx?id=42038<\/a><\/li>\n\n\n\n<li>\nAnd that you have added them to your script. Eg:<br>Add-Type \u2013Path &#8220;C:\\Program Files\\Common Files\\microsoft shared\\Web Server Extensions\\16\\ISAPI\\Microsoft.SharePoint.Client.dll&#8221;\nAdd-Type \u2013Path &#8220;C:\\Program Files\\Common Files\\microsoft shared\\Web Server Extensions\\16\\ISAPI\\Microsoft.SharePoint.Client.Runtime.dll&#8221;\n<\/li>\n\n\n\n<li>This script also assumes you have a variable $users which has a collection of email addresses that you want to invite. (Maybe imported from a CSV etc.)<\/li>\n\n\n\n<li>This sets all users invited to have &#8220;view&#8221; rights. To change this modify this line accordingly\n[Microsoft.SharePoint.Client.Sharing.Role]::View\n<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">[powershell]\n# Establish Connection to SharePoint Online\n$siteUrl = \"site url\"\n$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)\n$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials(\"username\", \"password\")\n$ctx.Credentials = $credentials\n# Create request list\n$userList = New-Object \"System.Collections.Generic.List``1[Microsoft.SharePoint.Client.Sharing.UserRoleAssignment]\"\n# For each user, set role\n# THIS ASSUMES YOU HAVE A POWERSHELL COLLECTION OF USERS YOU WANT TO INVITE\nForEach($user in $users)\n{\n$userRoleAssignment = New-Object Microsoft.SharePoint.Client.Sharing.UserRoleAssignment\n$userRoleAssignment.UserId = $user\n$userRoleAssignment.Role = [Microsoft.SharePoint.Client.Sharing.Role]::View\n$userList.Add($userRoleAssignment)\n}\ntry\n{\n# Send invites\n$message = \"Please accept this invite to our SharePoint Site. Thanks!\"\n[Microsoft.SharePoint.Client.Sharing.WebSharingManager]::UpdateWebSharingInformation($ctx, $ctx.Web, $userList, $true, $message, $true, $true)\n$ctx.ExecuteQuery()\n}\ncatch\n{\n$hasError = ($error[0] | out-string)\n}\n[\/powershell]<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Ever wished you could bulk invite external users to your SharePoint Online site? Turns out you can. Here&#8217;s the PowerShell. A couple notes: [powershell] # Establish Connection to SharePoint Online $siteUrl = &#8220;site url&#8221; $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials(&#8220;username&#8221;, &#8220;password&#8221;) $ctx.Credentials = $credentials # Create request list $userList = New-Object &#8220;System.Collections.Generic.List&#8220;1[Microsoft.SharePoint.Client.Sharing.UserRoleAssignment]&#8221; # &hellip; <a href=\"https:\/\/regroove.ca\/stellark\/2016\/01\/19\/sharepoint-online-invite-external-users-with-powershell\/\"><\/a><\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[68,80],"tags":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SharePoint Online Invite External Users with PowerShell - Stephanie Kahlam<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/regroove.ca\/stellark\/2016\/01\/19\/sharepoint-online-invite-external-users-with-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SharePoint Online Invite External Users with PowerShell - Stephanie Kahlam\" \/>\n<meta property=\"og:description\" content=\"Ever wished you could bulk invite external users to your SharePoint Online site? Turns out you can. Here&#8217;s the PowerShell. A couple notes: [powershell] # Establish Connection to SharePoint Online $siteUrl = &quot;site url&quot; $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials(&quot;username&quot;, &quot;password&quot;) $ctx.Credentials = $credentials # Create request list $userList = New-Object &quot;System.Collections.Generic.List``1[Microsoft.SharePoint.Client.Sharing.UserRoleAssignment]&quot; # &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/regroove.ca\/stellark\/2016\/01\/19\/sharepoint-online-invite-external-users-with-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"Stephanie Kahlam\" \/>\n<meta property=\"article:published_time\" content=\"2016-01-19T19:17:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-02-24T18:54:11+00:00\" \/>\n<meta name=\"author\" content=\"Stephanie Kahlam\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Stephanie Kahlam\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/regroove.ca\/stellark\/2016\/01\/19\/sharepoint-online-invite-external-users-with-powershell\/\",\"url\":\"https:\/\/regroove.ca\/stellark\/2016\/01\/19\/sharepoint-online-invite-external-users-with-powershell\/\",\"name\":\"SharePoint Online Invite External Users with PowerShell - Stephanie Kahlam\",\"isPartOf\":{\"@id\":\"https:\/\/regroove.ca\/stellark\/#website\"},\"datePublished\":\"2016-01-19T19:17:42+00:00\",\"dateModified\":\"2023-02-24T18:54:11+00:00\",\"author\":{\"@id\":\"https:\/\/regroove.ca\/stellark\/#\/schema\/person\/175e89cb69612178b2ac838c0bab6149\"},\"breadcrumb\":{\"@id\":\"https:\/\/regroove.ca\/stellark\/2016\/01\/19\/sharepoint-online-invite-external-users-with-powershell\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/regroove.ca\/stellark\/2016\/01\/19\/sharepoint-online-invite-external-users-with-powershell\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/regroove.ca\/stellark\/2016\/01\/19\/sharepoint-online-invite-external-users-with-powershell\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Stellark Home\",\"item\":\"https:\/\/regroove.ca\/stellark\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SharePoint Online Invite External Users with PowerShell\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/regroove.ca\/stellark\/#website\",\"url\":\"https:\/\/regroove.ca\/stellark\/\",\"name\":\"Stephanie Kahlam\",\"description\":\"Microsoft 365 and SMB.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/regroove.ca\/stellark\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/regroove.ca\/stellark\/#\/schema\/person\/175e89cb69612178b2ac838c0bab6149\",\"name\":\"Stephanie Kahlam\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/regroove.ca\/stellark\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/398b95e23dc9eaf37a780b86a239b485?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/398b95e23dc9eaf37a780b86a239b485?s=96&d=mm&r=g\",\"caption\":\"Stephanie Kahlam\"},\"url\":\"https:\/\/regroove.ca\/stellark\/author\/skahlam\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SharePoint Online Invite External Users with PowerShell - Stephanie Kahlam","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/regroove.ca\/stellark\/2016\/01\/19\/sharepoint-online-invite-external-users-with-powershell\/","og_locale":"en_US","og_type":"article","og_title":"SharePoint Online Invite External Users with PowerShell - Stephanie Kahlam","og_description":"Ever wished you could bulk invite external users to your SharePoint Online site? Turns out you can. Here&#8217;s the PowerShell. A couple notes: [powershell] # Establish Connection to SharePoint Online $siteUrl = \"site url\" $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials(\"username\", \"password\") $ctx.Credentials = $credentials # Create request list $userList = New-Object \"System.Collections.Generic.List``1[Microsoft.SharePoint.Client.Sharing.UserRoleAssignment]\" # &hellip;","og_url":"https:\/\/regroove.ca\/stellark\/2016\/01\/19\/sharepoint-online-invite-external-users-with-powershell\/","og_site_name":"Stephanie Kahlam","article_published_time":"2016-01-19T19:17:42+00:00","article_modified_time":"2023-02-24T18:54:11+00:00","author":"Stephanie Kahlam","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Stephanie Kahlam","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/regroove.ca\/stellark\/2016\/01\/19\/sharepoint-online-invite-external-users-with-powershell\/","url":"https:\/\/regroove.ca\/stellark\/2016\/01\/19\/sharepoint-online-invite-external-users-with-powershell\/","name":"SharePoint Online Invite External Users with PowerShell - Stephanie Kahlam","isPartOf":{"@id":"https:\/\/regroove.ca\/stellark\/#website"},"datePublished":"2016-01-19T19:17:42+00:00","dateModified":"2023-02-24T18:54:11+00:00","author":{"@id":"https:\/\/regroove.ca\/stellark\/#\/schema\/person\/175e89cb69612178b2ac838c0bab6149"},"breadcrumb":{"@id":"https:\/\/regroove.ca\/stellark\/2016\/01\/19\/sharepoint-online-invite-external-users-with-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/regroove.ca\/stellark\/2016\/01\/19\/sharepoint-online-invite-external-users-with-powershell\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/regroove.ca\/stellark\/2016\/01\/19\/sharepoint-online-invite-external-users-with-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Stellark Home","item":"https:\/\/regroove.ca\/stellark\/"},{"@type":"ListItem","position":2,"name":"SharePoint Online Invite External Users with PowerShell"}]},{"@type":"WebSite","@id":"https:\/\/regroove.ca\/stellark\/#website","url":"https:\/\/regroove.ca\/stellark\/","name":"Stephanie Kahlam","description":"Microsoft 365 and SMB.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/regroove.ca\/stellark\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/regroove.ca\/stellark\/#\/schema\/person\/175e89cb69612178b2ac838c0bab6149","name":"Stephanie Kahlam","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/regroove.ca\/stellark\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/398b95e23dc9eaf37a780b86a239b485?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/398b95e23dc9eaf37a780b86a239b485?s=96&d=mm&r=g","caption":"Stephanie Kahlam"},"url":"https:\/\/regroove.ca\/stellark\/author\/skahlam\/"}]}},"_links":{"self":[{"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/posts\/918"}],"collection":[{"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/comments?post=918"}],"version-history":[{"count":1,"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/posts\/918\/revisions"}],"predecessor-version":[{"id":1433,"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/posts\/918\/revisions\/1433"}],"wp:attachment":[{"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/media?parent=918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/categories?post=918"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/regroove.ca\/stellark\/wp-json\/wp\/v2\/tags?post=918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}