You can use stored credentials for auto login, similar to
$credential = Get-Credential
$credential.password |ConvertFrom-SecureString |set-Content C:\Users\domain_user\encrypted_password.txt
$encrypted = Get-Content C:\Users\domain_user\encrypted_password.txt | ConvertTo-SecureString
$dom_user = "domain\domain_user"
$credential = New-Object System.Management.Automation.PsCredential($dom_user, $encrypted)
Then use that credential ($credential) to login to the cluster ($filer)
$ClusterConnection = Connect-NcController -name $filer -Credential $credential
# If the connection is not success, exit else continue.
if (!$ClusterConnection) {
Write-Host "Unable to connect to $filer, please ensure all supplied information is correct and try again"
Exit
} else
{ Continue with you script}
Hope that helps