PowerShell to get SharePoint 2010 field name from site collection

param
(
 [Parameter(Mandatory=$true, HelpMessage=’-Url http://sharepointurl/site/test – Please provide the Url of the Site.’)]
 [string]$Url=””,
 [Parameter(Mandatory=$true, HelpMessage=’-FieldName – Please provide the Internal Field Name to remove.’)]
 [string]$FieldName=””,
 [Parameter(Mandatory=$true, HelpMessage=’-FieldType – Please provide the Field Type to remove.’)]
 [string]$FieldType=””
 
);

$site = Get-SPSite -Identity $Url -ErrorAction SilentlyContinue;
if($site -ne $null)
{
 Write-Host “Checking Site Collection:” $Url “Field:” $FieldName “….”-NoNewline;
 $checkSiteColumn = $site.RootWeb.Fields | ?{($_.InternalName -eq $FieldName) -and ($_.TypeAsString -eq $FieldType)};
 if($checkSiteColumn -eq $null)
 {
  Write-Host “Field Not Found!” -ForegroundColor Yellow;
 }
 else
 {
  Write-Host “Field Found” -ForegroundColor Green;
 }
 
 foreach($checkWeb in $site.AllWebs)
 {
  $caseFileList = $checkWeb.Lists.TryGetList(“Case Files”);
  if($caseFileList -ne $null)
  {
   Write-Host “Checking CaseFiles DocLib in” $checkWeb.ServerRelativeUrl “…”-NoNewline;
   $checkField = $caseFileList.Fields | ?{($_.InternalName -eq $FieldName) -and ($_.TypeAsString -eq $FieldType)};
   if($checkField -eq $null)
   {
    Write-Host “Not Found!” -ForegroundColor Yellow;
   }
   else
   {
    Write-Host “Found!” -ForegroundColor Green;
   }
  }
 }
 
}
else
{
 Write-Host “Site: ” $Url ” Not Found” -ForegroundColor Yellow;

How to enable delete button to delete SharePoint 2010 Content Type column

Here is the PowerShell script to bring back the Content Type delete button:

$site = Get-SPSite-Identity http://sharepointsite/sites/test 

$ctype =$site.RootWeb.Fields | ?{$_.InternalName -eq“InternalFieldName”}

$ctype.AllowDeletion=“true”

$ctype.Update()

Run the above script from the server and check that the content type button now appears.

Powershell to get count of your SharePoint sites

Often you may have the need to find the need to take a count of all your sites by site collection in your web application. Here is a small #powershell script which will do the work for you, just change the name of your web application:

Add-PSSnapin “Microsoft.SharePoint.PowerShell”

$webapp=Get-SPWebApplication http://yourwebapplication;
$webapp.Sites | %{Write-Host $_.Url ” -Count: ” $_.AllWebs.Count};

Hit like if this was helpful…