Community

Subscribe
Highlighted
Accepted Solution

first script

Hi guys,

I started playing with powershell this week - I've tried to run the following but getting this:

"the size of the volume is DataONTAP.Types.Volume.SizeInfo"

the script is:

Import-Module dataontap

$filername = Read-Host 'What is the filer hostname?'

$name = Read-Host 'What is your username?'

Connect-NaController -Name $filername -Credential $name

$volname = Read-Host 'What is the volume name?'

$volsize = Get-NaVolSize -Name $volname

Write-Host "the size of the volume is:" $volsize

my debugger is saying that my problem is in this line:

$volsize = Get-NaVolSize -Name $volname

Thank you

Re: first script

Make sure you set your execution policy to unrestricted.

Is your storage controller joined to the domain?  If so, then is your domain account (logged on with) a member of the storage controllers administrator's group?

     If yes, then:

Import-Module dataontap

$filername = Read-Host "What is the filer hostname?"

Connect-NaController -Name $filername | out-null

$volname = Read-Host "What is the volume name (case sensitive)?"

$volsize = Get-NaVolSize $volname

Write-Host "The size of the volume is:"$volsize.volumesize

If no, then:

Import-Module dataontap

$filername = Read-Host "What is the filer hostname?"

Connect-NaController -Name $filername -Credential (get-credential) | out-null

$volname = Read-Host "What is the volume name (case sensitive)?"

$volsize = Get-NaVolSize $volname

Write-Host "The size of the volume is:"$volsize.volumesize

Re: first script

no go

Thanks though

Re: first script

Hello,

In the below scriptlet you are connecting to the controller only with username, you are not entering the password

$name = Read-Host 'What is your username?'

Connect-NaController -Name $filername -Credential $name

Try with the below method

$name = Read-Host 'What is your username?'

$password = Read-Host 'What is your Password?'

$ControllerPassword = ConvertTo-SecureString -String $password -AsPlainText -force

$credential = New-Object System.Management.Automation.PsCredential($name,$ControllerPassword)

Connect-NaController -Name $filername -Credential $credential

Re: first script

this line (Connect-NaController -Name $filername -Credential $name) brings up a popup that asks for a password. I insert the password and the script moves on

Again, my debugger is pointing to this line:

$volsize = Get-NaVolSize -Name $volname

Thank you

Re: first script

what are you giving as input to $volume, can you share an example?

Here's the output when i ran your set of cmdlets.

Re: first script

I've tried with a volume I created, called vol7 and also with vol0

Re: first script

I am late to the discussion, but this is working for me:

Import-Module dataontap

$filername = Read-Host 'What is the filer hostname?'

$name = Read-Host 'What is your username?'

Connect-NaController -Name $filername -Credential $name

$volname = Read-Host 'What is the volume name?'

$volsize = Get-NaVolSize -Name $volname

Write-Host "the size of the volume is:" ($volsize).volumesize

What is the error that the debugger is throwing out?

-Scott

Re: first script

Scott,

I am getting this:

"the size of the volume is DataONTAP.Types.Volume.SizeInfo"

The only difference between my script and yours is this:

mine:

Write-Host "the size of the volume is:" $volsize

yours:

Write-Host "the size of the volume is:" ($volsize).volumesize

(is that my issue?)

I would have to try that again with your line

I'll let you know

Thanks

Re: first script

Yep, you need to call the property(volumesize) of the object ($volsize).  Otherwise it simply returns the object type, not the usable information of the object.

-Scott