Hi
Does anyone know how to use powershell to create Fibre Channel datastores?
A text file lists the datastores with datastore names and sizes(GB) as input:
DatastoreName1 10
DatastoreName2 200
DatastoreName3 10
File System version VMFS-5
1MB block size
The script needs to ignore LUN ID 0 as its not a datastore, its a boot LUN.
Is that value in $esxname correct ?
Do you see that name when you
Get-VMHost | Select Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Well basically that is the New-Datastore cmdlet where you specify the canonicalname of the LUN on the Path parameter.
In the inputfile you do not seem to have the canonicalname.
Isn't selecting the LUN solely based on the size a bit dangerous ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi
Ok, I'm trying to use runtimename to create new datastores
Do you know why this doesn't work? :smileyblush:
$esxName = 'slexavchyp002'
$runtimeName = "vmhba0:C0:T0:L1"
$dsName = "MyDS"
$esx = Get-VMHost -Name $esxName
$lun = Get-ScsiLun -VmHost $esx | where {$_.RuntimeName -eq $runtimeName}
New-Datastore -VMHost $esx -Path $lun.CanonicalName
Error:
New-Datastore : Parameter set cannot be resolved using the specified named parameters.
At D:\test.ps1:14 char:14
+ New-Datastore <<<< -VMHost $esx -Path $lun.CanonicalName
+ CategoryInfo : InvalidArgument: (:) [New-Datastore], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,VMware.VimAutomation.ViCore.Cmdlets.Commands.H
ost.NewDatastore
It seems you forgot the Name parameter on the New-Datastore cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
$esxName = 'slexavchyp001'
$runtimeName = "vmhba0:C0:T0:L3"
$dsName = "MyDS"
$esx = Get-VMHost -Name $esxName
$lun = Get-ScsiLun -VmHost $esx | where {$_.RuntimeName -eq $runtimeName}
New-Datastore -VMHost $esx -Name $esx -Path $lun.CanonicalName
Why this command get-vmhost -name $esxName doesn't work?
Get-VMHost : 1/03/2013 8:26:32 AM Get-VMHost VMHost with name 'slexavchyp002' was not fou
nd, using the specified filter(s).
At D:\a.ps1\CreateDS.ps1:12 char:18
+ $esx = Get-VMHost <<<< -Name $esxName
+ CategoryInfo : ObjectNotFound: (:) [Get-VMHost], VimException
+ FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmd
lets.Commands.GetVMHost
Get-ScsiLun : Cannot validate argument on parameter 'VmHost'. The argument is null or empty. Supply
an argument that is not null or empty and then try the command again.
At D:\a.ps1:13 char:27
+ $lun = Get-ScsiLun -VmHost <<<< $esx | where {$_.RuntimeName -eq $runtimeName}
+ CategoryInfo : InvalidData: (:) [Get-ScsiLun], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets
.Commands.Host.GetScsiLun
New-Datastore : Cannot validate argument on parameter 'VMHost'. The argument is null or empty. Supp
ly an argument that is not null or empty and then try the command again.
At D:\a.ps1:14 char:22
+ New-Datastore -VMHost <<<< $esx -Name NFS1 -Path $lun.CanonicalName
+ CategoryInfo : InvalidData: (:) [New-Datastore], ParameterBindingValidationExceptio
n
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets
.Commands.Host.NewDatastore
Is that value in $esxname correct ?
Do you see that name when you
Get-VMHost | Select Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks, looks like I have to use FQDN.
One more question, any idea why this doesn't work?
$esxName = 'slexavchyp001.mvs.hosting.telstra.com'
$runtimeName = "vmhba0:C0:T0:L3"
$dsName = "MyDS"
$esx = Get-VMHost -Name $esxName
$lun = Get-ScsiLun -VmHost $esx | where {$_.RuntimeName -eq $runtimeName}
New-Datastore -VMHost $esx -Name $dsName -Path $lun.CanonicalName
New-Datastore : Parameter set cannot be resolved using the specified named parameters.
At D:\a.ps1:14 char:14
+ New-Datastore <<<< -VMHost $esx -Name $dsName -Path $lun.CanonicalName
+ CategoryInfo : InvalidArgument: (:) [New-Datastore], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,VMware.VimAutomation.ViCore.Cmdlets.Commands.H
ost.NewDatastore
You need to add the Vmfs switch, otherwise the cmdlet will not know which parameterset to use.
New-Datastore -VMHost $esx -Name $dsName -Path $lun.CanonicalName -Vmfs
Btw, you can also do
$esxName = 'slexavchyp001*'
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference