Wednesday, July 25, 2012

SharePoint 2010 : List "Order field" is hidden

just run the below script and "order" field will be visible in the list.

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
$WebAppUrl = "http://site/"

$site=new-object Microsoft.SharePoint.SPSite($WebAppUrl
foreach ($web in $site.AllWebs) 
  Write-Host      $web.Url
 
  for ($i = 0; $i -lt $webLists.Count; $i++)
  {
 
     $spList = $weg.Lists[$i] #;   # ... }
      #foreach ($spList in $web.Lists) 
      # { 
            #if ($spList.BaseTemplate -eq "GenericList" -or $spList.BaseTemplate -eq  "DocumentLibrary" )
            if ($spList.BaseTemplate -eq "GenericList")
             {
                  # Write-Host  $spList.title
                 
                  if ($web.Url -eq "http://site")
                  {
                     #Write-Host  $spList.title
                   
                      $orderField = $spList.Fields["Order"]
                        $type = $orderField.GetType()
                        $mi = $type.GetMethod("SetFieldBoolValue", [reflection.bindingflags]"nonpublic, instance")
                        $parameters = "CanToggleHidden", $true
                        $mi.Invoke($orderField, $parameters)
                       
                        if($orderField.Hidden -eq $true)
                        {
                              Write-Host  "Surya" $spList.Title
                             
                              #if($spList.title -ne "Relationships List"  -or $spList.title -ne "Web Site Menu - First Level"   -or $spList.title -ne "Variation Labels" -or $spList.title -ne "TaxonomyHiddenList" -or $spList.title  -ne "Suggested Content Browser Locations" -or $spList.title -ne "Reusable Content" -or  $spList.title -ne "Reporting Metadata" -or $spList.title -ne "Notification List" -or  $spList.title -ne "Quick Deploy Items" -or $spList.title -ne "QuickLinksList")
                              #{
                                    $orderField.Hidden = $false
                                    $orderField.Update()
                              #}
                        }

                  }
                 
             }
           
            #SPListTemplateType.GenericList
      }
}


$web.Dispose()
$site.Dispose()


No comments:

Post a Comment

Followers