Orange-Cyberdefense / GOAD

game of active directory
GNU General Public License v3.0
5.12k stars 715 forks source link

Provisioning with powershell script - Multiple errors when setting up Win2016 & Win2019 server #183

Closed Nathanahell closed 6 months ago

Nathanahell commented 7 months ago

Upon building the Win2019 Server VM with : packer build -var-file=windows_server2019_proxmox_cloudinit.pkvars.hcl .

I get the following errors during the provisioning through the powershell scripts :

image

Full error output (so far is) can be found below :

roxmox-iso.windows: output will be in this color.

==> proxmox-iso.windows: Retrieving additional ISO
==> proxmox-iso.windows: Trying ./iso/Autounattend_winserver2019_cloudinit.iso
==> proxmox-iso.windows: Trying ./iso/Autounattend_winserver2019_cloudinit.iso?checksum=sha256%3A39cc80dc665c91ca80f7dea3c043cfc09e3dd581652ede0c813b119a043ebbd2
==> proxmox-iso.windows: ./iso/Autounattend_winserver2019_cloudinit.iso?checksum=sha256%3A39cc80dc665c91ca80f7dea3c043cfc09e3dd581652ede0c813b119a043ebbd2 => /root/GOAD/packer/proxmox/iso/Autounattend_winserver2019_cloudinit.iso
    proxmox-iso.windows: Uploaded ISO to local:iso/Autounattend_winserver2019_cloudinit.iso
==> proxmox-iso.windows: Creating VM
==> proxmox-iso.windows: No VM ID given, getting next free from Proxmox
==> proxmox-iso.windows: Starting VM
==> proxmox-iso.windows: Waiting for WinRM to become available...
    proxmox-iso.windows: WinRM connected.
==> proxmox-iso.windows: Connected to WinRM!
==> proxmox-iso.windows: Provisioning with Powershell...
==> proxmox-iso.windows: Provisioning with powershell script: ./scripts/sysprep/cloudbase-init.ps1
    proxmox-iso.windows: & : The term 'c:/Windows/Temp/script-65c5121c-ece8-e9ce-2037-ff9f4dc3f2d8.ps1' is not recognized as the name of a
    proxmox-iso.windows: cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
    proxmox-iso.windows: that the path is correct and try again.
    proxmox-iso.windows: At line:1 char:216
    proxmox-iso.windows: + ... 36e29.ps1; &'c:/Windows/Temp/script-65c5121c-ece8-e9ce-2037-ff9f4dc3f ...
    proxmox-iso.windows: +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : ObjectNotFound: (c:/Windows/Temp...f9f4dc3f2d8.ps1:String) [], CommandNotFoundException
    proxmox-iso.windows:     + FullyQualifiedErrorId : CommandNotFoundException
    proxmox-iso.windows:
