Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I created a script to show aggregates more than 90% full on multiple filers but they would not connect
the text file is like this:
"filer1", "filer2", "filer3"
+++++++++++++++++++++++++++++++++++++++++++++++++++
$ntapArrays = (get-content "C:\filers.txt")
$FasUser = "root"
$FasPasswd = Read-Host "Enter password"
$SecureFasPasswd = ConvertTo-SecureString $FasPasswd -AsPlainText -Force
$FasCred = New-Object -TypeName System.Management.Automation.PSCredential ($FasUser, $SecureFasPasswd)
Foreach ($array in $ntapArrays) {
connect-nacontroller -Name $array -Credential $FasCred
Get-Naaggr | select homename, SizePercentageUsed, name | ? {$_.SizePercentageUsed -gt 90} | ft -AutoSize
}
++++++++++++++++++++++++++++++++++++++++++++++
the error messages is
Connect-NaController : Cannot bind argument to parameter 'Name' because it is a
n empty string.
At C:\script2.ps1:30 char:27
+ connect-nacontroller -Name <<<< $array -Credential $FasCred
+ CategoryInfo : InvalidData: (:) [Connect-NaController], Paramet
erBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAl
lowed,DataONTAP.PowerShell.SDK.ConnectNaController
what am I doing wrong?
Cheers
Solved! See The Solution
1 ACCEPTED SOLUTION
migration has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The way you are saving filer names in filers.txt is wrong, you need to append them as below
10 REPLIES 10
migration has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The way you are saving filer names in filers.txt is wrong, you need to append them as below
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, the Controllers are connecting now but I still don't get the aggregates info. Something is wrong here:
Foreach ($array in $ntapArrays) {
connect-nacontroller -Name $array -Credential $FasCred
Get-Naaggr | select homename, SizePercentageUsed, name | ? {$_.SizePercentageUsed -gt 90} | ft -AutoSize
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is the output of
Get-NaAggr | select homename,SizePercentageUsed,name | ft -AutoSize
Can you confirm that you do have aggregates whose SizePercentageUsed is greater than 90?SizePercentageUsed is greater than 90?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Vinith, you were right. That list didn't have aggregate with more than 90%
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank You For letting us know that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Joel,
Instead of "filer1", "filer2", "filer3" save your txt as filer1,filer2,filer3
You can do it this way :
$ntapArrays = (get-content "C:\filers.txt")
$ntapArrays = $filertxt.Split(',')
Foreach ($array in $ntapArrays) {
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, the Controllers are connecting now but I still don't get the aggregates info. Something is wrong here:
Foreach ($array in $ntapArrays) {
connect-nacontroller -Name $array -Credential $FasCred
Get-Naaggr | select homename, SizePercentageUsed, name | ? {$_.SizePercentageUsed -gt 90} | ft -AutoSize
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The easiest thing to do here is to list them in a text file as stated above
filer1
filer2
filer3
Then just do
$filers = gc c:\filers.txt
That will create the array
Then just put that array into a loop
$filers | % {
$c = connect-nacontroller $_
Put code here
}
Also, you are doing something wrong in my opinion. You need to put your where clause before your select statement.
Get-Naaggr | ? {$_.SizePercentageUsed -gt 90}| select homename, SizePercentageUsed, name | | ft -AutoSize
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you all - I will apply the advices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Joel -
What your doing will look good if you want to stare at the screen - But you do you really want to do that. Powershell is all about automation.
You want to have this as a scheduled tasks that emails you a report.
So, here's the basics.
$globalarray = @()
$filers | % {
$filer = $_
$c = connet-nacontroller $filer
$aggr = get-naaggr | ? {$_.SizePercentageUsed -gt 10}
if ($aggr -ne $NUll) {
$aggr | % {
$customobject = new-object psobject
Add-Member -inputobject $customobject -membertype Noteproperty -name filer -value $filer
Add-Member -inputobject $customobject -membertype Noteproperty -name "Aggr" -value $_.name
Add-Member -inputobject $customobject -membertype Noteproperty -name "total size" -value (convertto-formattednumber $_.totalsize datasize "0.0")
Add-Member -inputobject $customobject -membertype Noteproperty -name "% used" -value (convertto-formattednumber $_.used percent)
$globalarray += $customobject
}
}
}
$globalarray | ft -autosize
$globalarray | export-csv c:\temp\aggrereport.csv -notypeinformation.
Do some reading on custom objects and see if you can come up with sending this report to you..