Adding a column to a content type powershell

Answered Adding a column to a content type powershell

  • Thursday, May 10, 2012 7:07 AM
     
      Has Code

    hi!

         I want on the site with the URL: "http://sp_3/export1" in the List

        "Whereabout" add column "dfg" in the content "Пользователи" with powershell

    // Whereabout - Местонахождение

    my attempt :

    PS C:\Windows\system32> $web = Get-SPWeb "http://sp_3/export1"
    PS C:\Windows\system32> $field = $web.Fields["dfg"]
    PS C:\Windows\system32> $ct = $web.ContentTypes["Пользователи"]
    PS C:\Windows\system32> $flink = new-Object Microsoft.SharePoint.SPFieldLink($field)
    PS C:\Windows\system32> $flink.DisplayName = $field.Title
    PS C:\Windows\system32> $ct.FieldLinks.Add($flink)
    Нельзя вызвать метод для выражения со значением NULL.
    строка:1 знак:19
    + $ct.FieldLinks.Add <<<< ($flink)
        + CategoryInfo          : InvalidOperation: (Add:String) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull

    why mistakes &

    please help, thanks !!

All Replies