Subscribe
Accepted Solution

read from multiple filers

I am after a script that will provide data from multiple filers

I can use this:

Get-NaVol -Controller (get-content c:\filers.txt)

The problem is that each filer in that list has different credentials. Is there a way to store the credentials in a file and somehow let PoSh read it?

something like:

Connect-NaController -Name (get-content c:\filers.txt) -Credential (get-content c:\credentials.txt)

Thank you

Joel

Re: read from multiple filers

Joel

No you can't do that.  You need to create credential objects.  But, i have to be honest, each controller has a different login?  How is that scalable?  How many controllers are you talking about?

Also, it's easier to manage your script if you put the filers into a variable and then loop them through a for loop to control the script a little easier in my opinion

$filers = gc c:\temp\filers.txt

$filers | % {

$filer = $_

$c = connect-nacontroller $filer

(script here)

}

Re: read from multiple filers

The Toolkit provides cmdlets for storing credentials.  Check out the following cmdlets:

PS C:\> help *NaCredential

Name                              Category  Synopsis

----                              --------  --------

Add-NaCredential                  Cmdlet    Save login credentials for a Data ONTAP controller.

Get-NaCredential                  Cmdlet    List entries in the credentials cache.

Remove-NaCredential               Cmdlet    Remove saved login credentials for a Data ONTAP controller.

Connect-NaController and Connect-NcController will automatically use the credentials cache.  For example, we can add the credentials for 10.61.169.28, then use Connect-NaController to connect without having to provide credentials:

PS C:\> Get-NaCredential 10.61.169.28

PS C:\> Add-NaCredential 10.61.169.28 -Credential root

Name                                    Credential                              HostUser

----                                    ----------                              --------

10.61.169.28                            System.Management.Automation.PSCrede...

PS C:\> Connect-NaController 10.61.169.28

Name                 Address           Ontapi   Version

----                 -------           ------   -------

10.61.169.28         10.61.169.28      1.13     NetApp Release 8.0.1 7-Mode: Wed Jan  5 17:24:41 PST 2011

-Steven

Re: read from multiple filers

Ah.. I totally forgot about add-nacredetial to the credential cache.. It's been so long since I used that.. Good catch steve

Re: read from multiple filers

thanks guys

can we also cache the password or I need to provide it every time it tries to access the filer?

Joel

Re: read from multiple filers

Once you connect to a controller using connect-nacontroller in a powershell session, just do add-nacredential after that, no you don't need to provide it everytime to access the filer.

Even if you close the powershell window and re-open it again it would still be cached.

Re: read from multiple filers

Thanks

"Once you connect to a controller...."

So I need to connect to all the controllers first? I cannot put the passwords in a file and let the script read it when trying to connect?

Re: read from multiple filers

Yes you would need to connect to all controllers first and do a "Add-Nacredential" to cache all of them, also let me figure out a way to iterate through all passwords in a txt file and connect, i would update you on that soon.

Re: read from multiple filers

should be something like this:

$CredsFile = "C:\PowershellCreds.txt"

$password = get-content $CredsFile | convertto-securestring

Re: read from multiple filers

No, you can't do that

Let's backstep.  How many controllers are you talking about and how many different logins?

Also, like I said in my previous post, unless there is specific business reasons what your doing is not scalable.   

What I would recommend is use a standard service account throughout your filers.