Microsoft Virtualization Discussions

Confused b/c invoke-nassh is lying to me....

JGPSHNTAP
5,375 Views

Ok, I'm stumped ...  Putting my script aside, i'm just doing basic work here and it's giving me fits..

Connect-nacontroller $filer

I confirm connection $global:currentnacontroller for sanity check

And then I am just typing a basic command...

invoke-nassh -command "snmp init 0"

And I'm getting thrown this error..

Invoke-NaSsh : Value cannot be null.

Parameter name: Credentials not provided in cmdlet argument, specified controller, or credentials cache.

At line:1 char:13

+ invoke-nassh <<<<

    + CategoryInfo          : InvalidArgument: (:) [Invoke-NaSsh], ArgumentNullException

    + FullyQualifiedErrorId : CredentialsNotSpecified,DataONTAP.PowerShell.SDK.Cmdlets.Toolkit.Ssh.InvokeNaSsh

It's frustrating me to no end!! 

1 ACCEPTED SOLUTION

cknight
5,375 Views

Thanks for confirming you use RPC; that makes sense.  Making an RPC connection to a controller is immaterial to using Invoke-NaSsh.  RPC doesn't need explicit credentials, while SSH does.  Both Connect-NaController and Invoke-NaSsh consult the credentials cache, which is why SSH is working for you now.  You could have done any number of things, such as:

* Rely on $global:CurrentNaController using an HTTP/HTTPS connection

Connect-NaController <filer> -HTTPS -Credential <xxx>

Invoke-NaSsh <command>

* Populate the cache

Add-NaCredential <filer> -Credential <xxx>

Invoke-NaSsh <command>

* Specify creds & controller

Invoke-NaSsh -Name <filer> -Credential <xxxx> -Command <command>

* Use a controller variable, as in a loop, without setting the global variable

$filer = Connect-NaController <filer> -HTTPS -Credential <xxx> -Transient

Invoke-NaSsh -Controller $filer -Command <command>

Keep in mind that with the credentials stored in the cache, Connect-NaController will now find that first and establish HTTPS (falling back to HTTP) connections unless you specify -RPC.

View solution in original post

5 REPLIES 5

cknight
5,375 Views

How are you connecting to the controller?  If you're using RPC, note that SSH is a separate protocol that requires credentials, so you'd have to provide those explicitly.  I'm not sure what else can lead to this condition.

JGPSHNTAP
5,375 Views

Clinton,

I am connecting to the filer via rpc.   But if i add the filers via add-nacredential -systemscope invoke-nassh works. 

I think that my concept is wrong.    I am connecting to the controller as above but then invoking nassh.   Thats i think whats throwing me off.

essentially i dont need to connect to controller via connect-nacontroller before i launch the invoke ssh cmdlet. 

cknight
5,376 Views

Thanks for confirming you use RPC; that makes sense.  Making an RPC connection to a controller is immaterial to using Invoke-NaSsh.  RPC doesn't need explicit credentials, while SSH does.  Both Connect-NaController and Invoke-NaSsh consult the credentials cache, which is why SSH is working for you now.  You could have done any number of things, such as:

* Rely on $global:CurrentNaController using an HTTP/HTTPS connection

Connect-NaController <filer> -HTTPS -Credential <xxx>

Invoke-NaSsh <command>

* Populate the cache

Add-NaCredential <filer> -Credential <xxx>

Invoke-NaSsh <command>

* Specify creds & controller

Invoke-NaSsh -Name <filer> -Credential <xxxx> -Command <command>

* Use a controller variable, as in a loop, without setting the global variable

$filer = Connect-NaController <filer> -HTTPS -Credential <xxx> -Transient

Invoke-NaSsh -Controller $filer -Command <command>

Keep in mind that with the credentials stored in the cache, Connect-NaController will now find that first and establish HTTPS (falling back to HTTP) connections unless you specify -RPC.

JGPSHNTAP
5,375 Views

Yeah, i was under the assumption that it talks to the credentials cache after it was working.. It just didn't register in my brain fast enough!

Yeah, I can totally add to the credentials cache.  I have the logic in place to handle that as per system login/ID,...

I'm gonna play around and let you know..

JGPSHNTAP
5,375 Views

Clinton...

I'm all worked out.. I went with your approach.

$filer = Connect-NaController <filer> -HTTPS -Credential <xxx> -Transient

Invoke-NaSsh -Controller $filer -Command <command>

I had it, but was totally blinded that I was connecting via rpc!

Thx for clearing that up with me...

Public