Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have this PowerShell script

function SetPropertyBag ($webAppUrl, $key, $value) {

    $spwebApp=Get-SPWebApplication -Identity $webAppUrl
    Write $spwebApp  

    if($spwebApp.Properties.ContainsKey($key) -eq $False)
    {
        $spwebApp.Properties.Add($key,$value);        
    }
    else
    {$spwebApp.Properties[$key]=$value; }

    Write-Host -foregroundcolor Green "value set in "  $key  " = "  $spwebApp.Properties[$key]    

    }

$webAppUrl= Read-Host 'Enter the web application url';
$siteCollectionUrl= Read-Host 'Enter the site collection url';
SetPropertyBag $webAppUrl "VGSP.VIS.TicketTale.EngineJob" $siteCollectionUrl ;

It's working great on PowerShell but when i try to get the property bag value by server side code I don't find.

I also deployed the property bag settings solution and didn't find the values that I've set there either.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted
$spwebApp.AllProperties.Update();
share|improve this answer
    
Method invocation failed because [System.Collections.Hashtable] doesn't contain a method named 'Update'. At C:\Users\Alshimaa\Desktop\PropertyBagSetter.ps1:19 char:32 + $spwebApp.Properties.Update <<<< (); + CategoryInfo : InvalidOperation: (Update:String) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound –  mshmshcs Sep 9 '12 at 13:15
    
It is actually recomanded to use AllProperties instead as Properties is only maintained for back-compatibility purposes and is obsolete! –  C. Marius - MVP Sep 9 '12 at 16:10
    
Thanks @c-marius, updated the answer to use AllProperties –  eirikb Sep 9 '12 at 19:07
add comment

Just had the same problem. Solution:

$spwebApp.Update();

The solution suggested by eirikb does not work because:

  1. The SPWebApplication object does not have a property called "AllProperties".
  2. It does have a property called "Properties" (as written by the OP), however this property does not have an Update() method.

(Note: I'm using SP2010)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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