What I am trying to do is access a SharePoint 2010 document library, change all root and sub folders of that library from their existing content type to a new content type. So far my code has somewhat worked but I cannot seem to see the content types although I can get the folders.
Function RunThroughSubFolders($folder)
{
foreach($subfolder in $folder.SubFolders)
{
#write-host $subfolder.Name
$OldCTName = "Document Set"
$oldCT = $subfolder.ContentTypes[$OldCTName]
if ($subfolder.ContentType.Name -eq $oldCT.Name)
{
write-host "OLD CONTENT TYPE NAME FOUND!("$oldCT.Name ")" $subfolder.Name
#write-host $subfolder["ContentTypeId"]
<#
$subfolder["ContentTypeId"] = $newCTID
$subfolder.Update()
#>
}
else
{
##
}
}
}
Function GetFolders($Folder)
{
foreach($subfolder in $Folder.SubFolders)
{
RunThroughSubFolders($subfolder)
}
}
$web = Get-SPWeb "//url//”
foreach($list in $web.Lists)
{
if($list.Title -eq "Document Library")
{
GetFolders($list.RootFolder)
}
}