Hi
I know the runtime name - vmhba2:0:0:201 and I would like to create a VMFS datastore on it using PowerCLI. In the past I'm sure I could use this runtime name for the path parameter, however today I need the canonical name.
So either 1) how to create the datastore with the info I have, or 2) how to get the canonical name from the runtime name would help me greatly.
Thanks, Andy.
Or everything in one go
$esxName = <hostname> $runtimeName = "vmhba2:0:0:201"
$dsName = "MyDS"
$esx = Get-VMHost -Name $esxName
$lun = Get-ScsiLun -VmHost $esx | where {$_.RuntimeName -eq $runtimeName} New-Datastore -VMHost $esx -Path $lun.CanonicalName
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Andy,
you can get the CanonicalName from the Runtime name with:
$RuntimeName = "vmhba2:0:0:201"
(Get-VMHost | `Get-ScsiLun | `
Where-Object {$_.RunTimeName -eq $RunTimeName} | `
Select-Object -First 1).CanonicalName
Regards, Robert
Or everything in one go
$esxName = <hostname> $runtimeName = "vmhba2:0:0:201"
$dsName = "MyDS"
$esx = Get-VMHost -Name $esxName
$lun = Get-ScsiLun -VmHost $esx | where {$_.RuntimeName -eq $runtimeName} New-Datastore -VMHost $esx -Path $lun.CanonicalName
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Robert,
Thanks for this, unfortunately it doesnt seem to work. The object returned by Get-ScsiLun does not seem to have a RunTimeName property...
[vSphere PowerCLI] C:\> $lun = Get-VMHost | Get-ScsiLun
[vSphere PowerCLI] C:\> $lun | gm
TypeName: VMware.VimAutomation.ViCore.Impl.V1.Host.Storage.Scsi.ScsiLunImpl
Name MemberType Definition
---- ---------- ----------
ConvertToVersion Method T ConvertToVersion[T]()
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
IsConvertableTo Method bool IsConvertableTo(type toType)
ToString Method string ToString()
BlocksToSwitchPath Property System.Nullable`1[[System.Int32, mscorlib, V...
CanonicalName Property System.String CanonicalName {get;}
CapacityMB Property System.Nullable`1[[System.Int64, mscorlib, V...
CommandsToSwitchPath Property System.Nullable`1[[System.Int32, mscorlib, V...
ConsoleDeviceName Property System.String ConsoleDeviceName {get;}
ExtensionData Property System.Object ExtensionData {get;}
HostId Property System.String HostId {get;}
Id Property System.String Id {get;}
Key Property System.String Key {get;}
LunType Property System.String LunType {get;}
Model Property System.String Model {get;}
MultipathPolicy Property VMware.VimAutomation.ViCore.Types.V1.Host.St...
SerialNumber Property System.String SerialNumber {get;}
Uid Property System.String Uid {get;}
Vendor Property System.String Vendor {get;}
VMHost Property VMware.VimAutomation.ViCore.Types.V1.Invento...
VMHostId Property System.String VMHostId {get;}
I'm using ESXi 4.1 ...
PowerCLI Version
----------------
VMware vSphere PowerCLI 4.1 build 264274
Cheers, Andy.
You need the latest version of PowerCLI
PS C:> Get-PowerCLIVersion
PowerCLI Version
----------------
VMware vSphere PowerCLI 4.1 U1 build 332441
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi Andy,
it looks like the RuntimeName is a new property of the ScsiLunImpl object in PowerCLI 4.1U1.
Regards, Robert
Hi Robert / Luc
Great answers, sorted it for me 100%. Thanks.
Cheers, Andy.