NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform.
You will still be able to view content, but posting and replying will be temporarily disabled.
To learn more, please review the information in this blog post.

Microsoft Virtualization Discussions

read from multiple filers

JSHACHER11
10,964 Views

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

1 ACCEPTED SOLUTION

beam
10,962 Views

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

View solution in original post

11 REPLIES 11

JGPSHNTAP
10,829 Views

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)

}

beam
10,963 Views

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

JGPSHNTAP
10,829 Views

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

JSHACHER11
10,829 Views

thanks guys

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

Joel

vinith
10,829 Views

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.

JSHACHER11
10,829 Views

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?

vinith
10,829 Views

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.

JSHACHER11
10,829 Views

should be something like this:

$CredsFile = "C:\PowershellCreds.txt"

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

JGPSHNTAP
10,829 Views

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. 

JSHACHER11
9,438 Views

Let's say for example that I have 8 filers (4 pairs) and I want some daily reports, snapmirror Lag for example or volumes and aggregates over 90% full. I'm looking for a 'one click' report

JGPSHNTAP
9,438 Views

Ah.. that's easy man...  We have 200+ filers, so automation is a key for us.

But you have to start small... Look at the report i wrote on volumes and aggrs man.

Start with creating a script service account that is consistent across all your filers.  Also, dare i ask, why you have so many logins?

Public