Identify columns then set visibility

We have 2 columns that are across all libraries in a web application.
In all cases they should be hidden from the edit and view properties forms.

How can I (powershell) loop through the web app and report on those libraries where this is not the case.
Report: Site name: Library name: Column that is not hidden in one or both forms.

Not looking to fix this in the script at this stage, just flag it in the report.

April 19th, 2015 4:43pm

Hi,

You could use $column.ShowInEditForm and $column.ShowInDisplayForm to check if they are hidden. Below is an example:

$URL = "http://webapp"
$sites = get-spweb $URL
foreach($site in $sites)
{
  $lists = $sites.Lists
    foreach($list in $lists)
         {
             $column = $list.Fields["columnname"]
             $column.ShowInEditForm
             $v = $column.ShowInEditForm
             if($v -eq $false)
              {write-host $list.title }
          }
}

However, I find that the $column.ShowInEditForm is null by default. If you have use powershell to set this attribute, then it should work.

Regards,

Free Windows Admin Tool Kit Click here and download it now
April 21st, 2015 1:38am

Thanks, have run this in test and got zero results (or zero write-host output).
Do we need to be checking the internal column name?
The column name is Function. I changed your ["columnname"] but nothing.

Also, how do I also include a check for the view properties form as well as edit properties?

April 21st, 2015 11:11pm

Hi,

How about testing the script on specific list:

$site = get-spweb http://siteurl
$list = $site.Lists["listcolumn"]        
$column = $list.Fields["fieldname"]
$column.ShowInEditForm

If that doesn't show any value, then try this script to set the value firstly:

$site = get-spweb http://sp:60/sites/first
$list = $site.Lists["ListA"]        
$column = $list.Fields["test"]
$column.ShowInEditForm = $false
$column.Update()
$list.Update()
$list.Dispose()

Then close the ShellManagement window and check if the column is hidded in Edit form. If it makes sense, use the first script to run it again.

Regards,

Free Windows Admin Tool Kit Click here and download it now
April 22nd, 2015 10:17pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics