zoukankan      html  css  js  c++  java
  • 修改SharePoint 2013中item Created by 信息

    因为公司的系统有点小bug。额,要做点坏事,把系统没记上的东西偷偷补上去,但是item的created by变成了我(这怎么行,不能让别人知道我做了坏事,一定是隔壁小李干的!

    懒得开visual studio写代码。偷偷写段PowerShell脚本改改吧,研究一下,搞定!

    $snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
    if ($snapin -eq $null)
    {
    Write-Host "Loading SharePoint Powershell Snapin..."
    Add-PSSnapin "Microsoft.SharePoint.Powershell"
    Write-Host "SharePoint Powershell Snapin Loaded"
    }

    # Get Site and Web
    $site = new-object Microsoft.SharePoint.SPSite("http://yoursite")
    $web = $site.rootweb

    # Get List
    $list = $web.Lists["LISTNAME"] 

    $item = $list.GetItemById(XXX)

    Write-Host -f Yellow $item["Author"]
    Write-Host -f Yellow $item["Editor"]
    Write-Host -f Yellow $item["Created"]
    Write-Host -f Yellow $item["Modified"]

    $item["Author"] = "123;# 小李"
    $item["Editor"] = "123;# 小李"
    $item["Created"] = "3/31/2015 10:35:15 AM"
    $item["Modified"] = "3/31/2015 10:35:15 AM"
    $item.Update()

    #问题就是上面这段123;# 小李,用AD或者直接名字都不行,会报ReadOnly字段错误,ID+姓名 就正好啦,哇哈哈哈哈哈哈,小李就是你!

     

    $web.Update()
    $web.Dispose()

  • 相关阅读:
    Python day thirteen
    Python day twelve
    Python day eleven
    Python day ten
    Python day nine
    Python day eight
    Python day seven
    Python day six
    Python day five
    Python day four
  • 原文地址:https://www.cnblogs.com/graccc/p/4389693.html
Copyright © 2011-2022 走看看