Microsoft Virtualization Discussions

first script

JSHACHER11
9,474 Views

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

1 ACCEPTED SOLUTION

cscott
9,424 Views

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

View solution in original post

32 REPLIES 32

JSHACHER11
4,944 Views

Vinith, that looks awesome! I'll try that later

Thanks

vinith
4,932 Views

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

JSHACHER11
4,932 Views

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

vinith
4,932 Views

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

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

JSHACHER11
4,932 Views

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

JGPSHNTAP
4,454 Views

Joel -

Do a quick search for a blog post i submitted that will dump out all the filers and volumes sizes etc... You can re-use the code for your liking.

I see from your flurry of posts that you are just getting going on PS which is great.  Start with the getting started powerpoint presentation as well.

Also, i'm noticing you are starting everything with import-module.  I believe in powershell 3.0 all modules are loaded. you can check that by launching powershell and typing get-module

If you are using 2.x you need to add import-module dataontap to your profile.ps1 file. 

JGPSHNTAP
4,453 Views

Here, give this a shot

get-navol vol0 | get-navolsize | select @{E={convertto-formattednumber $_.volumesize datasize "0.00"};N="Vol size"}

JSHACHER11
4,453 Views

sweet!

came out nice

so what does the 'E=' and 'N=' do?

JGPSHNTAP
4,129 Views

Do a man on Select-object, It will show you.  It's Expression and Name

Actually, you can also do this.

[ValidateRange(1024,1125899906842624)]

[Int64]$Unit=1GB

$v = get-navol vol0 | get-navolsize

$v.volumesize/$unit

JSHACHER11
4,129 Views

so is it similar to this:

C:\PS>get-process | select-object -property ProcessName,@{Name="Start Day"; Expression = {$_.StartTime.DayOfWeek}}

E --> Expression

N --> Name

?

JSHACHER11
2,999 Views
Public