Syntax
New-Datastore [-Server <VIServer[]>] [-VMHost] <VMHost[]> [-Name] <String> -Path <String> [-Vmfs] [-BlockSizeMB <Int32>] [-WhatIf] [-Confirm] [<CommonParameters>]Related Commands
Get-DatastoreDetailed Description
Creates a new datastore based on the provided parameters. The following characters cannor be used in a datastore name: slash (/), backslash (\), and percent (%).Parameters
Input Type
Return Type
VMware.VimAutomation.Types.DatastoreNotes
Examples
-------------- Example 1 --------------
C:\PS>$myhost = Get-VMHost 10.23.112.345
New-Datastore -Nfs -VMHost $myhost -Name DS034 -Path $remotePath -NfsHost $remot
eHost
Creates a new Nfs datastore named DS034 on the virtual machine host with IP addr
ess 10.23.112.345 with the specified parameters.
-------------- Example 2 --------------
C:\PS>$iscsiHba = "vmhba32"
$iscsiServer = "10.23.113.94"
$iscsiPort = 3260
$h = Get-VMHost
$hostView = Get-View -VIObject $h
$storageSystem = Get-View $hostView.configManager.storageSystem
# Enable software iSCSI controller $storageSystem.UpdateSoftwareInternetScsiEnab
led($true)
# Add iSCSI Server for dynamic discovery
$target = New-Object VMware.Vim.HostInternetScsiHBASendTarget
$target.address = $iscsiServer
$target.port = $iscsiPort
$storageSystem.AddInternetScsiSendTargets($iscsiHba, $target)
# Scan for iSCSI devices
$storageSystem.RescanHba($iscsiHba)
# Get lunPath and create a new storage
$lunpath = Get-ScsiLun $h | where {$_.CanonicalName.StartsWith($iscsiHba)} | Get
-ScsiLunPath New-Datastore -Vmfs -VMHost $h -Path $lunpath.LunPath -Name iSCSI
Configures an iScsi storage adapter, gets the LUN path and creates an iScsi data
store named iScsi on the $h virtual machine host. Note that the only difference
between creating an iScsi datastore and a Vmfs datastore is in the argument pass
ed to the Path parameter. When creating an iScsi datastore the path must be take
n from an iScsi Lun device.