PI TreeView WebPart deployment using Windows PowerShell Script

Discussion created by davidwsmith@bhi on Feb 8, 2011
Latest reply on Dec 20, 2011 by pkaiser

Please find the attached power shell script to add PI tree view webpart and set the tree view webpart parameter( using PI WebParts 2010). I want to add this webpart on SharePoint webpart page and set the below mentioned properties using power shell. With the attached script, I am able to add the webpart but not able to set the mentioned properties. I dig into OSIsoft.RtWebParts.RtTreeView.TreeViewWP assembly using reflector and tried few options to set the properties. All this properties are public and should able to do set/get




# core part of the code for reference.




[System.Web.UI.WebControls.WebParts.WebPart] $webpart


      $webpart = new-object  OSIsoft.RtWebParts.RtTreeView.TreeViewWP


      OSIsoft.RtWebParts.RtTreeView.TreeViewWebPartProperties] $webpartProp


      $webpartProp = $webpart.TreeViewProperties




      $webpart.TreeViewProperties.LevelsToDisplay.CurrentValue ="1"


      $level = $webpart.TreeViewProperties.LevelsToDisplay






$webpartmanager.AddWebPart($webpart, $zone, $index)






But it is not working.




Properties that need to be set using power Shell.





Root Node Of Tree:


Invalid path to AF object

Default Selected Node:


AF element not found


     Display Properties



Number Of Levels Initially Loaded

Must be greater than zero.


Number Of Levels Initially Displayed

Must be greater than or equal to zero.


Maximum Number Of Levels To Display



To run the Script:


1.       Upload the attached psTest.aspx in SharePoint document library


2.       Use the name of your SharePoint document library in – SPLibrary parameter


3.       Copy the attached Add-PITreeViewWebPart.ps1 to local folder and r Go to power shell command prompt and type


./Add-PITreeViewWebPart -url "http://bhihouscr01:5555/sites/EncanaTest" -SPLibrary "Site%20Pages"  -pageName "psTest.aspx" -zone "Left" -index 1


More details are included in the script.




Please see the below screenshots showing tree view properties.








I also want to know in case of connecting WebParts which properties need to be set here.