bottkars / vmxtoolkit

vmxtoolkit is the Powershell extension to VMware Workstation
Apache License 2.0
116 stars 32 forks source link

new-vmx not writing GuestOS Type to config file #27

Open sailingbikeruk opened 2 years ago

sailingbikeruk commented 2 years ago

PS_Error VMware_Workstation_Error This could just be me as a newbie but the PS below doesnt write the GuestOS to the config file causing the VM to fail to start with the error "The configuration file does not specify a guest OS"

Windows 10 Home 64-Bit Build 19043.1348 PS 5.1 VMware workstation Pro 15.5.7

new-vmx -VMXName MyWin10 -GuestOS windows9-64 -Firmware BIOS -Path <PathToFile> | 
    New-VMXScsiDisk -NewDiskSize 60GB -NewDiskName SCSI_0 | 
    Add-VMXScsiDisk -LUN 0 -controller 0 | 
    Connect-VMXcdromImage -ISOFile <PathToFile> |
    Set-VMXNetworkAdapter -Adapter 0 -ConnectionType nat -AdapterType vmxnet3 | 
    start-vmx -nowait

I get the following PS error

Set-Content : The process cannot access the file 'H:\Test_VM\MyWin10\MyWin10.vmx' because it is being used by another process.
At C:\Program Files\WindowsPowerShell\Modules\vmxtoolkit\4.5.3.1\vmxtoolkit.psm1:2202 char:13
+             Set-Content -Path $config -Value $content -Force
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-Content], IOException
    + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.SetContentCommand

I've attached the output from the PS Console and the error from Workstation as screenshots.

It appears that it starts the VM BEFORE writing the Guest OS and then cannot do so:

 ==>Creating new VM MyWin10[success]
 ==>creating new 60GB SCSI Disk SCSI_0 at H:\Test_VM\MyWin10VixDiskLib: Failed to initialize PhoneHome library.
[success]
 ==>adding Disk SCSI_0.vmdk at Controller 0 LUN 0 to MyWin10[success]
 ==> Configuring IDE sata0:1 on MyWin10[success]
WARNING: Adapter not present, will be added
 ==>configuring Ethernet0 as vmxnet3 with nat for MyWin10[success]
 ==>starting Virtual Machine MyWin10[success]

 ==>setting GuestOS windows9-64 for MyWin10[success]
VMXname Status  Starttime
------- ------  ---------
MyWin10 Started 11.21.2021 11:46:15
Set-Content : The process cannot access the file 'H:\Test_VM\MyWin10\MyWin10.vmx' because it is being used by another process.
At C:\Program Files\WindowsPowerShell\Modules\vmxtoolkit\4.5.3.1\vmxtoolkit.psm1:2202 char:13
+             Set-Content -Path $config -Value $content -Force
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-Content], IOException
    + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.SetContentCommand

PS F:\OneDrive\Documents\GitHub\vmxtoolkit> Error: Unknown error