PowerShell script connecting to a secondary server for archive management

Discussion created by JeffHopper on Aug 30, 2013
Latest reply on Sep 6, 2013 by Gregor

I'm working on a script which is doing the moving of older archives to a slower disk location and focusing in on testing this against a secondary PI Server.  There is a similar sample script for PI connection that's sent with powershell -





     [Parameter(Position=0, Mandatory=$true)]
     [string] $PIServerName,

     [Parameter(Position=1, Mandatory=$true)]
     [DateTime] $MoveArchivesOlderThan,

     [Parameter(Position=2, Mandatory=$true)]
     [string] $MoveToLocation,

     [Parameter(Position=3, Mandatory=$false)]
     [string] $MemberName,         # <--- this is a new line -- added param for the collective member name

     [Parameter(Position=4, Mandatory=$false)]
     [switch] $MakeReadOnly = $false)

# Get the PI server object, exit if there is an error retrieving the server
$PIServer = Get-PIServer -Name $PIServerName -ErrorAction Stop

if ($PIServer.IsConnected -eq $false)
{   if ($MemberName = "")                        # (<--- this is a new line) Check if a collective member name was provided.
          $PIServer = Connect-PIServer -PIServer $PIServer -ErrorAction Stop
          $PIServer = Connect-PIServer -PIServer $PIServer -MemberNode $MemberName -ErrorAction Stop

When passing in the secondary server name into the $MemberName, it is still returning the connection to the primary server.  I'm guessing this is either a bug, or I need to use this differently... I can accept either!