ONTAP Discussions
ONTAP Discussions
I have a powershell script that has been working well for the past 4 yrs., Recently I migrated the script to a new environment and it started giving errors
what the script does is to login the source filer A, change the snapshots' snapmirror labels to "daily" then snapvault these snapshots to the destination filer B
When i run it, it seems the script is able to login both filer A and filer B, and replicate the snapshots over. It failed on getting the snapshots, and gave me 400 errors are below
PS C:\Users\adm_gwen> powershell.exe E:\Scripts\Veeam-NetAppSnaplock\Set-SM-Label-Update_SV-With-File_Input.ps1 -PrimaryCluster "PUG3AXRSTR1.pue1m.ad" -PrimarySVM "PUG3AXRSTR1-vs01" -ClusterUser veeam -ClusterPass "E:\Scripts\Veeam-NetAppSnaplock\password.txt" -PassKey "E:\Scripts\Veeam-NetAppSnaplock\AES.key" -SecondaryCluster "pcs1bxdsbr.pcs1m.ad" -SecondarySVM "pcs1bxdsbr-uge-vs01" -VolumeListFile "E:\Scripts\Veeam-NetAppSnaplock\SiteA_pug3axrstr_oasys.txt"
[04.03.2025 15:01:22] Starting new log file
[04.03.2025 15:01:22] Trying to load NetApp Powershell module
[04.03.2025 15:01:22] Loaded NetApp Powershell module sucessfully
[04.03.2025 15:01:22] Trying to connect to SVM PUG3AXRSTR1-vs01 on cluster PUG3AXRSTR1.pue1m.ad
[04.03.2025 15:01:24] Connection established to PUG3AXRSTR1-vs01 on cluster PUG3AXRSTR1.pue1m.ad
Get-NcSnapshot : The remote server returned an error: (400) Bad Request.
At E:\Scripts\Veeam-NetAppSnaplock\Set-SM-Label-Update_SV-With-File_Input.ps1:239 char:3
+ Get-NcSnapshot -SnapName *Veeam* | Set-NcSnapshot -SnapmirrorLabel ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-NcSnapshot], WebException
+ FullyQualifiedErrorId : System.Net.WebException,DataONTAP.C.PowerShell.SDK.Cmdlets.Snapshot.GetNcSnapshot
[04.03.2025 15:01:24] Trying to connect to SVM pcs1bxdsbr-uge-vs01 on cluster pcs1bxdsbr.pcs1m.ad
[04.03.2025 15:01:28] Connection established to pcs1bxdsbr-uge-vs01 on cluster pcs1bxdsbr.pcs1m.ad
[04.03.2025 15:01:28] File E:\Scripts\Veeam-NetAppSnaplock\SiteA_pug3axrstr_oasys.txt was found
[04.03.2025 15:01:29] Volume tp_pug3axrstr1_vs01_pgu3arj_esx_ds_data_bc_even01_vol was found
[04.03.2025 15:01:29] SecondarySVM: pcs1bxdsbr-uge-vs01
[04.03.2025 15:01:29] SecondaryVolume: tp_pug3axrstr1_vs01_pgu3arj_esx_ds_data_bc_even01_vol
VERBOSE: Updating SnapMirror with destination //pcs1bxdsbr-uge-vs01/tp_pug3axrstr1_vs01_pgu3arj_esx_ds_data_bc_even01_vol.
NcController : pcs1bxdsbr.pcs1m.ad
ResultOperationId : 76301282-f933-11ef-bcd2-d039eabd3a83
ErrorCode :
ErrorMessage :
JobId :
JobVserver :
Status : succeeded
Uuid :
Message :
[04.03.2025 15:01:29] Volume tp_pug3axrstr1_vs01_pgu3arj_esx_ds_data_bc_odd01_vol was found
[04.03.2025 15:01:29] SecondarySVM: pcs1bxdsbr-uge-vs01
[04.03.2025 15:01:29] SecondaryVolume: tp_pug3axrstr1_vs01_pgu3arj_esx_ds_data_bc_odd01_vol
VERBOSE: Updating SnapMirror with destination //pcs1bxdsbr-uge-vs01/tp_pug3axrstr1_vs01_pgu3arj_esx_ds_data_bc_odd01_vol.
NcController : pcs1bxdsbr.pcs1m.ad
ResultOperationId : 768f5208-f933-11ef-bcd2-d039eabd3a83
ErrorCode :
ErrorMessage :
JobId :
JobVserver :
Status : succeeded
Uuid :
Message :
[04.03.2025 15:01:30] Volume tp_pug3axrstr1_vs01_pgu3arj_esx_ds_data_nbc_even01_vol was found
Any help is appreciated!
Hi there,
From my experience, PSTK throws error when it queries the controller
Get-NcSnapshot : The remote server returned an error: (400) Bad Request.
I can recreate the error on my laptop too.
PS C:\Users\user\Scripts> Read-NcDirectory -Path /vol/mystore1 |where-object {$_.Name -Notmatch "\."} |measure-object
Read-NcDirectory: The remote server returned an error: (400) Bad Request.
Tried again - it works
PS C:\Users\user\Scripts> Read-NcDirectory -Path /vol/mystore1 |where-object {$_.Name -Notmatch "\."} |measure-object
Count : 47
Average :
Sum :
Maximum :
Minimum :
StandardDeviation :
Property :
So, what you can do is, trap that "Bad Request" and retry until no "Bad Request" error then continue. I think it is flow in PSTK 9.15.1.2.xxxx
Hey Sanaman
Very appreciate your response.
I got your instructions, could you please tell the commands as I have no idea on how t trap the "Bad Request"
Thanks so much
Unfortunately, I can't teach you PowerShell to trap the error. Basic thing is your script is calling Get-NcSnapshot somewhere and you need to trap the output first time and try again. Something like this:
$Variable = Get-NcSnapshot <your_volume_name>
if ($Variable -Match "Bad Request") {
Write-Host "Trying again"
Get-NcSnapshot <your_volume_name>
}
Great, I think this is good information, I will get it a shot, thanks so much
It seems that you are using PowerShell Toolkit version 9.11.1 or higher. In these versions, the volume parameter is required, so you will need to specify the volume name as well.
Use the command as follows:
Get-NcSnapshot -SnapName <snapshot-name> -Volume <volume-name> | Set-NcSnapshot -Snapmirror ...