Edit

Share via


New-IscsiVirtualDisk

Creates an iSCSI virtual disk with the specified file path and size.

Syntax

Dynamic (Default)

New-IscsiVirtualDisk
    [-Path] <String>
    [-SizeBytes] <UInt64>
    [-Description <String>]
    [-LogicalSectorSizeBytes <UInt32>]
    [-PhysicalSectorSizeBytes <UInt32>]
    [-BlockSizeBytes <UInt32>]
    [-ComputerName <String>]
    [-Credential <PSCredential>]
    [<CommonParameters>]

Differencing

New-IscsiVirtualDisk
    [-Path] <String>
    [[-SizeBytes] <UInt64>]
    -ParentPath <String>
    [-Description <String>]
    [-PhysicalSectorSizeBytes <UInt32>]
    [-BlockSizeBytes <UInt32>]
    [-ComputerName <String>]
    [-Credential <PSCredential>]
    [<CommonParameters>]

Fixed

New-IscsiVirtualDisk
    [-Path] <String>
    [-SizeBytes] <UInt64>
    [-Description <String>]
    [-DoNotClearData]
    [-UseFixed]
    [-LogicalSectorSizeBytes <UInt32>]
    [-PhysicalSectorSizeBytes <UInt32>]
    [-BlockSizeBytes <UInt32>]
    [-ComputerName <String>]
    [-Credential <PSCredential>]
    [<CommonParameters>]

Description

The New-IscsiVirtualDisk cmdlet creates an iSCSI Virtual Hard Disk (VHDX) object that has the specified file path and size. After the iSCSI VHDX object has been created, the virtual disk can be assigned to an iSCSI target. Once a virtual disk has been assigned to a target, and an initiator connects to that target, the iSCSI initiator can then access the virtual disk after the initiator connects to the target.

If the virtual hard disk file path does not exist, a new VHDX file is created.

If the VHDX file path exists, the server returns an error. Use the Import-IscsiVirtualDisk cmdlet to import existing virtual hard disks.

If the cmdlet displays an error while it creates a virtual disk, check the following conditions:

  • An absolute file path must be specified for the Path and ParentPath parameters.

  • The virtual disk file name must have a .vhdx file name extension.

  • The VHDX file cannot be a network file, or be in a compressed, sparse, or transacted folder.

Examples

Example 1: Create a fixed VHDX

PS C:\> New-IscsiVirtualDisk -UseFixed -Path "E:\temp\test.vhdx" -Size 10GB

This example creates a fixed VHDX that is 10GB in size.

Example 2: Create a differencing VHDX

PS C:\> New-IscsiVirtualDisk -ParentPath "E:\temp\test.vhdx" -Path "E:\temp\child\diff.vhdx"

This example creates a differencing VHDX, with the parent path E:\temp\test.vhdx and the differencing VHDX path is E:\temp\child\diff.vhdx.

Example 3: Create a dynamic VHDX on a remote computer

PS C:\> New-IscsiVirtualDisk -Path "E:\temp\test.vhdx" -Size 10GB -ComputerName "iscsisvr"

This example creates a dynamic VHDX with the size 10GB at E:\temp\test.vhdx on the computer named iscsisvr.

Example 4: Create a VHDX

PS C:\> New-IscsiVirtualDisk -Path "ramdisk:test.vhdx" -Size 20MB

This example creates a VHDX with the size 20MB. This VHDX is not saved. The VHDX is lost if the wintarget service is restarted or the system is restarted.

Parameters

-BlockSizeBytes

Specifies the block size, in bytes, for the VHDX. For fixed VHDX, if the value of the SizeBytes parameter is less than 32 MB, the default size if 2 MB. Otherwise, the default value is 32 MB. For dynamic VHDX, the default size is 2 MB. For differencing VHDX, the default size is the parent BlockSize.

Parameter properties

Type:UInt32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ComputerName

Specifies the computer name, or IP address, of the remote computer, if this cmdlet is run on a remote computer.

Specifies the cluster resource group network name, or cluster node name, if this cmdlet is run on a cluster configuration.

If you do not specify a value for this parameter, the cmdlet uses the local computer.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Credential

Specifies the credentials when connecting to a remote computer.

Parameter properties

Type:PSCredential
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Description

Specifies the description for the iSCSI virtual disk.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-DoNotClearData

Indicates that the cmdlet does not clear the fixed VHDX. Because failing to clear data can reveal pre-existing data, we do not recommend this option.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

Fixed
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-LogicalSectorSizeBytes

Specifies the logical sector size, in bytes, for the VHDX. The acceptable values for this parameter are: 512 and 4096. The default value is 512.

Parameter properties

Type:UInt32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

Dynamic
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
Fixed
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ParentPath

Specifies the parent virtual disk path if the VHDX is a differencing disk.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

Differencing
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Path

Specifies the path of the VHDX file that is associated with the iSCSI virtual disk. If the VHDX file path does not exist, a new VHDX file is created. If the virtual hard disk file path exists, the server returns an error. Use the Import-IscsiVirtualDisk cmdlet to import existing virtual hard drives.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:DevicePath

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-PhysicalSectorSizeBytes

Specifies the physical sector size, in bytes, for the VHDX. The acceptable values for this parameter are: 512 and 4096. The default value is 4096.

Parameter properties

Type:UInt32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-SizeBytes

Specifies the size, in bytes, of the iSCSI virtual disk.

Parameter properties

Type:UInt64
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Size

Parameter sets

Dynamic
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False
Fixed
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-UseFixed

Indicates that the cmdlet creates a fixed VHDX.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Fixed

Parameter sets

Fixed
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

None

Outputs

Microsoft.Iscsi.Target.Commands.IscsiVirtualDisk