==> proxmox-iso.windows: Pausing 1m0s before the next provisioner...
==> proxmox-iso.windows: Provisioning with Powershell...
==> proxmox-iso.windows: Provisioning with powershell script: ./scripts/sysprep/cloudbase-init-p2.ps1
    proxmox-iso.windows: Select-String : Cannot find path 'C:\setup\cloud-init.log' because it does not exist.
    proxmox-iso.windows: At C:\Windows\Temp\script-65c5127b-67ca-3b94-277d-6d6c3de1ebfb.ps1:1 char:10
    proxmox-iso.windows: + while (!(Select-String -Path 'C:\setup\cloud-init.log' -Pattern 'Inst ...
    proxmox-iso.windows: +          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : ObjectNotFound: (C:\setup\cloud-init.log:String) [Select-String], ItemNotFoundException
    proxmox-iso.windows:     + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SelectStringCommand
    proxmox-iso.windows:
    proxmox-iso.windows: Show cloudinit service
    proxmox-iso.windows: Get-Service : Cannot find any service with service name 'cloudbase-init'.
    proxmox-iso.windows: At C:\Windows\Temp\script-65c5127b-67ca-3b94-277d-6d6c3de1ebfb.ps1:7 char:1
    proxmox-iso.windows: + Get-Service -Name cloudbase-init
    proxmox-iso.windows: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : ObjectNotFound: (cloudbase-init:String) [Get-Service], ServiceCommandException
    proxmox-iso.windows:     + FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand
    proxmox-iso.windows:
    proxmox-iso.windows: Move config files to location
    proxmox-iso.windows: copy-item : Could not find a part of the path 'C:\Program Files\Cloudbase
    proxmox-iso.windows: Solutions\Cloudbase-Init\conf\cloudbase-init.conf'.
    proxmox-iso.windows: At C:\Windows\Temp\script-65c5127b-67ca-3b94-277d-6d6c3de1ebfb.ps1:11 char:1
    proxmox-iso.windows: + copy-item "G:\sysprep\cloudbase-init.conf" "C:\Program Files\Cloudbas ...
    proxmox-iso.windows: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : NotSpecified: (:) [Copy-Item], DirectoryNotFoundException
    proxmox-iso.windows:     + FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand
    proxmox-iso.windows:
    proxmox-iso.windows: copy-item : Could not find a part of the path 'C:\Program Files\Cloudbase
    proxmox-iso.windows: Solutions\Cloudbase-Init\conf\cloudbase-init-unattend.conf'.
    proxmox-iso.windows: At C:\Windows\Temp\script-65c5127b-67ca-3b94-277d-6d6c3de1ebfb.ps1:12 char:1
    proxmox-iso.windows: + copy-item "G:\sysprep\cloudbase-init-unattend.conf" "C:\Program Files ...
    proxmox-iso.windows: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : NotSpecified: (:) [Copy-Item], DirectoryNotFoundException
    proxmox-iso.windows:     + FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand
    proxmox-iso.windows:
    proxmox-iso.windows: copy-item : Could not find a part of the path 'C:\Program Files\Cloudbase
    proxmox-iso.windows: Solutions\Cloudbase-Init\conf\cloudbase-init-unattend.xml'.
    proxmox-iso.windows: At C:\Windows\Temp\script-65c5127b-67ca-3b94-277d-6d6c3de1ebfb.ps1:13 char:1
    proxmox-iso.windows: + copy-item "G:\sysprep\cloudbase-init-unattend.xml" "C:\Program Files\ ...
    proxmox-iso.windows: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : NotSpecified: (:) [Copy-Item], DirectoryNotFoundException
    proxmox-iso.windows:     + FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand
    proxmox-iso.windows:
    proxmox-iso.windows: Disable cloudbaseinit at start
    proxmox-iso.windows: Set-Service : Service cloudbase-init was not found on computer '.'.
    proxmox-iso.windows: At C:\Windows\Temp\script-65c5127b-67ca-3b94-277d-6d6c3de1ebfb.ps1:17 char:1
    proxmox-iso.windows: + Set-Service -Name cloudbase-init -StartupType Disabled
    proxmox-iso.windows: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : ObjectNotFound: (.:String) [Set-Service], InvalidOperationException
    proxmox-iso.windows:     + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.SetServiceCommand
    proxmox-iso.windows:
    proxmox-iso.windows: cd : Cannot find path 'C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\' because it does not exist.
    proxmox-iso.windows: At C:\Windows\Temp\script-65c5127b-67ca-3b94-277d-6d6c3de1ebfb.ps1:20 char:1
    proxmox-iso.windows: + cd "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\"
    proxmox-iso.windows: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : ObjectNotFound: (C:\Program File...base-Init\conf\:String) [Set-Location], ItemNotFoundE
    proxmox-iso.windows:    xception
    proxmox-iso.windows:     + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
    proxmox-iso.windows:
xsxz commented 7 months ago

@Nathanahell you should fix ./packer/proxmox/scripts/sysprep/cloudbase-init.ps1 copy-item "G:\sysprep\CloudbaseInitSetup_Stable_x64.msi" "c:\setup\CloudbaseInitSetup_Stable_x64.msi" -force to copy-item "G:\CloudbaseInitSetup_Stable_x64.msi" "c:\setup\CloudbaseInitSetup_Stable_x64.msi" -force and then rerun build_proxmox_iso.sh to generate iso files with updated file

cc @Mayfly277

Nathanahell commented 7 months ago

Hello again, that cleared some errors. I'm pasting here the rest of my faulty output upon applying the previous fix :

proxmox-iso.windows: output will be in this color.

==> proxmox-iso.windows: Retrieving additional ISO
==> proxmox-iso.windows: Trying ./iso/Autounattend_winserver2016_cloudinit.iso
==> proxmox-iso.windows: Trying ./iso/Autounattend_winserver2016_cloudinit.iso?checksum=sha256%3A2648515e8bec8f80fb863659d537fbb66f624933cb4f061698b1d452df7b19ec
==> proxmox-iso.windows: ./iso/Autounattend_winserver2016_cloudinit.iso?checksum=sha256%3A2648515e8bec8f80fb863659d537fbb66f624933cb4f061698b1d452df7b19ec => /root/GOAD/packer/proxmox/iso/Autounattend_winserver2016_cloudinit.iso                                                                                                  
    proxmox-iso.windows: Uploaded ISO to local:iso/Autounattend_winserver2016_cloudinit.iso
==> proxmox-iso.windows: Creating VM
==> proxmox-iso.windows: No VM ID given, getting next free from Proxmox
==> proxmox-iso.windows: Starting VM
==> proxmox-iso.windows: Waiting for WinRM to become available...
    proxmox-iso.windows: WinRM connected.
==> proxmox-iso.windows: Connected to WinRM!
==> proxmox-iso.windows: Provisioning with Powershell...
==> proxmox-iso.windows: Provisioning with powershell script: ./scripts/sysprep/cloudbase-init.ps1
    proxmox-iso.windows:
    proxmox-iso.windows:
    proxmox-iso.windows:     Directory: C:\
    proxmox-iso.windows:
    proxmox-iso.windows:
    proxmox-iso.windows: Mode                LastWriteTime         Length Name
    proxmox-iso.windows: ----                -------------         ------ ----
    proxmox-iso.windows: d-----        2/12/2024   5:10 PM                setup
    proxmox-iso.windows: Copy CloudbaseInitSetup_Stable_x64.msi
    proxmox-iso.windows: copy-item : Cannot find path 'G:\CloudbaseInitSetup_Stable_x64.msi' because it does not exist.
    proxmox-iso.windows: At C:\Windows\Temp\script-65ca42cb-1cf5-ac45-f24e-715d23085af0.ps1:4 char:1
    proxmox-iso.windows: + copy-item "G:\CloudbaseInitSetup_Stable_x64.msi" "c:\setup\CloudbaseI ...
    proxmox-iso.windows: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : ObjectNotFound: (G:\CloudbaseInitSetup_Stable_x64.msi:String) [Copy-Item], ItemNotFoundE
    proxmox-iso.windows:    xception
    proxmox-iso.windows:     + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
    proxmox-iso.windows:
    proxmox-iso.windows: Start process CloudbaseInitSetup_Stable_x64.msi
    proxmox-iso.windows: start-process : This command cannot be run due to the error: The system cannot find the file specified.
    proxmox-iso.windows: At C:\Windows\Temp\script-65ca42cb-1cf5-ac45-f24e-715d23085af0.ps1:6 char:1
    proxmox-iso.windows: + start-process -FilePath 'c:\setup\CloudbaseInitSetup_Stable_x64.msi'  ...
    proxmox-iso.windows: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    proxmox-iso.windows:     + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
    proxmox-iso.windows:
==> proxmox-iso.windows: Pausing 1m0s before the next provisioner...
==> proxmox-iso.windows: Provisioning with Powershell...
==> proxmox-iso.windows: Provisioning with powershell script: ./scripts/sysprep/cloudbase-init-p2.ps1
    proxmox-iso.windows: Select-String : Cannot find path 'C:\setup\cloud-init.log' because it does not exist.
    proxmox-iso.windows: At C:\Windows\Temp\script-65ca4325-3100-8777-a8a1-7bef56c77623.ps1:1 char:10
    proxmox-iso.windows: + while (!(Select-String -Path 'C:\setup\cloud-init.log' -Pattern 'Inst ...
    proxmox-iso.windows: +          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : ObjectNotFound: (C:\setup\cloud-init.log:String) [Select-String], ItemNotFoundException
    proxmox-iso.windows:     + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SelectStringCommand
    proxmox-iso.windows:
    proxmox-iso.windows: Show cloudinit service
    proxmox-iso.windows: Get-Service : Cannot find any service with service name 'cloudbase-init'.
    proxmox-iso.windows: At C:\Windows\Temp\script-65ca4325-3100-8777-a8a1-7bef56c77623.ps1:7 char:1
    proxmox-iso.windows: + Get-Service -Name cloudbase-init
    proxmox-iso.windows: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : ObjectNotFound: (cloudbase-init:String) [Get-Service], ServiceCommandException
    proxmox-iso.windows:     + FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand
    proxmox-iso.windows:
    proxmox-iso.windows: Move config files to location
    proxmox-iso.windows: copy-item : Could not find a part of the path 'C:\Program Files\Cloudbase
    proxmox-iso.windows: Solutions\Cloudbase-Init\conf\cloudbase-init.conf'.
    proxmox-iso.windows: At C:\Windows\Temp\script-65ca4325-3100-8777-a8a1-7bef56c77623.ps1:11 char:1
    proxmox-iso.windows: + copy-item "G:\sysprep\cloudbase-init.conf" "C:\Program Files\Cloudbas ...
    proxmox-iso.windows: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : NotSpecified: (:) [Copy-Item], DirectoryNotFoundException
    proxmox-iso.windows:     + FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand
    proxmox-iso.windows:
    proxmox-iso.windows: copy-item : Could not find a part of the path 'C:\Program Files\Cloudbase
    proxmox-iso.windows: Solutions\Cloudbase-Init\conf\cloudbase-init-unattend.conf'.
    proxmox-iso.windows: At C:\Windows\Temp\script-65ca4325-3100-8777-a8a1-7bef56c77623.ps1:12 char:1
    proxmox-iso.windows: + copy-item "G:\sysprep\cloudbase-init-unattend.conf" "C:\Program Files ...
    proxmox-iso.windows: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : NotSpecified: (:) [Copy-Item], DirectoryNotFoundException
    proxmox-iso.windows:     + FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand
    proxmox-iso.windows:
    proxmox-iso.windows: copy-item : Cannot find path 'G:\cloudbase-init-unattend.xml' because it does not exist.
    proxmox-iso.windows: At C:\Windows\Temp\script-65ca4325-3100-8777-a8a1-7bef56c77623.ps1:13 char:1
    proxmox-iso.windows: + copy-item "G:\cloudbase-init-unattend.xml" "C:\Program Files\Cloudbas ...
    proxmox-iso.windows: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : ObjectNotFound: (G:\cloudbase-init-unattend.xml:String) [Copy-Item], ItemNotFoundExcepti
    proxmox-iso.windows:    on
    proxmox-iso.windows:     + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
    proxmox-iso.windows:
    proxmox-iso.windows: Disable cloudbaseinit at start
    proxmox-iso.windows: Set-Service : Service cloudbase-init was not found on computer '.'.
    proxmox-iso.windows: At C:\Windows\Temp\script-65ca4325-3100-8777-a8a1-7bef56c77623.ps1:17 char:1
    proxmox-iso.windows: + Set-Service -Name cloudbase-init -StartupType Disabled
    proxmox-iso.windows: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : ObjectNotFound: (.:String) [Set-Service], InvalidOperationException
    proxmox-iso.windows:     + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.SetServiceCommand
    proxmox-iso.windows:
    proxmox-iso.windows: cd : Cannot find path 'C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\' because it does not exist.
    proxmox-iso.windows: At C:\Windows\Temp\script-65ca4325-3100-8777-a8a1-7bef56c77623.ps1:20 char:1
    proxmox-iso.windows: + cd "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\"
    proxmox-iso.windows: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    proxmox-iso.windows:     + CategoryInfo          : ObjectNotFound: (C:\Program File...base-Init\conf\:String) [Set-Location], ItemNotFoundE
    proxmox-iso.windows:    xception
    proxmox-iso.windows:     + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
Mayfly277 commented 6 months ago

The msi should be placed inside the sysprep folder image

image

agent-69 commented 3 months ago

изображение Please, tell me what did happen here?

tuxvador commented 3 months ago

Restarting PFSENSE solved the issue for me

Gromiton commented 2 months ago

Where you able to resolve this? I am running into the exact same problem here

V1rucov commented 2 months ago

@Gromiton Check this Out, helped me https://github.com/rgl/packer-plugin-proxmox-issue-197