问题描述
下面是我的代码,我是从Internet上获得的,用于使用Powershell更新SPlist中的列表项
below is my code, i got it from internet for updating a list item in my SPlist, using powershell
但无法正常工作吗?
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA静默继续
$ SPWeb = Get-SPWeb``http://srvr1s:28516/''
$ SPList = $ SPWeb.GetList("http://srvr1s:28516/Lists/ProjectProposal");
$ userName =" i:0#.w | mydomain \ npd10" ;; #NPD10已经是AD中的用户
$ user = Get-SPUser -web $ SPWeb -Identity $ userName;
$ userString =" {0};#{1}" -f $ user.ID,$ user.UserLogin.Tostring()
$ SPListItem = $ SPList.Items.Add();
#$ SPListItem ["URL"] ="http://www.cnn.com";
$ SPListItem [" Author] = $ userString;
$ SPListItem.UpdateOverwriteVersion();
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
$SPWeb = Get-SPWeb "http://srvr1s:28516/"
$SPList = $SPWeb.GetList("http://srvr1s:28516/Lists/ProjectProposal");
$userName = "i:0#.w|mydomain\npd10"; # NPD10 IS ALREADTY A USER IN AD
$user = Get-SPUser -web $SPWeb -Identity $userName;
$userString = "{0};#{1}" -f $user.ID, $user.UserLogin.Tostring()
$SPListItem = $SPList.Items.Add();
#$SPListItem["URL"] = "http://www.cnn.com";
$SPListItem["Author"] = $userString;
$SPListItem.UpdateOverwriteVersion();
它引发错误
推荐答案
您应该尝试
此致
Gaurav
如果答案有帮助,请标记为正确.
Please mark correct if answer helps you.
这篇关于应用Powershell通过AD中现有的新用户ID更新Created By字段时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!