Is there a way to add Items to a SharePoint List/Library using the credentials of a non-administrator user?
I am logged on SharePoint server using the Admin account, I have users in my domain which I assigned the below permissions over my SharePoint Site Collection.
spadmin - Full Control - SP Administrator account user1 - Design - simple user user2 - Contribute - simple user
if I run Powershell as a different user using the user1 credentials, the current session opened on powershell is obviously for user1, after this I execute the next command:
$spweb = Get-SPWeb -Identity "http://misite-D02:36677/sites/SC_1" $list = $spweb.Lists["Gen_List"] $list.AddItem() #IT FAILS AT THIS LINE BECAUSE LIST IS NULL $list["Title"] = "TestItem" $list.Update()
the above code fails on commented line, and when I print on screen the value of the list
$spweb.Lists the next error is displayed:
The following exception occurred while trying to enumerate the collection: "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))". + CategoryInfo : NotSpecified: (:) , ExtendedTypeSystemException + FullyQualifiedErrorId : ExceptionInGetEnumerator + PSComputerName : misite-D02.testsp.local
My target is add items from PowerShell to lists, in order to have the "Modified By" and "Created By" columns recorded with the name of the user who created/modified them, such as is displayed in the below image:
it is possible do it with
spadmin credentials, however I'm not sure with other user credentials or another way