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

Cannot issue command New-DcnClone: The term 'New-VHD' is not recognized as the name of a cmdlet #150

Closed
blitzmann opened this issue Jan 7, 2022 · 0 comments · Fixed by #151

Comments

@blitzmann
Copy link
Contributor

As with #148, I'm trying to issue commands to a remote host, and running into issues. This issue pops up, and it seems like there is a discrepancy between how the vdisk is created when running locally vs how it's created when running remotely.

# Create the new child vhd
            if ($PSCmdlet.ShouldProcess($ParentVhd, "Creating clone")) {
                try {
                    Write-PSFMessage -Message "Creating clone from $ParentVhd" -Level Verbose

                    $command = "create vdisk file='$($clonePath)' parent='$ParentVhd'"

                    # Check if computer is local
                    if ($computer.IsLocalhost) {
                        # Set the content of the diskpart script file
                        Set-Content -Path $diskpartScriptFile -Value $command -Force

                        $script = [ScriptBlock]::Create("diskpart /s $diskpartScriptFile")
                        $null = Invoke-PSFCommand -ScriptBlock $script
                    }
                    else {
                        $command = [ScriptBlock]::Create("New-VHD -ParentPath $ParentVhd -Path `"$($clonePath)`" -Differencing")
                        $vhd = Invoke-PSFCommand -ComputerName $computer -ScriptBlock $command -Credential $Credential

                        if (-not $vhd) {
                            return
                        }
                    }

                }

You can see that, when running locally, the vdisk is created using diskpart, the settings which are given with a file with the contents create vdisk file='$($clonePath)' parent='$ParentVhd'. When this is issued remotely, it's using New-VHD instead, and this is throwing the error for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant