Was busy in implementing a test site - my BA asked whether we can show the CEO's name instead of her name in the created by column of all items in a list.
$SPSite = New-Object Microsoft.SharePoint.SPSite("<site collection url>")
$SPWeb = $SPSite.AllWebs["<site name>"]
$SPList = $SPWeb.Lists["<List Name>"]
$SPListItemCollection = $SPList.Items
$targetUser =$SPWeb.EnsureUser(“<user Windows ID>”)
foreach ($ListItem in $SPListItemCollection)
{
$ListItem["Author"] = $targetUser
$ListItem.ModerationInformation.Status = "Approved"
$ListItem.Update()
}
$SPWeb.Update()
Worked like a gem .... BA happy, CEO tooo :)
$SPSite = New-Object Microsoft.SharePoint.SPSite("<site collection url>")
$SPWeb = $SPSite.AllWebs["<site name>"]
$SPList = $SPWeb.Lists["<List Name>"]
$SPListItemCollection = $SPList.Items
$targetUser =$SPWeb.EnsureUser(“<user Windows ID>”)
foreach ($ListItem in $SPListItemCollection)
{
$ListItem["Author"] = $targetUser
$ListItem.ModerationInformation.Status = "Approved"
$ListItem.Update()
}
$SPWeb.Update()
Worked like a gem .... BA happy, CEO tooo :)
No comments:
Post a Comment