2

I have a new SharePoint deployment we are in the process of upgrading from SP2007 to SP2010. During the visual upgrade a lot of the branding element have been broken and the organisation has a requirement to maintain look and feel as much as possible. I am testing the upgrade process on a Dev server prior to conducting a full migration and upgrade of the live environment.

To fix the UI issues I have been using the following powershell script on the broken sites:

$web = get-spweb <URL goes here>
$web.UIVersion = 3
$web.UIVersionConfigurationEnabled = $true
$web.Update()

This works but I currently have to run the script with a new URL on every broken site I find. Is there any way I can modify the script to accept a list of URLs and modify them all at once?

6

You can use a text file to get the list of Web URLs, and loop through this list in PowerShell

UPDATED POWERSHELL SNIPPET

Get-Content 'FULL PATH\\FILENAME.txt' | Foreach-Object {
$web = get-spweb $_
$web.UIVersion = 3
$web.UIVersionConfigurationEnabled = $true
$web.Update()
$web.Dispose()
}

Its better to dispose the $web object after the operation is done.

Content of the text file should be URLs of sites in each line

http://site1url
http://site2url
http://site3url
  • Thanks this works well. One tip for anyone else using this method. Be careful to not leave any whitespace under your URL list. Always make sure your cursor is at the end of the final line when you save or your script will throw null entity errors when you run it. – JonS Aug 2 '17 at 11:42
  • 1
    @JonS: You could ensure there are no whitespaces trailing the url by setting the second line of code to $web = get-spweb $_.Trim() – Nils Aug 2 '17 at 14:57
3
@("url.1", "url.2") | %{
   $web = get-spweb $_
   $web.UIVersion = 3
   $web.UIVersionConfigurationEnabled = $true
   $web.Update()
} 

consider using try/finally in combination with $web.Dispose() if you have many urls...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.