locked
Set web properties using powershell command RRS feed

  • Question

  • Hi,

    Can anyone help me with powershell or stsadm commands for setting web properties of Site collections and subsites in SharePoint 2007?

    TIA

    Thursday, October 5, 2017 12:18 PM

Answers

  • I achieved it using this:
    Set-ExecutionPolicy RemoteSigned
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
    
    $fullUrl = 'http://mysite.com/ABC/X'
    $site = New-Object -Type Microsoft.SharePoint.SPSite -ArgumentList $fullUrl
    $web = $site.OpenWeb()
    
    $web.Properties["My_Key"] = "https://mynewsite.com/"
    $web.Properties.Update()
    
    $web.Dispose()
    $site.Dispose()

    • Marked as answer by Kodnil Wednesday, October 11, 2017 2:03 PM
    Wednesday, October 11, 2017 8:26 AM

All replies

  • SharePoint 2007 only used STSADM.  PowerShell support was set-up for 2010 wit STSADM being a deprecated feature.

    However according to this blog, if you're running MOSS on Server 2003 (and possibly later) you can get PS to work with it via a few tweaks.  As a disclaimer I've never tried this before so I'm not sure what your set of options might be.

    https://blogs.technet.microsoft.com/praveenh/2013/01/21/running-powershell-on-moss-2007/

    For STSADM the literature that details what it can do natively can be seen here

    https://technet.microsoft.com/en-us/library/cc263384(v=office.12).aspx.  Using ctrl-f on this (find function) using the word "Set" returns 97 results for me so you may have some flexibility via batch files here.  It's been about nine years since I've used STSADM though so I can't recall really how flexible it is.


    Steven Andrews
    SharePoint Business Analyst: LiveNation Entertainment
    Blog: baron72.wordpress.com
    Twitter: Follow @backpackerd00d
    My Wiki Articles: CodePlex Corner Series
    Please remember to mark your question as "answered" if this solves (or helps) your problem.

    Thursday, October 5, 2017 1:20 PM
    Answerer
  • I achieved it using this:
    Set-ExecutionPolicy RemoteSigned
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
    
    $fullUrl = 'http://mysite.com/ABC/X'
    $site = New-Object -Type Microsoft.SharePoint.SPSite -ArgumentList $fullUrl
    $web = $site.OpenWeb()
    
    $web.Properties["My_Key"] = "https://mynewsite.com/"
    $web.Properties.Update()
    
    $web.Dispose()
    $site.Dispose()

    • Marked as answer by Kodnil Wednesday, October 11, 2017 2:03 PM
    Wednesday, October 11, 2017 8:26 AM