Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

add existing site content type to doc lib -power shell

$
0
0

Add-PSSnapIn Microsoft.SharePoint.PowerShell

#Update : incomplete on  09-feb-2015 05 pm

$siteCollecURL = "http://sirvr11:123/sites/Engineering/WIP"

$basicContentType="Basic Content Type"

#$siteColl = Get-SPSite -Identity $siteCollecURL

$paramWeb = Get-SPWeb -Identity $siteCollecURL

Write-Host $siteColl.Url

$pdoclib ="CY"

$docLib = $paramWeb.Lists[$pdoclib]

          $docLib.Title
         
         if ($docLib -ne $null)
          {
            $docLib.ContentTypesEnabled = $true
            $docLib.Update()

            #Add site content types to the list
            $ctToAdd = $paramWeb.ContentTypes["Basic Content Type"]

            $ctToAdd.Name

            pause

            try
            {
            $ct = $docLib.ContentTypes.Add($ctToAdd)
            }
            catch
            {
            write-host "error adding Content type" $ct.Name  "to" $docLib.Title
            }

            write-host "Content type" $ct.Name "added to list" $docLib.Title
            $docLib.Update()
          }

am trying to add the "BasicContent Type"  to my doc lib called "CY" with the help of above  power shells cript.

but it failed to add .

getting the error message.can anyone pls help where  am missing any steps /line of code.

help is appreciated!


Viewing all articles
Browse latest Browse all 7589

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>