Data Backup and Recovery

Get-Ncsnapmirror command fails sometimes in powershell




When SMSQL tries to get the snapvault relationship by invoking the command get-Ncsnapmirror it fails sometimes.

but the thing is the same command executed  successfully the other day in production.So not sure why it fails sometimes...

Can anyone help me out..?



 General Critical Failed to run a command Get-NcSnapMirror.
Exception : Message : Command execution stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Object reference not set to an instance of an object.
Source : System.Management.Automation
StackTrace : at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input, Hashtable errorResults, Boolean enumerate)
at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()
at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc() 


we are executing the command through >>pipeline.invoke(IEnumerable<>) method. 








If the error is reproduceable is there any more verbose information about the error using the following (if so can you post the output)


#'Invoke the powershell cmdlet.
   [String]$command = "<%insert_your_powershell_command_to_execute_here%> -ErrorAction Stop"
   Invoke-Expression -Command $command -ErrorAction Stop
   Write-Host "Executed Command`: $command"
   Write-Warning -Message $("Failed Executing Command`: $command. Error " + $_.Exception.Message) 
   echo $_.Exception | Format-List -Force

Are you piping input into the cmdlet that is failing? Can you post the code snipet that generates the error?



If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.




Unfortunately this error occured at the production environment so not able to give you more info

and also it is occuring sometimes.

Sometimes it is executed successfully.


Below code snippet where it is getting exception:

Command input is :Get-Ncsnapmirror


>>public Collection<PSObject> RunCommand(Command command, IEnumerable input = null)
>>Collection<PSObject> output = null;

>>if (command == null)
/* GLOBALYZER_EXTERNALIZED_TEXT:Input command object is null */
>>throw new ArgumentNullException(SDResources.PSHELPER_INPUTCOMMA_213);

/>>/ Create new pipeline
>>Pipeline pipeline = NewPipeline(command);

>>// Invoke the pipeline (execute commands) and return the results to caller.
>>output = pipeline.Invoke(input);       *******//Exception occured here************
>>catch (Exception ex)
>>/* GLOBALYZER_EXTERNALIZED_TEXT:Failed to run a command {0} */
>>string formattedCommandString = string.Format(SDResources.PSHELPER_FAILEDTORU_216, command.ToString());
>>NsfLogger.LogCriticalError(formattedCommandString, ex);

>>if (ex.Message.ToLower().Contains("specified vserver not found"))
>>string controllerName = command.Parameters.Where(p => p.Name.Equals("Controller")).Select(p => p.Value).First().ToString();
>>output = StorageConnectionFaultPublisher.OnConnectionFault(controllerName, command);
>>throw new PSHelperException(formattedCommandString, ex);


To get the snapmirror information is a SnapDrive task, so maybe there are some issue there.


i would suggest to check if the Transport protocol settings are set up properly ( hostname with proper name resolution etc etc..) for both the source and destination SVMs

then check if the Nsf.config file you can find in the sanpdrive installation folder does contain all the the SVMs information.

Then you can try to reset the TPS setting in this way:


- Delete the SVMs details from TPS of SDW

- Add the SVMs to SDW in TPS.

- Click on "apply" and then click on "ok". [Do not click "ok" first].




There is a default timeout value of 60sec in SDW nextgen code. Then we use PSTK to get the status.

So whenever this timeout value is exceeded i.e., get-ncsnapmirror did not get a respoonse within 60sec from SVM,it is failing.

Any ideas on how to increase the timeout?






You can specify the timeout parameter when connecting to the cluster:


    Connect-NcController [-Name] <String[]> [-Port <UInt16>] [-Credential <PSCredential>] [-HTTPS] [-HTTP] [-Transient] [-Vserver <String>] [-Timeout <Int32>]
    [-Add] [-ApplicationName <String>] [-SSLVersion <String>] [<CommonParameters>]

    -Timeout <Int32>
        Connection timeout in milliseconds.

        Required?                    false
        Position?                    named
        Default value                60000
        Accept pipeline input?       false
        Accept wildcard characters?  false

By default it will be 60 seconds (60000 milliseconds).

You can also modify the timeout by setting on the global controller object:




If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.