title: Using the Sharepoint CSOM with PowerShell
body: <p>There are many examples online of how to access/use the SharePoint Client-Side Object Model with PowerShell.  But of course, they don't seem to work for me.  I seem to be having trouble accessing some of the credential code:</p>
  
  <pre><code>PS C:\Scripts&gt; $webUrl = "https://abc.sharepoint.com&gt;"
  PS C:\Scripts&gt; $username = "user3"
  PS C:\Scripts&gt; $password = "password"
  PS C:\Scripts&gt;
  PS C:\Scripts&gt; $ctx = new-object Microsoft.SharePoint.Client.ClientContext($webUrl)
  PS C:\Scripts&gt; $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
  New-Object : Cannot find type Microsoft.SharePoint.Client.SharePointOnlineCredentials]: make sure the assembly containing this type is loaded.
  At line:1 char:30
  + $ctx.Credentials = New-Object &lt;&lt;&lt;&lt;  Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
      + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
      + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
  </code></pre>
  
  <p>I am attempting to access a SharePoint 2010 server that we maintain which requires logon authentication.  Does anyone know what I am doing wrong?</p>
  
  <p>OK, so many responses have told me that I am using the incorrect credentialing type for this connection.  So I have changed to:</p>
  
  <pre><code>$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($url)
  $clientContext.AuthenticationMode = "FormsAuthentication"
  $clientContext.FormsAuthenticationLoginInfo = New-Object Microsoft.SharePoint.Client.FormsAuthenticationLoginInfo("myDomain\myUser", "myPassword")
  </code></pre>
  
  <p>which seems to work fine.  But then...</p>
  
  <pre><code>$web = $clientContext.Web
  $properties = $web.AllProperties
  $clientContext.Load($web)
  </code></pre>
  
  <p>gives me:</p>
  
  <pre><code>&gt; Cannot find an overload for "Load" and the argument count: "1". At
  &gt; line:1 char:20
  &gt; + $clientContext.Load &lt;&lt;&lt;&lt; ($web)
  &gt;     + CategoryInfo          : NotSpecified: (:) [], MethodException
  &gt;     + FullyQualifiedErrorId : MethodCountCouldNotFindBest
  </code></pre>
  
  <p>and when I try to look at the $clientContent object:</p>
  
  <pre><code>PS C:\Scripts&gt; $clientContent | get-member
  Get-Member : No object has been specified to the get-member cmdlet.
  At line:1 char:28
  + $clientContent | get-member &lt;&lt;&lt;&lt;
      + CategoryInfo          : CloseError: (:) [Get-Member], InvalidOperationException
      + FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand
  </code></pre>
  
  <p>which makes no sense at all.  Anyone have any help for this?</p>