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

Always create $env:USERPROFILE\.hvtoolscfgpath #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sandytsang
Copy link

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 "admin@M365x810560.onmicrosoft.com"
Add-NetworkToConfig -VSwitchName 'CrazyNet'
New-ClientVM -TenantName 'Contoso' -NumberOfVMs 1 -CPUsPerVM 1 -VMMemory 2gb -Verbose
Creating hvtools folder structure..

  • Creating D:\Hyper-V\DEMO.hvtools\hvconfig.json.. √ (Already created - no need to run this again..)
    Adding 2004 to config.. √
    Creating reference Autopilot VHDX - this may take some time..
    Select an Image from the below available options:

ImageIndex ImageName


     1 Windows 10 Education             
     2 Windows 10 Education N           
     3 Windows 10 Enterprise            
     4 Windows 10 Enterprise N          
     5 Windows 10 Pro                   
     6 Windows 10 Pro N                 
     7 Windows 10 Pro Education         
     8 Windows 10 Pro Education N       
     9 Windows 10 Pro for Workstations  
    10 Windows 10 Pro N for Workstations

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: admin@M365x810560.onmicrosoft.com admin@M365x810560.onmicrosoft.com

WARNING: Cannot bind argument to parameter 'Path' because it is null.

sandytsang and others added 2 commits July 25, 2020 20:05
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.
@tabs-not-spaces
Copy link
Owner

@sandytsang I'd suggest that unless you specifically specify reset, you shouldn't ever really use the initialize cmdlet. What we could do is check when the cmdlet runs:

  • is there already a .hvToolsCfgPath file?
  • does the path in the file resolve?

if it does, return a message to the user saying that configuration is already found.

we can then replace the "reset" switch with "force" that will allow us to forcefully re-initialize the environment.

Thoughts?

Let me know if you want to give this a go - otherwise I'm happy to implement it.

@sandytsang
Copy link
Author

The "reset" switch sound good! Good job guys, can't wait to test it again!

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 this pull request may close these issues.

None yet

2 participants