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 Dcn-NewClone command when running powershell in admin #148

Closed
blitzmann opened this issue Jan 7, 2022 · 3 comments · Fixed by #149
Closed

Cannot issue Dcn-NewClone command when running powershell in admin #148

blitzmann opened this issue Jan 7, 2022 · 3 comments · Fixed by #149

Comments

@blitzmann
Copy link
Contributor

blitzmann commented Jan 7, 2022

Current set up:

Running from source using the debug script found here: #138 (comment)

I am attempting to run Dcn-NewClone from my local machine, to create a clone on a remote sql host. The SQL host has dbaclone installed already and we utilize it, but we have to remote in to issue the commands directly.

When running the following command locally, I get a bunch of errors:
new-dcnclone -database keylime -latestimage -clonename keylime_new -sqlinstance whsqldev01 -destination z:\sql_clones

Join-Path : Cannot find drive. A drive with the name 'z' does not exist.
At C:\Program Files\WindowsPowerShell\Modules\PSFramework\1.6.205\PSFramework.psm1:11474 char:21
+ ... $resultingPath = Join-Path -Path $resultingPath -ChildPath $childItem
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (z:String) [Join-Path], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.JoinPathCommand

Cannot bind argument to parameter 'Path' because it is an empty string.
    + CategoryInfo          : InvalidData: (:) [Test-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.TestPathCommand
    + PSComputerName        : WHSQLDEV01

Cannot bind argument to parameter 'Path' because it is an empty string.
    + CategoryInfo          : InvalidData: (:) [New-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.NewItemCommand
    + PSComputerName        : WHSQLDEV01

Join-Path : Cannot find drive. A drive with the name 'z' does not exist.
At C:\Program Files\WindowsPowerShell\Modules\PSFramework\1.6.205\PSFramework.psm1:11474 char:21
+ ... $resultingPath = Join-Path -Path $resultingPath -ChildPath $childItem
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (z:String) [Join-Path], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.JoinPathCommand

Cannot bind argument to parameter 'Path' because it is an empty string.
    + CategoryInfo          : InvalidData: (:) [Test-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.TestPathCommand
    + PSComputerName        : WHSQLDEV01

The term 'New-VHD' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct   
and try again.
    + CategoryInfo          : ObjectNotFound: (New-VHD:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : WHSQLDEV01

z:\sql_clones exists on the SQL host, and the same command works when issued on that host.

I've tracked it down to the following line in Dcn-NewClone:

$accessPath = Join-PSFPath -Path $Destination -Child $mountDirectory

Join-PSFPath does not seem to work correctly when running in admin (which the script forces you to do). It seems to check to make sure that the drive exists on the local machine instead of just... well, doing it's job and concatenating into a path.

I know Join-PSFPath isn't part of this project, but I'm wondering if there's an alternative that should be used for instances like this.

A workaround (untested, will check soon) may be to symlink z drive onto a drive that is shared by both local machine and host (ofc, this would be c drive), but this is ofc hacky.

@blitzmann
Copy link
Contributor Author

Looks like [System.IO.Path]::Combine($Destination,$mountDirectory) would work, I'll make a PR, however I don't know how prevalent it is. I'll keep poking around as I test things

@sanderstad
Copy link
Collaborator

Instead we can also use Join-Path if Join-PSFPath is a problem

@blitzmann
Copy link
Contributor Author

Join-Path had the same issues. Seems ridiculous to me, but it is what it is. This is the reason I use Combine as it doesn't validate the existence of a drive

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.

2 participants