Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Using module dataontap - and scripting with cmdlet Get-nasnapmirrorschedule
2024-04-18
07:12 AM
1,733 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a script that runs get-ncvol ...the connect... and get-ncvol work fine. I want to get some snapmirror info with
"get-nasnapmirrorschedule" Seems it requires credentialsparameter??!. Does anyone know what the format of get-nassnapmirrorschedule is?
$username = "xxxxx"
$pwdTxt = Get-Content "C:\Scripts\Storage\xxxxx.txt"
$securePwd = $pwdTxt | ConvertTo-SecureString
$credObject = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $securePwd
$global:CurrentNcController = $null
connect-nccontroller $cluster -credential $credObject
get-ncvol
**********************************************
I tried to use "get-nasnapmirrorschedule -Controller xxxx" and it errors...wanting credentials.
get-nasnapmirrorschedule : Incorrect credentials for xxxxx
At C:\scripts\storage\testing-snapmirror\Snapmirror-check.ps1:32 char:1
+ get-nasnapmirrorschedule -Controller xxxxx
+ CategoryInfo : InvalidOperation: (bmina:NaController) [Get-NaSnapmirrorSchedule], NaAuthException
+ FullyQualifiedErrorId : ApiException,DataONTAP.PowerShell.SDK.Cmdlets.Snapmirror.GetNaSnapmirrorSchedule
Solved! See The Solution
1 ACCEPTED SOLUTION
thaddad has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
*-Na* commands are for non cluster mode filers.
3 REPLIES 3
thaddad has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
*-Na* commands are for non cluster mode filers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
If the CmdLet in the PSTK is not working as you expect you can always use the REST API. Here's an example of enumerating the schedules in ONTAP. I suspect there is a bug in the "Get-NaSnapMirrorSchedule" CmdLet in the latest PSTK version in the "NetApp.ONTAP" module. You can also invoke a CLI via the REST API if you prefer.
Param(
[Parameter(Mandatory = $True, HelpMessage = "The cluster name or IP Address")]
[String]$Cluster,
[Parameter(Mandatory = $True, HelpMessage = "The Credential to authenticate to ONTAP")]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSCredential]$Credential
)
#'------------------------------------------------------------------------------
Function Get-NrAuthorization{
[Alias("Get-UMAuth")]
[CmdletBinding()]
Param(
[Parameter(Mandatory = $True, HelpMessage = "The Credential to authenticate to ONTAP")]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSCredential]$Credential
)
#'---------------------------------------------------------------------------
#'Set the authentication header to connect to ONTAP.
#'---------------------------------------------------------------------------
$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-NrAuthorization.
#'------------------------------------------------------------------------------
Function Get-NrSchedule{
[CmdletBinding()]
Param(
[Parameter(Mandatory = $True, HelpMessage = "The cluster name or IP Address")]
[String]$Cluster,
[Parameter(Mandatory = $True, HelpMessage = "The Credential to authenticate to ONTAP")]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSCredential]$Credential
)
#'---------------------------------------------------------------------------
#'Set the authentication header to connect to ONTAP.
#'---------------------------------------------------------------------------
$headers = Get-NrAuthorization -Credential $Credential
#'---------------------------------------------------------------------------
#'Enumerate the Schedules.
#'---------------------------------------------------------------------------
[String]$uri = "https://$Cluster/api/cluster/schedules"
Try{
$response = Invoke-RestMethod -Uri $uri -Method GET -Headers $headers -ErrorAction Stop
Write-Host "Enumerated Schedules on Cluster ""$Cluster"" using URI ""$uri"""
}Catch{
Write-Warning -Message $("Failed enumerating Schedules on Cluster ""$Cluster"" using URI ""$uri"". Error " + $_.Exception.Message + ". Status Code " + $_.Exception.Response.StatusCode.value__)
}
Return $response;
}#'End Function Get-NrSchedule.
#'------------------------------------------------------------------------------
#'Enumerate the schedules on the cluster.
#'------------------------------------------------------------------------------
Try{
$schedules = Get-NrSchedule -Cluster $Cluster -Credential $Credential -ErrorAction Stop
Write-Host "Enumerated schedules on cluster ""$Cluster"""
}Catch{
Write-Warning -Message $("Failed enumerating schedules on cluster ""$Cluster"". Error " + $_.Exception.Message)
Exit -1;
}
$schedules.records
#'------------------------------------------------------------------------------
Here is an example of syntax:
PS E:\Scripts\PowerShell\Projects\GetSnapMirrorSchedule> .\GetSnapMirrorSchedule.ps1 -Cluster 192.168.100.2 -Credential $credential
Enumerated Schedules on Cluster "192.168.100.2" using URI "https://192.168.100.2/api/cluster/schedules"
Enumerated schedules on cluster "192.168.100.2"
uuid name cron
---- ---- ----
0adb64c1-8374-11ee-8d03-00a098ba68d6 8hour @{minutes=System.Object[]; hours=System.Object[]}
0ae0899e-8374-11ee-8d03-00a098ba68d6 hourly @{minutes=System.Object[]}
0ae2a527-8374-11ee-8d03-00a098ba68d6 5min @{minutes=System.Object[]}
0aef6a2e-8374-11ee-8d03-00a098ba68d6 daily @{minutes=System.Object[]; hours=System.Object[]}
0af386e5-8374-11ee-8d03-00a098ba68d6 weekly @{minutes=System.Object[]; hours=System.Object[]; weekdays=System.Object[]}
Hope that helps
/Matt
If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you. Also I ran Get-Ncsnapmirrorschedule without any parameters (after doint a Connect... to the cluster) and all was successful
Tom Haddad
Office of Technology - Storage Administration
Encova Insurance
400 Quarrier Street
Charleston, Wv 25301
Encova.com
Tom.haddad@encova.com
Office 304 220 6776
Mobile 304 542 1876
Important notice: This message may contain confidential information intended exclusively for the recipient named above. If you have received this email in error, or if you are not the intended recipient, please promptly delete and destroy the original email transmission. Any unauthorized use, dissemination, distribution or duplication of this email message is strictly prohibited. Thank you for your assistance.
Tom Haddad
Office of Technology - Storage Administration
Encova Insurance
400 Quarrier Street
Charleston, Wv 25301
Encova.com
Tom.haddad@encova.com
Office 304 220 6776
Mobile 304 542 1876
Important notice: This message may contain confidential information intended exclusively for the recipient named above. If you have received this email in error, or if you are not the intended recipient, please promptly delete and destroy the original email transmission. Any unauthorized use, dissemination, distribution or duplication of this email message is strictly prohibited. Thank you for your assistance.
