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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i'm trying to get all cifs options from a svm via pstk (9.16.1.2501)
using option -ZapiCall gives me all the options with values.
Without this option there are only some options populated with settings, for most of them i see the value false.
studying the help for the command didnt reveal how to do this via rest.
Any help is appreciated.
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Enagon,
Could you please provide the debug logs on ng-ontap-pstk-queries@netapp.com DL from the cmdlet execution? This will assist us in identifying the issue. You can enable debug logging by using the Set-NatoolkitConfiguration debug command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi saharsh,
i just collected the debug log and sent it to the address you mentioned.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Enagon,
If there's an issue that requires you to revert to ZAPI you can always use the private REST CLI to invoke a command via HTTPS. Here's an example to get the CIFS options:
Param(
[Parameter(Mandatory = $True, HelpMessage = "The Cluster name or IP Address")]
[String]$Cluster,
[Parameter(Mandatory = $True, HelpMessage = "The Vserver name")]
[String]$VserverName,
[Parameter(Mandatory = $True, HelpMessage = "The Credentials to authenticate to the 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.
#'------------------------------------------------------------------------------
$command = "vserver cifs options show -vserver $VserverName"
$headers = Get-NcAuth -Credential $Credential
$uri = "https://$Cluster/api/private/cli/vserver/cifs/options?vserver=$VserverName&fields=client_session_timeout,default_unix_group,default_unix_user,read_grants_exec,wins_servers"
#'------------------------------------------------------------------------------
#'Invoke the command via the private REST CLI.
#'------------------------------------------------------------------------------
Write-Host "Executing Command`: $command"
Try{
$response = Invoke-RestMethod -Method GET -Uri $uri -Headers $headers -ErrorAction Stop
}Catch{
Write-Warning -Message $("Failed Executing Command`: $command. Error " + $_.Exception.Message)
Break;
}
#'------------------------------------------------------------------------------
#'Display the records.
#'------------------------------------------------------------------------------
If($Null -eq $response -Or $response.num_records -eq 0){
Write-Warning -Message "No records were returned from executing command`: $command"
}Else{
$response.records
}
#'------------------------------------------------------------------------------
Example Output:
PS C:\Scripts\PowerShell\Projects\GetCifsOptions> .\GetCifsOptions.ps1 -Cluster 192.168.100.2 -VserverName vserver1 -Credential $credential
Executing Command: vserver cifs options show -vserver svm_nfs_cifs
vserver : vserver1
default_unix_user : pcuser
read_grants_exec : disabled
wins_servers : {}
client_session_timeout : 900
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
Hi mbeattie,
your script works well, but one question: how to get all fields without naming them ?
