This is probably an API enhancement, because it doesn't work with the VisualStudio API either...but...
I'd like to suggest an enhancement to the NaController class, but really to all classes in the NetApp toolkit. When using New-Object -Type NetApp.Ontapi.Filer.NaController, users will receive an error. This is caused by the NaController having no constructors that take zero arguments. This is mostly a problem when using PowerShell scripts that pass variables by reference to functions. To pass a variable by reference, you first have to define its type. There's no way to do this with the NaController class without passing an IP or hostname.
My specific case looks like this:
function ConnectSanController {
param (
[ValidateNotNullOrEmpty()][string]$controllername,
[ref]$sancontroller,
[ref]$ex
)
PrintDebug("Entering ConnectSanController")
Try {
[NetApp.Ontapi.Filer.NaController]$sancontroller.Value = Connect-NaController -name $controllername.Value -ErrorAction Stop
$ex.Value = $null
} Catch [System.Exception] {
PrintMessage("ERROR: Could not connect to SAN controller!")
PrintMessage($_.exception.gettype().fullname)
PrintMessage($_.exception.message)
PrintMessage($_.exception.ToString())
$sancontroller.Value = $null
$ex.Value = $_.exception
}
PrintDebug("Exiting ConnectSanController")
}
ConnectSanController -ControllerName $controller -SanController [NetApp.Ontapi.Filer.NaController]$MainSanController -ex [System.Exception]$MainException
if ($MainSanController -eq $null) {
PrintMessage($MainException)
QuitScript -reason SANERROR
}
Obvisouly I don't need to use a function to connect to the controller, but it makes my script collection much more re-usable and makes my individual scripts more sensible when looking at the actual body of the script. Plus, it's just good programming practice to define variable types when defining variables...even if the language in use doesn't require it. Right?