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.
thanks LucD. I figured out the rest. appreciate the help
$volumelabel = "Volume Name"
$esxcli = Get-EsxCli -VMhost esxhost
$esxcli.storage.vmfs.snapshot.resignature($volumelabel)
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)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
thanks LucD. I figured out the rest. appreciate the help
$volumelabel = "Volume Name"
$esxcli = Get-EsxCli -VMhost esxhost
$esxcli.storage.vmfs.snapshot.resignature($volumelabel)
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.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
Ok, that one doesn't have the V2 option yet.
You should perhaps consider upgrading your PowerCLI version.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
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).
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you !
This makes a lot of sense now.
Thanks @ffrancisco & @LucD 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