New-Datastore

Synopsis

Creates a new datastore.

Syntax

New-Datastore [-Server <VIServer[]>] [-VMHost] <VMHost[]> [-Name] <String> -Path <String> [-Vmfs] [-BlockSizeMB <Int32>] [-WhatIf] [-Confirm] [<CommonParameters>]
New-Datastore [-Server <VIServer[]>] [-VMHost] <VMHost[]> [-Name] <String> -Path <String> [-Local] [-WhatIf] [-Confirm] [<CommonParameters>]
New-Datastore [-Server <VIServer[]>] [-VMHost] <VMHost[]> [-Name] <String> -Path <String> [-Nfs] -NfsHost <String> [-ReadOnly] [-WhatIf] [-Confirm] [<CommonParameters>]
New-Datastore [-Server <VIServer[]>] [-VMHost] <VMHost[]> [-Name] <String> -Path <String> -NfsHost <String> [-ReadOnly] [-Cifs] -Username <String> -Password <String> [-WhatIf] [-Confirm] [<CommonParameters>]

Related Commands

Get-Datastore
Remove-Datastore
Set-Datastore

Detailed 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

NameDescriptionRequired?Pipeline InputDefault Value
ServerSpecify the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer.falsefalse
VMHostSpecify a host where you want to create the new datastore.truetrue (ByValue)
NameSpecify a name for the new datastore.truefalse
PathIf you want to create a local datastore, specify the file path to the directory where the virtual machine data is stored.
If you want to create a NFS/CIFS datastore, specify the remote path of the NFS mount point.
If you want to create a VMFS datastore, specify the canonical name of the SCSI logical unit that will contain new VMFS datastores.
truefalse
VmfsIndicate that you want to create a VMFS datastore.falsefalse
BlockSizeMBSpecify the maximum file size of VMFS in megabytes (MB). If no value is given, the maximum file size for the current system platform is used.falsefalse
WhatIfIndicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.falsefalse
ConfirmIndicate that the cmdlet asks for confirmation before running.falsefalse
LocalIndicate that you want to create a Local datastore.falsefalse
NfsIndicate that you want to create a NFS datastore.falsefalse
NfsHostSpecify the NFS host where you want to create the new datastore.truefalse
ReadOnlyIndicate that the access mode for the mount point is ReadOnly. The default access mode is ReadWrite.falsefalse
CifsIndicate that you want to create a CIFS datastore.falsefalse
UsernameSpecify the username you want to use for authentication with the CIFS server.truefalse
PasswordSpecify the password you want to use for authentication with the CIFS server.truefalse

Input Type

Return Type

VMware.VimAutomation.Types.Datastore

Notes

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.

Copyright © 1998 - 2009 VMware, Inc. All rights reserved.