Ditch -server from every function

Coordinator
Sep 26, 2008 at 10:22 PM
Edited Sep 27, 2008 at 11:54 AM
I'm not a developer and I only signed up to CodePlex in an attempt to get in touch with who ever is running this project.  Anyways... Really nice start easy to follow, but I have one suggestion ditch the -server parameter from every function.  Personally I took care of it with.. 

Function Connect-NaFiler {
    param(
        [string]$server = $(throw "The parameter -server is required."),
        [System.Management.Automation.PSCredential]$credentials = $(Get-Credential)
    )       
    $global:NAserver = New-NaServer -server $server -credentials $credentials
    $global:NAserver.Version = Get-NaSystemOnTAPIVersion -server $global:NAserver
    return $global:NAserver
}

Function Disconnect-NaFiler {
    $global:NAserver = $null
}

and replace  [PSObject]$server = $(throw "The parameter -server is required.")

with             [PSObject]$server = $(if (!$global:NAserver){throw "The parameter -server is required."}else{write-output $global:NAserver})

I apologize if this is not the correct forum for something like this..

~Glenn
get-admin:com

 



 

Nov 15, 2008 at 7:27 PM
For those of use with multiple filers, having the server parameter in every function is a big plus.  It lets me perform operations or looping on multple filers without having to keep rebinding.  Please don't take it out.

 Gary