Friday, February 18, 2011

Proxy Settings in Machine.Config

With the our migrations to SharePoint 2010, decided to move our proxy settings to the machine.config files as opposed to web.configs. The infrastucture guys change the URL too often (they alse haven't provided us with a DNS entry) which means we have to edit the config files of multiple web applications and extensions.

Steps required:

1. Add the following to the machine.config:


  <system.net>

    <defaultProxy useDefaultCredentials="true">

      <proxy usesystemdefault="False" proxyaddress="http://proxy.address" bypassonlocal="True" />

    </defaultProxy>

  </system.net>





2. Remove the defaultProxy from section from your web.config files.


PS. The machine.config to edit can be found at: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG.

Thursday, February 17, 2011

Add New Web Part to Web Part Gallery Broken?

I have a site in SharePoint 2010 running in 2007 mode (don't ask me why? ask the business users). It seems there may be a bug when in the web part gallery that does not allow you to add new web parts (in 2007 mode only). I had a look through the page source and there is definitely some issues with the javascript on the "New" button.

Hopefully, we won't be in 2007 mode for too long, so we are just gonna roll with a workaround. Go to following page and you can add web parts to the web part gallery:

http://{siteurl}/_layouts/NewDwp.aspx

Monday, October 18, 2010

SharePoint 2010 Modifying UI Version in PowerShell

To change UI version of a SharePoint 2010 site between 2007 and 2010 you can use the following PowerShell code:

$site = Get-SPSite -identity http://{site url}

To 2007 mode:

$site | Get-SPWeb -limit all | ForEach-Object { $_.UIversion = 3; $_.UIVersionConfigurationEnabled = $false; $_.update(); }

To 2010 mode:

$site | Get-SPWeb -limit all | ForEach-Object { $_.UIversion = 4; $_.UIVersionConfigurationEnabled = $false; $_.update(); }

Wednesday, October 6, 2010

PowerShell - Stopping the annoying confirm messages

To stop those annoying confirm messages (i.e. "Are you sure you want to perform this action?") , do this:

$ConfirmPreference = "None"


the end

Looping through all SharePoint 2010 sites with PowerShell

Just needed to loop through all SPS2010 sites and disable and enable a feature. The following PowerShell script does this. (this outputs the site url so I can observe the progress)


$site = Get-SPSite -identity http://{siteurl}


$site | Get-SPWeb -limit all | ForEach-Object { Write-Host $_.Url; Disable-SPFeature -Identity {featureid} -url $_.Url; Enable-SPFeature -Identity {featureid} -url $_.Url }

Friday, October 1, 2010

SharePoint 2010: One or more field types are not installed properly

We started migrating our old SharePoint 2007 sites to SharePoint 2010. It all has been going pretty smoothly, until we found a pesky little problem when creating new subsites:

"One or more field types are not installed properly. Go to the list settings page to delete these fields."

Not much more detail in the ULS logs to describe which field is not installed properly. After some Googling and experimentation the problem was determined to be the changes between SharePoint 2007 and 2010 in the "Relationship List" (http://{siteurl}/Relationships%20List/AllItems.aspx).

Basically to fix the problem, you need to deactivate the SharePoint Server Publishing Infrastructure feature, delete the relationship list and reactivate the SharePoint Server Publishing Infrastructure feature.

The following PowerShell is all you need:

Disable-SPFeature -Identity F6924D36-2FA8-4f0b-B16D-06B7250180FA -Url http://{siteurl}


$site = Get-SPSite -Identity http://{siteurl}

$site.RootWeb.GetList("Relationships List").Delete()


Enable-SPFeature -Identity F6924D36-2FA8-4f0b-B16D-06B7250180FA -Url http://{siteurl}

Wednesday, June 30, 2010

Add Proxy Settings to web.config file of SharePoint with Powershell

I recently needed to modify the default proxy settings in the web.config file of our SharePoint apps. This was done manually to start with, but after many deployments in multiple environments, doing this manually was a chore and often forgotten. I therefore worked on the following PowerShell script that did what we needed.

The following script changes the default proxy settings of:


  <system.net>

    <defaultProxy>

      <proxy autoDetect="true" />

    </defaultProxy>

  </system.net>




to:


  <system.net>

    <defaultProxy useDefaultCredentials="true">

      <proxy usesystemdefault="False" proxyaddress="http://proxy.address" bypassonlocal="True" />

    </defaultProxy>

  </system.net>




Sorry about the crappiness of the cut-and-paste, but this might give you enough help to get you going:


function AddWebConfigModification([Microsoft.SharePoint.Administration.SPWebApplication] $webApp=$(throw 'Parameter -webApp is missing!'),

                                  [string] $name=$(throw 'Parameter -name is missing!'), 

                                  [string] $path=$(throw 'Parameter -path is missing!'), 

                                  [string] $owner=$(throw 'Parameter -owner is missing!'), 

                                  [string] $sequence=0, 

                                  [Microsoft.SharePoint.Administration.SPWebConfigModification+SPWebConfigModificationType] $modificationType=$(throw 'Parameter -modificationType is missing!'), 

                                  [string] $value=$(throw 'Parameter -value is missing!'))

{

    $modification = New-Object -TypeName "Microsoft.SharePoint.Administration.SPWebConfigModification";

    $modification.Name = $name;

    $modification.Path = $path;

    $modification.Owner = $owner;

    $modification.Sequence = $sequence;

    $modification.Type = $modificationType;

    $modification.Value = $value;    

    $webApp.WebConfigModifications.Add($modification);    

}

 

function AddProxySettings([string]$url=$(throw 'Parameter -url is missing!'))

{

    $webApp = GetWebApp($url);    

    $owner = "GUID_HERE";    

    $ensureAttribute = [Microsoft.SharePoint.Administration.SPWebConfigModification+SPWebConfigModificationType]::EnsureAttribute; 

 

    AddWebConfigModification -webApp $webApp -owner $owner -modificationType $ensureAttribute -path "configuration/system.net/defaultProxy" -name "useDefaultCredentials" -value "true";

    AddWebConfigModification -webApp $webApp -owner $owner -modificationType $ensureAttribute -path "configuration/system.net/defaultProxy/proxy" -name "usesystemdefault" -value "False";

    AddWebConfigModification -webApp $webApp -owner $owner -modificationType $ensureAttribute -path "configuration/system.net/defaultProxy/proxy" -name "proxyaddress" -value "http://proxy.address";    

    AddWebConfigModification -webApp $webApp -owner $owner -modificationType $ensureAttribute -path "configuration/system.net/defaultProxy/proxy" -name "bypassonlocal" -value "True";    

    AddWebConfigModification -webApp $webApp -owner $owner -modificationType $ensureAttribute -path "configuration/system.net/defaultProxy/proxy" -name "autoDetect" -value "True";    

 

    [Microsoft.SharePoint.Administration.SPWebService]::ContentService.ApplyWebConfigModifications();

}