PowerCLI

Expand all | Collapse all

Resignature a VMFS Datastore Copy

  • 1.  Resignature a VMFS Datastore Copy

    Posted Nov 16, 2017 06:09 PM

    anyone know of or seen a powercli script to mount a new disk/lun and "assign a new signature" on the same time?  it works well on the gui, but I'm trying to automate the process.  any help is appreciated.

    https://docs.vmware.com/en/VMware-vSphere/5.5/com.vmware.vsphere.hostclient.doc/GUID-5A4E2248-12CB-4A10-B167-79D3D13D3751.html

    Procedure

    1. Log in to the vSphere Client and select the server from the inventory panel.
    2. Click the Configuration tab and click Storage in the Hardware panel.
    3. Click Add Storage.
    4. Select the Disk/LUN storage type and click Next.
    5. From the list of LUNs, select the LUN that has a datastore name displayed in the VMFS Label column and click Next.   The name present in the VMFS Label column indicates that the LUN is a copy that contains a copy of an existing VMFS datastore.
    6. Under Mount Options, select Assign a New Signature and click Next.
    7. In the Ready to Complete page, review the datastore configuration information and click Finish.


  • 2.  RE: Resignature a VMFS Datastore Copy

    Posted Nov 16, 2017 06:46 PM

    Try something like this.

    The volume will be mounted after the resignature.

    You can also use the volumeuuid instead of the volumenlabel

    $esxcli = Get-EsxCli -VMhost MyEsx -V2

    $resig = @{

        volumelabel = 'VMFS-Snap'

    }

    $esxcli.storage.vmfs.snapshot.resignature.Invoke($resig)



  • 3.  RE: Resignature a VMFS Datastore Copy

    Posted Nov 16, 2017 07:03 PM

    Hi LucD - I got an error.  thx for the assistance.

    PowerCLI H:\powershell\shadowimage_clone> .\resignature.ps1
    Get-EsxCli : A parameter cannot be found that matches parameter name 'V2'.
    At H:\powershell\shadowimage_clone\resignature.ps1:1 char:55
    + $esxcli = Get-EsxCli -VMhost usdenvsp102.corp.hds.com -V2
    +                                                       ~~~
        + CategoryInfo          : InvalidArgument: (:) [Get-EsxCli], ParameterBindingException
        + FullyQualifiedErrorId : NamedParameterNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetEsxCli

    You cannot call a method on a null-valued expression.
    At H:\powershell\shadowimage_clone\resignature.ps1:5 char:1
    + $esxcli.storage.vmfs.snapshot.resignature.Invoke($resig)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull

    ##then I removed the V2###

    PowerCLI H:\powershell\shadowimage_clone> .\resignature.ps1

    Exception calling "Invoke" with "1" argument(s): "Message: No unresolved VMFS snapshots with volume label 'System.Collections.Hashtable' found.;

    InnerText: No unresolved VMFS snapshots with volume label 'System.Collections.Hashtable' found.EsxCLI.CLIFault.summary"

    At H:\powershell\shadowimage_clone\resignature.ps1:5 char:1

    + $esxcli.storage.vmfs.snapshot.resignature.Invoke($resig)

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

        + FullyQualifiedErrorId : ViError



  • 4.  RE: Resignature a VMFS Datastore Copy
    Best Answer

    Posted Nov 16, 2017 07:28 PM

    thanks LucD. I figured out the rest.  appreciate the help

    $volumelabel = "Volume Name"

    $esxcli = Get-EsxCli -VMhost esxhost

    $esxcli.storage.vmfs.snapshot.resignature($volumelabel)



  • 5.  RE: Resignature a VMFS Datastore Copy

    Posted Nov 16, 2017 07:38 PM

    That's strange, look slike you are using the Get-EsxCli V2 version, but the resignature is not a V2 command.

    Could it be that you are on a somewhat older PowerCLI version? Do a Get-PowerCLIVersion.



  • 6.  RE: Resignature a VMFS Datastore Copy

    Posted Nov 16, 2017 08:58 PM

    thx again for your help.

    here is the version.

    PowerCLI H:\powershell\shadowimage_clone> get-powercliversion

    PowerCLI Version
    ----------------
       VMware vSphere PowerCLI 6.0 Release 3 build 3205540
    ---------------
    Component Versions
    ---------------
       VMWare AutoDeploy PowerCLI Component 6.0 build 2358282
       VMWare ImageBuilder PowerCLI Component 6.0 build 2358282
       VMware vSphere PowerCLI Component 6.0 build 3205541



  • 7.  RE: Resignature a VMFS Datastore Copy

    Posted Nov 16, 2017 09:05 PM

    Ok, that one doesn't have the V2 option yet.

    You should perhaps consider upgrading your PowerCLI version.



  • 8.  RE: Resignature a VMFS Datastore Copy

    Posted Jul 02, 2021 04:40 AM

    Thanks  &   for this interesting post.

    I was looking for exactly the same scenario... I'm newbie to PowerShell/PowerCLI.

    we are using ESXi v6.7 & ESXi v7... and we are taking Storage snaps for the DataStores... 

    Can someone post the entire script please and explanation so I can use it for our environment. 

     

    thanks a lot in advance



  • 9.  RE: Resignature a VMFS Datastore Copy

    Posted Mar 08, 2021 02:20 PM

    Hi LucD,

    I'd like to look at the definitions of this method with its parameters but I didn't find any useful link to doc.

    Have you one ?

     

    I fall into this thread because I used to launch a similar method, vmfs mount, but this way

    $esxcli.storage.vmfs.snapshot.mount.Invoke("DATASTORELABELNAME")

    But I got this error:

    You cannot call a method on a null-valued expression.
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
    + PSComputerName : localhost

     

    Only after trying to create an Has Table like this way the method worked

    $vols = @{ volumelabel = "DATASTORELABELNAME" }
    $esxcli.storage.vmfs.snapshot.mount.Invoke($vols)

     

    But this is the only place where I found any useful advice about how to use the invoke() command..

    Hope anybody could help

     

     



  • 10.  RE: Resignature a VMFS Datastore Copy

    Posted Mar 08, 2021 02:46 PM

    The Get-EsxCli cmdlet is nothing more than a PowerCLI front for the esxcli command.
    See PowerCLI 6.3 R1: Get-ESXCLI Why the V2? for info on the Get-EsxCli cmdlet and how it maps to the esxcli commands.

    The esxcli command, and all its parameters, is available in the esxcli documentation.

    The error you listed seems to indicate that you didn't do the Get-EsxCli to populate the $esxcli variable (correctly).



  • 11.  RE: Resignature a VMFS Datastore Copy

    Posted Mar 09, 2021 09:03 AM

    Thank you !

    This makes a lot of sense now.



  • 12.  RE: Resignature a VMFS Datastore Copy

    Posted Feb 08, 2025 08:07 AM

    Hi LucD,

    I have a similar requirement and would appreciate your guidance.

    We take a PMAX storage snapshot of the DATA disks (VMDK) from a production VM, create a new datastore using that snapshot LUN, and then mount the .VMDK disks to a target VM.

    But, whenever the storage team takes a new snapshot of the data disk LUN, the target cluster loses the datastore created from the previous snapshot. So, we have to manually create a new datastore and remount the .VMDK files to the VM each time. The NAA ID of the LUN remains unchanged, but the datastore disappears or loses connection after a storage rescan whenever a new snapshot is taken.

    Each time when we create a new datastore, the datastore name changes like "snap-<unique_Name>_sourcedatastorename"

    we are trying to develop a script that follows these steps:

    1. Power off the target VM.
    2. Remove all data disks that were mounted from the snapshot LUN/datastore.
    3. Delete the snapshot datastore and rescan the storage.
    4. Execute a script to take a PMAX storage snapshot and mount it to the target ESXi cluster.
    5. Add the new snapshot LUN as a new datastore (it has the same NAA ID) → This is where I'm facing an issue: I need a way to create a new datastore with a new signature.
    6. Attach the disks from the new snapshot datastore to the VM.
    7. Power on the VM.

    I have successfully created PowerCLI scripts for all the steps except Step 5. How can I create a new datastore using the "new signature" option in PowerCLI?

    Any insights would be greatly appreciated!

    Thanks,