Skip to content

Instantly share code, notes, and snippets.

@vaderj
Last active February 27, 2020 19:15
Show Gist options
  • Save vaderj/52c77f27ddc257f107d1 to your computer and use it in GitHub Desktop.
Save vaderj/52c77f27ddc257f107d1 to your computer and use it in GitHub Desktop.
#PowerShell #SharePoint #SSOM Instanciate SPSite object using a user token.From: http://w3foverflow.com/question/access-personal-views-in-a-list-with-powershell/This method allows for access to a users "Personal Views"
#Create a standard SPWeb object with admin credentials
$spweb = get-spweb http://url
#grab the user you want to instanciate under
$usr = $spweb.allusers | ? {$_.displayname -like "User Name"}
#make the user token accessable
$token = $usr.UserToken
#create a new SPSite obj using user token
$spsite = New-Object Microsoft.SharePoint.SPSite($spweb.url, $token)
#open the SPWeb with the root-relative path
$web = $spsite.OpenWeb("/sites")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment