Microsoft Virtualization Discussions
Microsoft Virtualization Discussions
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
Solved! See The Solution
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
Vinith, that looks awesome! I'll try that later
Thanks
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
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
what are you giving as input to $volume, can you share an example?
Here's the output when i ran your set of cmdlets.
I've tried with a volume I created, called vol7 and also with vol0
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.
Here, give this a shot
get-navol vol0 | get-navolsize | select @{E={convertto-formattednumber $_.volumesize datasize "0.00"};N="Vol size"}
sweet!
came out nice
so what does the 'E=' and 'N=' do?
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
so is it similar to this:
C:\PS>get-process | select-object -property ProcessName,@{Name="Start Day"; Expression = {$_.StartTime.DayOfWeek}}
E --> Expression
N --> Name
?
...and here is a good link: