Created
May 11, 2015 15:11
-
-
Save asadrefai/292ea54a182824e95f56 to your computer and use it in GitHub Desktop.
PowerShell to remove item content type from a SharePoint list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Remove-ItemContentTypeFromAList(){ | |
#delete item content type from list | |
Add-PSSnapin "Microsoft.SharePoint.PowerShell" | |
$web = Get-SPWeb "http://YourSite.com" | |
$list = $web.Lists["Your List Name"] | |
$ctToRemove = $list.ContentTypes["Item"] | |
if($ctToRemove) | |
{ | |
Write-Host "Item Content Type Exist ready to delete" | |
$list.ContentTypes.Delete($ctToRemove.Id) | |
$list.Update() | |
$Web.Dispose() | |
} | |
else | |
{ | |
Write-Host "Item content type do not exists" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment