Microsoft Virtualization Discussions

Is there a way to get the currently connected controller ?

raol
4,292 Views

I am creating a script to create volumes... The input list consists of Filer name/volume name/aggregate name/size/etc in a csv format.... This list could span multiple controllers and plan on sorting the entries by Filer name...

In my volume creation loop I will take a line from the CSV input file and process it...

I don't want to do Connect-NAController for each entry... what I would like to do is skip the connection part if the Filer name is the same as the currently connected Filer...

Is there a way to find out what the currently connected filer is ?

Thanks

Mayur

1 ACCEPTED SOLUTION

raol
4,292 Views

Looks like I may have found the answer to my question...

There is a variable $CurrentNAController.... and I can compare my Filer name to $CurrentNAController.Name

Going to try it out and see how I fare...

Thx

View solution in original post

3 REPLIES 3

raol
4,293 Views

Looks like I may have found the answer to my question...

There is a variable $CurrentNAController.... and I can compare my Filer name to $CurrentNAController.Name

Going to try it out and see how I fare...

Thx

vinith
4,292 Views

Are you looking for something like this 

$controllerdetails = Get-Content "c:\vinith\desktop\controllerdetails.csv"

foreach ($control in $controllerdetails)

{

if (($global:CurrentNaController).name -match $control.filername)

  {

New-NaVol -Name $control.volumename ....(continued syntax)...

  }

else

{

Connect-NaController $control.filername ...(continued syntax)......

New-NaVol -Name $control.volumename ..(continued syntax).....

}

}

raol
4,292 Views

Thank you Vinith...

Yes, that is what I was looking for... I actually made my code simpler and more compact rather than duplicate the volume creation code.... below is what I used...

 

If ($CurrentNAController.Name -ne $Filer) { Connect-NaController $Filer -Credential $Cred }

New-NaVol.......

Mayur

Public