Microsoft Virtualization Discussions

Any way to reset snapshot's record-owner via PowerShell ?

rtorresani
4,548 Views

Hi all,

 I need to execute the following cmode cli command on a looong list of snapshot (based on snapshot creation date):

 

vol snapshot remove-owner -vserver <vserver> -volume <volume>  -snapshot <snapshot> -owner <owner>

 

The problem is that this command must be executed from a "diagnostic" privilege (set -privilege diagnostic).

 

I can't find any way to execute command on powershell at a diagnostic privilege level nor to reset snapshot's record-owner.

 

Can someone help me, please ?

 

Regards

Roberto

 

PS:
 just in case you are curious why I need to remove the record-owner from the snapshot, is due to the fact of a bug in OCUM (that works with SImpana Commvault) which leaves behind some old snaphost.

I've been directed to do so by Netapp support.

1 ACCEPTED SOLUTION

asulliva
4,483 Views

Another way is to use the system-cli API...

 

$zapi = "<system-cli>"
$zapi += "<priv>diagnostic</priv>"
$zapi += "<args>"
$zapi += "<arg>volume</arg>"
$zapi += "<arg>snapshot</arg>"
$zapi += "<arg>remove-owner</arg>"
$zapi += "<arg>-vserver</arg>"
$zapi += "<arg>$($vserver_name)</arg>"
$zapi += "<arg>-volume</arg>"
$zapi += "<arg>$($volume_name)</arg>"
$zapi += "<arg>-snapshot</arg>"
$zapi += "<arg>$($snapshot_name)</arg>"
$zapi += "<arg>-owner</arg>"
$zapi += "<arg>$($owner_name)</arg>"
$zapi += "</args>"
$zapi += "</system-cli>"

$x = Invoke-NcSystemApi $zapi

$x.results.'cli-output'

The privilege level is controlled by the "priv" value in the ZAPI call.

 

Hope that helps.

 

Andrew

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

View solution in original post

4 REPLIES 4

JGPSHNTAP
4,517 Views

I haven't had time to look into the cmdlets, but you can use invoke-ncssh

 

mbeattie
4,488 Views

Hi Roberto,

 

You can set the command into diagnostic mode by concatenating it using a semi-colon, this way you can run multiple commands.

Here is an example for you demonstrating how to run a CLI command in diag mode using the Invoke-NcSsh account to unlock a user:

 

Before running code:

cluster1> security login show -vserver vserver1

Vserver: vserver1
                             Authentication                  Acct
User/Group Name  Application Method         Role Name        Locked
---------------- ----------- -------------- ---------------- ------
vsadmin          ontapi      password       vsadmin          yes
vsadmin          ssh         password       vsadmin          yes

 

Note: the vsadmin user account is locked.

 

Code:

 

 

Import-Module DataONTAP
$credentials = Get-Credential -Credential admin
Connect-NcController -Name cluster1.testlab.local -HTTPS -Credential $credentials | Out-Null
$command = "set diagnostic -confirmations off;security login unlock -username vsadmin -vserver vserver1"
Invoke-NcSsh -Command $command -ErrorAction Stop

Note: use the semi-colon to seperate the set diag command and the secondary command you want to execute.

 

After running code:

 

 

cluster1> security login show -vserver vserver1

Vserver: vserver1
                             Authentication                  Acct
User/Group Name  Application Method         Role Name        Locked
---------------- ----------- -------------- ---------------- ------
vsadmin          ontapi      password       vsadmin          no
vsadmin          ssh         password       vsadmin          no

 

Note: the vsadmin account is now unlocked after running the code.

 

So you should be able to set your command to:

 

$command = "set diagnostic -confirmations off;vol snapshot remove-owner -vserver <vserver> -volume <volume>  -snapshot <snapshot> -owner <owner>"

 

Hope that helps?

 

/matt

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

asulliva
4,484 Views

Another way is to use the system-cli API...

 

$zapi = "<system-cli>"
$zapi += "<priv>diagnostic</priv>"
$zapi += "<args>"
$zapi += "<arg>volume</arg>"
$zapi += "<arg>snapshot</arg>"
$zapi += "<arg>remove-owner</arg>"
$zapi += "<arg>-vserver</arg>"
$zapi += "<arg>$($vserver_name)</arg>"
$zapi += "<arg>-volume</arg>"
$zapi += "<arg>$($volume_name)</arg>"
$zapi += "<arg>-snapshot</arg>"
$zapi += "<arg>$($snapshot_name)</arg>"
$zapi += "<arg>-owner</arg>"
$zapi += "<arg>$($owner_name)</arg>"
$zapi += "</args>"
$zapi += "</system-cli>"

$x = Invoke-NcSystemApi $zapi

$x.results.'cli-output'

The privilege level is controlled by the "priv" value in the ZAPI call.

 

Hope that helps.

 

Andrew

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

rtorresani
4,464 Views

Man, how I feel ignorant....Smiley Sad

 

Thank you very much, I just reset the owner fields of a bunch of snapshot.

 

Now I'll wait to commvault to cleanup itself.

 

Regards

Roberto

 

 

Public