Skip to content

Commit e7ec7f2

Browse files
authored
Merge pull request #14 from sanderstad/development
Fixed bugs in APPDATA folde usage
2 parents fe0a623 + 10f1733 commit e7ec7f2

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

functions/clone/New-PSDCClone.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,15 @@
154154

155155
# Set the location where to save the diskpart command
156156
$diskpartScriptFile = Get-PSFConfigValue -FullName psdatabaseclone.diskpart.scriptfile -Fallback "$env:APPDATA\psdatabaseclone\diskpartcommand.txt"
157+
158+
if(-not (Test-Path -Path $diskpartScriptFile)){
159+
try{
160+
$null = New-Item -Path $diskpartScriptFile -ItemType File
161+
}
162+
catch{
163+
Stop-PSFFunction -Message "Could not create diskpart script file" -ErrorRecord $_ -Continue
164+
}
165+
}
157166
}
158167

159168
process {

functions/disk/New-PSDCVhdDisk.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@
164164

165165
# Set the location where to save the diskpart command
166166
$diskpartScriptFile = Get-PSFConfigValue -FullName psdatabaseclone.diskpart.scriptfile -Fallback "$env:APPDATA\psdatabaseclone\diskpartcommand.txt"
167+
168+
if(-not (Test-Path -Path $diskpartScriptFile)){
169+
try{
170+
$null = New-Item -Path $diskpartScriptFile -ItemType File
171+
}
172+
catch{
173+
Stop-PSFFunction -Message "Could not create diskpart script file" -ErrorRecord $_ -Continue
174+
}
175+
}
167176
}
168177

169178
process {

functions/support/Set-PSDCConfiguration.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@
390390

391391
# Set the path to the diskpart script file
392392
Set-PSFConfig -Module PSDatabaseClone -Name diskpart.scriptfile -Value "$env:APPDATA\psdatabaseclone\diskpartcommand.txt" -Validation string
393+
New-Item -Path "$env:APPDATA\psdatabaseclone" -ItemType Directory
393394
Get-PSFConfig -FullName psdatabaseclone.diskpart.scriptfile | Register-PSFConfig -Scope SystemDefault
394395

395396
# Check if all the settings have been made

0 commit comments

Comments
 (0)