Always create $env:USERPROFILE\.hvtoolscfgpath #12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When use this function initialize a new folder, it didn't update "$env:USERPROFILE.hvtoolscfgpath" file content, or recreate this new file, so reads hvconfig.json configuration from wrong folder. I think "$env:USERPROFILE.hvtoolscfgpath" file need to be updated when run this function.
In my example, I first run " Initialize-HVTools -Path "D:\Hyper-V\DEMO1", when want to use a new folder by using Initialize-HVTools -Path "D:\Hyper-V\DEMO", it reads hvconfig.json path from .hvtoolscfgpath, which it goes to the DEMO1 folder, not DEMO folder.
PS C:\Windows\system32> Initialize-HVTools -Path "D:\Hyper-V\DEMO"
Add-ImageToConfig -ImageName "2004" -IsoPath "D:\No-Dedup\Asennus\ISO\en_windows_10_business_editions_version_2004_updated_june_2020_x64_dvd_cc9defea.iso"
Add-TenantToConfig -TenantName "Contoso" -ImageName "2004" -AdminUpn "[email protected]"
Add-NetworkToConfig -VSwitchName 'CrazyNet'
New-ClientVM -TenantName 'Contoso' -NumberOfVMs 1 -CPUsPerVM 1 -VMMemory 2gb -Verbose
Creating hvtools folder structure..
Adding 2004 to config.. √
Creating reference Autopilot VHDX - this may take some time..
Select an Image from the below available options:
ImageIndex ImageName
Select Image Index..(1..10): 3
Image 3 / Windows 10 Enterprise selected..
Building reference image..√
Adding Contoso to config.. √
Adding virtual switch details to config.. √
VERBOSE: Autopilot Reference VHDX:
VERBOSE: Client name: Contoso
VERBOSE: Win10 ISO is located:
VERBOSE: Path to client VMs will be: D:\Hyper-V\DEMO1.hvtools\tenantVMs\Contoso
VERBOSE: Number of VMs to create: 1
VERBOSE: Admin user for Contoso is: [email protected] [email protected]
WARNING: Cannot bind argument to parameter 'Path' because it is null.