diff --git a/functions/clone/New-PSDCClone.ps1 b/functions/clone/New-PSDCClone.ps1 index 7c47386..db34dd6 100644 --- a/functions/clone/New-PSDCClone.ps1 +++ b/functions/clone/New-PSDCClone.ps1 @@ -154,6 +154,15 @@ # Set the location where to save the diskpart command $diskpartScriptFile = Get-PSFConfigValue -FullName psdatabaseclone.diskpart.scriptfile -Fallback "$env:APPDATA\psdatabaseclone\diskpartcommand.txt" + + if(-not (Test-Path -Path $diskpartScriptFile)){ + try{ + $null = New-Item -Path $diskpartScriptFile -ItemType File + } + catch{ + Stop-PSFFunction -Message "Could not create diskpart script file" -ErrorRecord $_ -Continue + } + } } process { diff --git a/functions/disk/New-PSDCVhdDisk.ps1 b/functions/disk/New-PSDCVhdDisk.ps1 index 8edbf0e..b7da801 100644 --- a/functions/disk/New-PSDCVhdDisk.ps1 +++ b/functions/disk/New-PSDCVhdDisk.ps1 @@ -164,6 +164,15 @@ # Set the location where to save the diskpart command $diskpartScriptFile = Get-PSFConfigValue -FullName psdatabaseclone.diskpart.scriptfile -Fallback "$env:APPDATA\psdatabaseclone\diskpartcommand.txt" + + if(-not (Test-Path -Path $diskpartScriptFile)){ + try{ + $null = New-Item -Path $diskpartScriptFile -ItemType File + } + catch{ + Stop-PSFFunction -Message "Could not create diskpart script file" -ErrorRecord $_ -Continue + } + } } process { diff --git a/functions/support/Set-PSDCConfiguration.ps1 b/functions/support/Set-PSDCConfiguration.ps1 index ceb330f..0a7303a 100644 --- a/functions/support/Set-PSDCConfiguration.ps1 +++ b/functions/support/Set-PSDCConfiguration.ps1 @@ -390,6 +390,7 @@ # Set the path to the diskpart script file Set-PSFConfig -Module PSDatabaseClone -Name diskpart.scriptfile -Value "$env:APPDATA\psdatabaseclone\diskpartcommand.txt" -Validation string + New-Item -Path "$env:APPDATA\psdatabaseclone" -ItemType Directory Get-PSFConfig -FullName psdatabaseclone.diskpart.scriptfile | Register-PSFConfig -Scope SystemDefault # Check if all the settings have been made