This is just a quick note to ask the question

Are you using Powershell when developing your WSS application ?

Cos if your not your missing a trick.

When I build a SharePoint App that comes complete with data, for example you have a list definition and in the Elements file it pre-populates all your Admin Users and their details.  Thing is if you using multiple deployment platforms for testing etc, Dev,Uat, Live for example then those values may not be the same on all platforms.

So do you have 3 different builds ?  Thus you have not tested your live build when it comes to deploy it ?

Then this is when Powershell is really handy.  Because of the great .NET integration you can just access the Object model in Powershell and modify all the data you created.

Here is an example script I use, it trashes and recreates a site collection and then manipulates the list data from the original (live ready) values to dev ones.

#Powershell can call stsadm provided its rigged up correctly to know where the PATH is
stsadm -o deactivatefeature   -url http://moss.binaryjam.com/apps/JAM -name BinaryJam.JammyApplication
stsadm -o deletesite -url http://moss.binaryjam.com/apps/JAM
stsadm -o createsite -url “http://moss.binaryjam.com/apps/JAM” -title “JAM” -ownerlogin “homesimon” -owneremail comments@binaryjam.com -sitetemplate “sts#1” 
stsadm -o activatefeature   -url “http://moss.binaryjam.com/apps/JAM” -name BinaryJam.JammyApplication

$site= new-object Microsoft.Sharepoint.SPSite(“http://moss.binaryjam.com/apps/JAM”)
$web=$site.RootWeb
$list = $web.Lists[“MyMainList”]

#My Site has an SPGroup so add some users to it
$super = $web.Groups[“My Super Users”];
$super.AddUser(“hometheWife”, “wife@nosuchmail.com”, “Wife, The”, “”);
$super.AddUser(“hometheCat”, “cat@nosuchmail.com”, “Cat, The”, “”);

#If there is an email then change it 
foreach ($item in $list.items )
{
    $needsUpdate = $false

      if ($item[“UsersEmail”])
      {
          if ($item[“UsersEmail”].ToString().Length -gt 0)
          {
              $item[“UsersEmail”] = “adminmain@nosuchmail.com”
              $needsUpdate = $true
          }
      }
      if ($item[“UsersName”])
      {
          if ($item[“UsersName”].ToString().Length -gt 0)
          {
              $item[“UsersName”] = “DevSystemUserName”
              $needsUpdate = $true
          }
      }

      if ($needsUpdate -eq $true)
      {
          $item.Update()
      }
  }

Advertisements