From 43bc46e2c26ae34dab72f6198a2e180bcb1174ce Mon Sep 17 00:00:00 2001 From: Sander Stad Date: Sat, 1 Sep 2018 16:08:11 +0200 Subject: [PATCH 1/2] Fix errors in APPDATA folder --- appveyor.yml | 2 +- functions/clone/New-PSDCClone.ps1 | 9 +++++++++ functions/disk/New-PSDCVhdDisk.ps1 | 9 +++++++++ functions/support/Set-PSDCConfiguration.ps1 | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index a82ff93..5fddbf3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ # See http://www.appveyor.com/docs/appveyor-yml for many more options -version: 0.1.{build} +version: 0.2.{build} cache: - C:\ProgramData\chocolatey\bin -> appveyor.yml diff --git a/functions/clone/New-PSDCClone.ps1 b/functions/clone/New-PSDCClone.ps1 index 7c47386..344b335 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{ + 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..233539f 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{ + 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 From 9fb474691a91ee1e07536ffd96ba62c5e5658320 Mon Sep 17 00:00:00 2001 From: Sander Stad Date: Sat, 1 Sep 2018 16:14:17 +0200 Subject: [PATCH 2/2] Removed mention of diskpart file beingcreated --- functions/clone/New-PSDCClone.ps1 | 2 +- functions/disk/New-PSDCVhdDisk.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/clone/New-PSDCClone.ps1 b/functions/clone/New-PSDCClone.ps1 index 344b335..db34dd6 100644 --- a/functions/clone/New-PSDCClone.ps1 +++ b/functions/clone/New-PSDCClone.ps1 @@ -157,7 +157,7 @@ if(-not (Test-Path -Path $diskpartScriptFile)){ try{ - New-Item -Path $diskpartScriptFile -ItemType File + $null = New-Item -Path $diskpartScriptFile -ItemType File } catch{ Stop-PSFFunction -Message "Could not create diskpart script file" -ErrorRecord $_ -Continue diff --git a/functions/disk/New-PSDCVhdDisk.ps1 b/functions/disk/New-PSDCVhdDisk.ps1 index 233539f..b7da801 100644 --- a/functions/disk/New-PSDCVhdDisk.ps1 +++ b/functions/disk/New-PSDCVhdDisk.ps1 @@ -167,7 +167,7 @@ if(-not (Test-Path -Path $diskpartScriptFile)){ try{ - New-Item -Path $diskpartScriptFile -ItemType File + $null = New-Item -Path $diskpartScriptFile -ItemType File } catch{ Stop-PSFFunction -Message "Could not create diskpart script file" -ErrorRecord $_ -Continue