I found that the following line of code works for me In Power Shell after a ton of work
$F.Properties["ContentTypeId"]=$ProjectFolder.Id.ToString()
$F is the folder from $Web.GetFolder.
$ProjectFolder is the new ContentType
Full code below.
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
Start-SPAssignment –Global
$Site = "http://myreallykewlsite"
$File = "TheFolderToUpdateinSite"
$Title="NewTitlebyRodney"
$ContentType="ProjectFolder"
$web = Get-SPWeb $Site
$FolderType = $web.AvailableContentTypes["Folder"]
$ProjectFolder = new-object Microsoft.SharePoint.SPContentType($FolderType, $web.ContentTypes, $ContentType)
$FolderType.Group = "Folder Content Types"
$web.ContentTypes.Add($ProjectFolder)
$web.Fields.Add("ProjectInfo","Text",$false)
$ProjectInfo =$web.Fields.GetField("ProjectInfo")
$ProjectInfo.Group="Folder Content Types"
step 9
$FieldLink = New-OBject Microsoft.SharePoint.SPFieldLink($ProjectInfo)
$ProjectFolder.FieldLinks.Add($FieldLink)
$ProjectFolder.Update()
Stop-SPAssignment –Global
Get the documents Library
$List = $web.Lists["Documents"]
update the library to allow managment of content types then addd the contenttype to the library.
$List.ContentTypesEnabled =$True
$List.Update()
$List.ContentTypes.Add($ProjectFolder)
$List.Update()
add the field to the Default View.
$D=$List.DefaultView
$D.ViewFields.Add($ProjectInfo)
$D.Update()
Get the List Item by its Title field value
$ListItem = $List.Items | Where {$_["Name"] -eq $File}
#foreach($_ in $ListItem){
Set "Department" column value
ok now to change the type from "Folder" to "ProjectFolder"
and add the Project Title and Info information
$F=$Web.GetFolder($Site + "/Shared Documents/" + $File)
#fojoadsfjadslfj here is your error Rodney
#$F.Item.File.CheckOut()
#$FI.CheckOut()
$F.Properties["ContentTypeId"]=$ProjectFolder.Id.ToString()
#$FI.CheckIn()
$F.Update()
$F["Project"] = $Title
$F.Update()
}
"Updated: " + $Site + " : " + $File + " : " + $Title