<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: The New-NcSnapMirror command in powershell - &amp;quot;Incorrect credential problem&amp;quot; in ONTAP Discussions</title>
    <link>https://community.netapp.com/t5/ONTAP-Discussions/The-New-NcSnapMirror-command-in-powershell-quot-Incorrect-credential-problem/m-p/452455#M43587</link>
    <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested the CmdLet. If you have used the Connect-NcController to connect to the destination cluster you don't need to pass the -Controller parameter (as it will use the current connection). EG:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;PS C:\Scripts\PowerShell\Projects\ONTAP\CreateSnapMirrorCLI&amp;gt; connect-nccontroller -Name cluster2 -Credential $credential

Name                 Address           Vserver              Version
----                 -------           -------              -------
cluster2             192.168.0.102                          NetApp Release Clawhammer__9.14.1: Tue Mar 19 18:52:51 UTC 2024

PS C:\Scripts\PowerShell\Projects\ONTAP\CreateSnapMirrorCLI&amp;gt; New-NcSnapmirror -DestinationCluster cluster2 -DestinationVserver svm1_cluster2 -DestinationVolume volume_002_dr -SourceCluster cluster1 -SourceVserver svm1_cluster1 -SourceVolume volume_002 -Type DP

SourceLocation                                DestinationLocation                           Status       MirrorState
--------------                                -------------------                           ------       -----------
svm1_cluster1:volume_002                      svm1_cluster2:volume_002_dr                   uninitial... uninitialized&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The private REST CLI example might come in useful for tasks that might not have a corresponding PowerShell CmdLet in future. Certainly useful to know about.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/Matt&lt;/P&gt;</description>
    <pubDate>Wed, 01 May 2024 11:29:47 GMT</pubDate>
    <dc:creator>mbeattie</dc:creator>
    <dc:date>2024-05-01T11:29:47Z</dc:date>
    <item>
      <title>The New-NcSnapMirror command in powershell - "Incorrect credential problem"</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/The-New-NcSnapMirror-command-in-powershell-quot-Incorrect-credential-problem/m-p/447200#M42720</link>
      <description>&lt;P&gt;I will soon have to give up using Powershell to setup hundreds of SM relationships. I established peer relationships between the two SVMs, and in the GUI I can setup SnapMirror on the destination if I want. But I will have to do it one-by-one. This is why I am trying to do it with Powershell. I am using the New-NCSnapMirror command in order to create the relationship. But it stops due to "Incorrect credenials" on the destination cluster. But as you can see from the attachment, I am already connected to the destination cluster. Why is it saying the credential is wrong?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see my attachment showing the command with -debug turned on.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 09:45:48 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/The-New-NcSnapMirror-command-in-powershell-quot-Incorrect-credential-problem/m-p/447200#M42720</guid>
      <dc:creator>Northman</dc:creator>
      <dc:date>2025-06-04T09:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: The New-NcSnapMirror command in powershell - "Incorrect credential problem"</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/The-New-NcSnapMirror-command-in-powershell-quot-Incorrect-credential-problem/m-p/452450#M43584</link>
      <description>&lt;P&gt;I second this. I get the exact same issue. Perhaps it's a bug in the command itself.&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 04:26:58 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/The-New-NcSnapMirror-command-in-powershell-quot-Incorrect-credential-problem/m-p/452450#M43584</guid>
      <dc:creator>NetappUser117</dc:creator>
      <dc:date>2024-05-01T04:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: The New-NcSnapMirror command in powershell - "Incorrect credential problem"</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/The-New-NcSnapMirror-command-in-powershell-quot-Incorrect-credential-problem/m-p/452453#M43586</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure if there's an issue with the CmdLet however you could use the private REST CLI as an alternative. Here is an example for you:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Param(
   [Parameter(Mandatory = $True, HelpMessage = "The destination cluster name or IP Address")]
   [String]$Cluster,
   [Parameter(Mandatory = $True, HelpMessage = "The Source Vserver name")]
   [String]$SourceVserver,
   [Parameter(Mandatory = $True, HelpMessage = "The Source Volume name")]
   [String]$SourceVolume,
   [Parameter(Mandatory = $True, HelpMessage = "The destination Vserver name")]
   [String]$TargetVserver,
   [Parameter(Mandatory = $True, HelpMessage = "The destination Volume name")]
   [String]$TargetVolume,
   [Parameter(Mandatory = $True, HelpMessage = "The Schedule name")]
   [String]$ScheduleName,
   [Parameter(Mandatory = $True, HelpMessage = "The Policy name")]
   [String]$PolicyName,
   [Parameter(Mandatory = $True, HelpMessage = "The Relationship type")]
   [ValidateSet("DP","LS","XDP","TDP")]
   [String]$RelationshipType,
   [Parameter(Mandatory = $True, HelpMessage = "The Credentials to authenticate to the destination cluster")]
   [System.Management.Automation.PSCredential]$Credential
)
#'------------------------------------------------------------------------------
#'Set the certificate policy and TLS version.
#'------------------------------------------------------------------------------
Add-Type @"
   using System.Net;
   using System.Security.Cryptography.X509Certificates;
   public class TrustAllCertsPolicy : ICertificatePolicy {
   public bool CheckValidationResult(
   ServicePoint srvPoint, X509Certificate certificate,
   WebRequest request, int certificateProblem) {
      return true;
   }
}
"@
[System.Net.ServicePointManager]::SecurityProtocol  = [System.Net.SecurityProtocolType]'Tls12'
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
#'------------------------------------------------------------------------------
Function Get-NcAuthorization{
   [Alias("Get-NcAuth")]
   [CmdletBinding()]
   Param(
      [Parameter(Mandatory = $True, HelpMessage = "The Credential to authenticate to the cluster")]
      [ValidateNotNullOrEmpty()]
      [System.Management.Automation.PSCredential]$Credential
   )
   #'---------------------------------------------------------------------------
   #'Set the authentication header to connect to the cluster.
   #'---------------------------------------------------------------------------
   $auth    = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Credential.UserName + ':' + $Credential.GetNetworkCredential().Password))
   $headers = @{
      "Authorization" = "Basic $auth"
      "Accept"        = "application/json"
      "Content-Type"  = "application/json"
   }
   Return $headers;
}#'End Function Get-NcAuthorization.
#'------------------------------------------------------------------------------
[String]$command = "snapmirror create -source-path '$SourceVserver`:$SourceVolume' -destination-path '$TargetVserver`:$TargetVolume' -schedule $ScheduleName -policy $PolicyName -type $RelationshipType "
$headers = Get-NcAuth -Credential $Credential
$cli = @{};
$cli.Add("source-path", "$SourceVserver`:$SourceVolume")
$cli.Add("destination-path", "$TargetVserver`:$TargetVolume")
$cli.Add("schedule", $ScheduleName)
$cli.Add("policy", $PolicyName)
$cli.Add("type", $RelationshipType)
$body = $cli | ConvertTo-Json
#'------------------------------------------------------------------------------
#'Create the SnapMirror relationship and set the schedule.
#'------------------------------------------------------------------------------
[String]$uri = "https://$Cluster/api/private/cli/snapmirror"
Write-Host "Executing Command`: $command"
Try{
   $response = Invoke-RestMethod -Method Post -Body $body -Uri $uri -Headers $headers -ErrorAction Stop
}Catch{
   Write-Warning -Message $("Failed Creating SnapMirror relationship between ""$SourceVserver`:$SourceVolume"" and ""$TargetVserver`:$TargetVolume"" on cluster ""$Cluster"". Error " + $_.Exception.Message)
   Break;
}
If($Null -ne $response){
   If($response -Match "Operation succeeded"){
      Write-Host "Created SnapMirror relationship between ""$SourceVserver`:$SourceVolume"" and ""$TargetVserver`:$TargetVolume"" on cluster ""$Cluster"""
   }Else{
      Write-Warning -Message "Failed Creating SnapMirror relationship between ""$SourceVserver`:$SourceVolume"" and ""$TargetVserver`:$TargetVolume"" on cluster ""$Cluster"""
      Break;
   }
}Else{
   Write-Warning -Message "Failed Creating SnapMirror relationship between ""$SourceVserver`:$SourceVolume"" and ""$TargetVserver`:$TargetVolume"" on cluster ""$Cluster"""
   Break;
}
#'------------------------------------------------------------------------------&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Usage:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;PS C:\Scripts\PowerShell\Projects\ONTAP\CreateSnapMirrorCLI&amp;gt; $credential = Get-Credential
PS C:\Scripts\PowerShell\Projects\ONTAP\CreateSnapMirrorCLI&amp;gt; .\CreateSnapMirrorCLI.ps1 -Cluster cluster2 -SourceVserver svm1_cluster1 -SourceVolume volume_001 -TargetVserver svm1_cluster2 -TargetVolume volume_001_dr -ScheduleName daily -PolicyName DPDefault -RelationshipType DP -Credential $credential
Executing Command: snapmirror create -source-path 'svm1_cluster1:volume_001' -destination-path 'svm1_cluster2:volume_001_dr' -schedule daily -policy DPDefault -type DP
Created SnapMirror relationship between "svm1_cluster1:volume_001" and "svm1_cluster2:volume_001_dr" on cluster "cluster2"&lt;/LI-CODE&gt;&lt;P&gt;Hope that helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/Matt&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 11:18:31 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/The-New-NcSnapMirror-command-in-powershell-quot-Incorrect-credential-problem/m-p/452453#M43586</guid>
      <dc:creator>mbeattie</dc:creator>
      <dc:date>2024-05-01T11:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: The New-NcSnapMirror command in powershell - "Incorrect credential problem"</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/The-New-NcSnapMirror-command-in-powershell-quot-Incorrect-credential-problem/m-p/452455#M43587</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested the CmdLet. If you have used the Connect-NcController to connect to the destination cluster you don't need to pass the -Controller parameter (as it will use the current connection). EG:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;PS C:\Scripts\PowerShell\Projects\ONTAP\CreateSnapMirrorCLI&amp;gt; connect-nccontroller -Name cluster2 -Credential $credential

Name                 Address           Vserver              Version
----                 -------           -------              -------
cluster2             192.168.0.102                          NetApp Release Clawhammer__9.14.1: Tue Mar 19 18:52:51 UTC 2024

PS C:\Scripts\PowerShell\Projects\ONTAP\CreateSnapMirrorCLI&amp;gt; New-NcSnapmirror -DestinationCluster cluster2 -DestinationVserver svm1_cluster2 -DestinationVolume volume_002_dr -SourceCluster cluster1 -SourceVserver svm1_cluster1 -SourceVolume volume_002 -Type DP

SourceLocation                                DestinationLocation                           Status       MirrorState
--------------                                -------------------                           ------       -----------
svm1_cluster1:volume_002                      svm1_cluster2:volume_002_dr                   uninitial... uninitialized&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The private REST CLI example might come in useful for tasks that might not have a corresponding PowerShell CmdLet in future. Certainly useful to know about.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/Matt&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 11:29:47 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/The-New-NcSnapMirror-command-in-powershell-quot-Incorrect-credential-problem/m-p/452455#M43587</guid>
      <dc:creator>mbeattie</dc:creator>
      <dc:date>2024-05-01T11:29:47Z</dc:date>
    </item>
  </channel>
</rss>

