2011-03-09 08:47 AM
I am having trouble with several PowerShell scripts when it comes to getting data from the Get-NaLun routine. It seems like the routine is not populating the variable when called in my case.
Most of the scripts I have saved from this site have the following line in them:
$LunList = Get-NaLun
Later in the scripts they use code like this:
Foreach ($LUN in $LunList)
Write-Host "Sour: " $Sour
$spath = $Sour.Split("/")
I added the code in bold to see if anything is ever set in the variable and I always get a null value.
I am able to get plenty of other information from the NetApp and the credentials allow me to get in with no problems. The error messages I get are always:
You cannot call a method on a null-valued expression.
At C:\Users\Administrator\Documents\NetApp_ThinProv.ps1:42 char:45
+ $spath = $Sour.Split <<<< ("/")
+ CategoryInfo : InvalidOperation: (Split:String) , RuntimeExce
+ FullyQualifiedErrorId : InvokeMethodOnNull
Cannot index into a null array.
At C:\Users\Administrator\Documents\NetApp_ThinProv.ps1:43 char:36
+ if ($spath[ <<<< 2].equals($vol.name))
+ CategoryInfo : InvalidOperation: (2:Int32) , RuntimeException
+ FullyQualifiedErrorId : NullArray
Any idea why this is happening?