All posts in PowerShell

Make Hidden SharePoint Fields Visible Again

There are times when you set a field to visible (optional or required) in the GUI, yet it refuses to show up on the list\library.  This seems to occur if your content type inherits from a parent that has the field hidden.  If you attempt to make the child content type field visible again it doesn’t seem to cascade down into the list instance of the content type and thus your field never shows up on the list.

So you think, “ok, I’ll just use PowerShell”.  You’re on the right track, but there is more to it than meets the eye.

if you run the following code:

$spWeb = Get-SPWeb "http://teams.drevdevsp2013.com";
$spList = $spWeb.Lists["My Documents"];
$spField = $spList.Fields["Keywords"]
$spField.Hidden=$false;

You are going to get the following error message:

Exception setting “Hidden”: “Cannot change Hidden attribute for this field”

ErrorMessage

What you don’t realize is that when this particular problem occurs, there is an internal field that you can see in the field xml, but is not part of the regular properties called CanToggleHidden.  As it sounds, the purpose of this field is to ensure the field can’t be enabled.

But wait!!  There’s hope.

There’s a method that can be used called SetFieldBoolValue.  It allows us to modify that value.  If you do a little research on it, the method is listed in technet.  But it’s one of those: “It’s there but you shouldn’t use it” kind of methods.  Well in this case we have to use it.  The only way to get to it is via the Reflection namespace as follows:

$spWeb = Get-SPWeb "http://teams.drevdevsp2013.com";
$spList = $spWeb.Lists["My Documents"];
$spField = $spList.Fields["Keywords"]
$fieldType = $spField.GetType();

#Access the "hands off method" via reflection namespace
$hiddenMethod = $fieldType.GetMethod("SetFieldBoolValue",
    [System.Reflection.BindingFlags]$([System.Reflection.BindingFlags]::NonPublic -bor
    [System.Reflection.BindingFlags]::Instance));

#update the can toggle field using our newly aquired method
$hiddenMethod.Invoke($spField, @("CanToggleHidden",$true));

#Now that the hidden toggle is open we can make the field to visible
$spField.Hidden=$false;
$spField.Update();

Once you have completed the script you will find your field is visible again.

Thanks for reading!

Quickly Build a Multi-Server SharePoint 2013 Developer Environment (Part 3) – Configure SP SQL Server

As I had stated in part 1 of this series, I was reviewing Vlad Catrinescu’s series on creating a dev environment quickly and effortlessly. I think it’s a great post, but it is a single server environment and I wanted to setup a multi-server farm. That is what brought me to create this series. My first post has the architecture of the build if you are starting here and want to review. I also suggest you review the second part of the series as it contains the prep steps I outlined in the first post as well to prepare you for the steps in this post (it’s also important as we deploy your Active Directory and DNS there).  In this post we will Configure the SP SQL Server.

Posts in this series:

Read more

Quickly Build a Multi-Server SharePoint 2013 Developer Environment (Part 2) – Domain Controller

Welcome to Part 2 of my “Quickly Build a Multi-Server SharePoint 2013 Developer Environment” blog post series. The idea for this series of posts started while I was reading Vlad Catrinescu’s blog about building a single server environment. It’s a great blog post, but I wanted a multi-server installation so decided to write a series of posts to describe the process of accomplishing this. If you’re wanting to build out a multi-server developer environment, the information in this series will help you achieve this..

In Part 1 I outlined the environment, showed you how to create and configure your VMs with PowerShell and walked you through installing Windows Server 2012. Click here to review that post. In this post I am going to show you how to configure your Domain Controller and Active Directory environment.

Posts in this series:

 

Read more

Quickly Build a Multi-Server SharePoint 2013 Developer Environment (Part 1) – Provisioning VMs

The other day I was taking a look at Vlad Catrinescu’s blog on quickly creating a SharePoint 2013 dev farm. It’s a great blog and provides some good information on creating a dev environment much faster than you could ever do it manually.  I like to develop in an environment as similar to the production environment as possible and I also have the hardware to do it. With this in mind I wanted to come up with a way to quickly build a multi-server SharePoint 2013 developer environment. The problem is that for a single server install you could be looking at hours to install and configure, a multi-server environment could take even longer. I set out to build scripts that would not only deploy the SharePoint environments but would also create the VMs, deploy Active Directory and SQL Server, and configure the network. In addition, I wanted to be able to do this more than once (as different environments are sometimes needed at different times).

Read more

Quickly Build a Multi-Server SharePoint 2013 Developer Environment (Part 5) – AutoSPInstaller Answer File

In part five of my building a multi-server SharePoint dev environment series we are going to install SharePoint 2013.  But first I am going to cover how to create the AutoSPInstaller Answer File. We will do this using the AutoSPInstaller online tool.  There isn’t a lot of information out there on it (that I could find) so I hope it is helpful.  I am going to go through each area in pretty decent detail, but to make things easier for you, I will also provide my answer file that you can easily modify for your needs.  Once we have finished creating the answer file I will show you how to kick off the install of SharePoint.

Posts in this series:

 

Read more