Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disk: Invalid Parameter error occurs with ReFS Volume on Windows Server 2019 #227

Open
PlagueHO opened this issue Apr 13, 2020 · 2 comments
Labels
bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community.

Comments

@PlagueHO
Copy link
Member

When using the Disk resource to create ReFS volumes on Windows Server 2019, an "Invalid Parameter" exception occurs when calling the Format-Volume cmdlet in the Set method.

This can be replicated outside of the DSC Resource with the following code:

function New-VDisk
{
    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory = $True)]
        [String]
        $Path,

        [Parameter()]
        [Uint32]
        $SizeInMB,

        [Parameter()]
        [Switch]
        $Initialize
    )

    $tempScriptPath = Join-Path -Path $ENV:Temp -ChildPath 'DiskPartVdiskScript.txt'
    Write-Verbose -Message ('Creating DISKPART script {0}' -f $tempScriptPath)

    $diskPartScript = "CREATE VDISK FILE=`"$Path`" TYPE=EXPANDABLE MAXIMUM=$SizeInMB"

    if ($Initialize)
    {
        # The disk will be initialized with GPT (first blank line required because we're adding to existing string)
        $diskPartScript += @"

SELECT VDISK FILE=`"$Path`"
ATTACH VDISK
CONVERT GPT
DETACH VDISK
"@
    }

    Set-Content `
        -Path $tempScriptPath `
        -Value $diskPartScript `
        -Encoding Ascii
    $result = & DISKPART @('/s',$tempScriptPath)
    Write-Verbose -Message ($Result | Out-String)
    $null = Remove-Item -Path $tempScriptPath -Force
} # end function New-VDisk

$VHDPath = Join-Path -Path $ENV:Temp -ChildPath 'TestDisk.vhd'
$null = New-VDisk -Path $VHDPath -SizeInMB 1024
$null = Mount-DiskImage -ImagePath $VHDPath -StorageType VHD -NoDriveLetter
$diskImage = Get-DiskImage -ImagePath $VHDPath
$disk = Get-Disk -Number $diskImage.Number
$FSLabel = 'TestDisk'
$disk | Initialize-Disk -PartitionStyle GPT
$partition = $disk | New-Partition -UseMaximumSize

# Following line works on WS 2016, but not on WS 2019. 
$partition | Format-Volume -FileSystem ReFS

# Invalid Parameter occurs

$null = Dismount-DiskImage -ImagePath $VHDPath -StorageType VHD
$null = Remove-Item -Path $VHDPath -Force

The exception occurs:
image

The error appears to be in the WMI subsystem.

This should be logged with the Window Server storage team. I'll try and find the appropriate method to log the issue.

In the mean time there are two things than should be done:

  1. Change the resource to display a warning message when ReFS is used with Windows Server 2019.
  2. Add a known issue in the README.MD
@PlagueHO PlagueHO added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. labels Apr 13, 2020
@TaylorTWBrown
Copy link

Still experiencing this issue.

@PlagueHO
Copy link
Member Author

@TaylorTWBrown - does this occur outside DSC and which version of WS 2019 is this on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community.
Projects
None yet
Development

No branches or pull requests

2 participants