Microsoft Virtualization Discussions

How to use Powershell to perform the ontap system shell command?

AllenChang
1,453 Views

In ONTAP Cli ,

we can use diag account to perform the system shell command,

If the powershell can do that?

how to perform the system shell command by powershell tool kit?

 

Thanks

1 ACCEPTED SOLUTION

mbeattie
1,374 Views

Hi Allen,

Here is an example:

[Array]$command = @("set diag;volume", "show", "-fields", "tiering-minimum-cooling-days")
Try{
   $api = $("<system-cli><args><arg>" + ($command -join "</arg><arg>") + "</arg></args></system-cli>")
   Write-Host $("Executed Command`: " + $([String]::Join(" ", $command)))
   $response = Invoke-NcSystemApi -Request $api -ErrorAction Stop
}Catch{
   Write-Warning -Message $("Failed Executing Command`: " + $([String]::Join(" ", $command))
   Break;
}
$response.results."cli-output"

Hope that helps

/Matt

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

View solution in original post

1 REPLY 1

mbeattie
1,375 Views

Hi Allen,

Here is an example:

[Array]$command = @("set diag;volume", "show", "-fields", "tiering-minimum-cooling-days")
Try{
   $api = $("<system-cli><args><arg>" + ($command -join "</arg><arg>") + "</arg></args></system-cli>")
   Write-Host $("Executed Command`: " + $([String]::Join(" ", $command)))
   $response = Invoke-NcSystemApi -Request $api -ErrorAction Stop
}Catch{
   Write-Warning -Message $("Failed Executing Command`: " + $([String]::Join(" ", $command))
   Break;
}
$response.results."cli-output"

Hope that helps

/Matt

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