Accepted Solution

Unable to combine

I querying the active snapmirror jobs of two filers. After that I want to combine the output sets into one to be able to do some stuff with them in a single loop.

Unfortuately PS don't allow me to add the output from the second command to the result from the first command.

As I'm quite new to PS and the DataOntap Module I want to ask if someone can give me a hint.

Cheers, Danny

My Code:


     $filer1 = Connect-NaController filer1

     $filer2 = Connect-NaController filer2

     $ret1 = Get-NaSnapmirror -controller $filer1
     $ret2 = Get-NaSnapmirror -controller $filer2
     $ret = $ret1
      $ret += $ret2


Re: Unable to combine

Hi Danny,

I recommend managing multiple 7-mode controllers using the following technique:

# Declare an array where we will store 7-Mode controller connections.

$7modeControllers = @()

# Connect to our controllers and store them in our array (assumes that

# credentials are cached). You could connect to many controllers here.

$7modeControllers += Connect-NaController -Transient

$7modeControllers += Connect-NaController -Transient

# Iterate through the 7-mode controllers we connected to and retrieve a

# list of aggregates from them.

foreach ($controller in $7modeControllers) {

    # use the global variable to identify the current controller.

    $global:CurrentNaController = $controller

    # Now every other command you run will use the current controller.



This approach allows you to do your work on each controller in a single loop no matter how many controllers you are managing.  You essentially perform the task as if you're using a single controller inside the foreach loop.  It's also a nice approach because you can work out your logic for one controller and then just drop it into the loop to scale it out, and you don't need to build up collections of objects in variables for processing, other than the connected controller collection of course.

Kirk out.