diff --git a/plugins/providers/hyperv/scripts/check_hyperv.ps1 b/plugins/providers/hyperv/scripts/check_hyperv.ps1 index 1d1775314..9e64bed14 100644 --- a/plugins/providers/hyperv/scripts/check_hyperv.ps1 +++ b/plugins/providers/hyperv/scripts/check_hyperv.ps1 @@ -5,4 +5,4 @@ $result = @{ result = $check } -Write-Output-Message $(ConvertTo-Json $result) +Write-OutputMessage $(ConvertTo-Json $result) diff --git a/plugins/providers/hyperv/scripts/clone_vhd.ps1 b/plugins/providers/hyperv/scripts/clone_vhd.ps1 index 829366635..1fe4ab3cc 100644 --- a/plugins/providers/hyperv/scripts/clone_vhd.ps1 +++ b/plugins/providers/hyperv/scripts/clone_vhd.ps1 @@ -13,6 +13,6 @@ $ErrorActionPreference = "Stop" try { Hyper-V\New-VHD -Path $Destination -ParentPath $Source } catch { - Write-Error-Message "Failed to clone drive: ${PSItem}" + Write-ErrorMessage "Failed to clone drive: ${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/configure_vm.ps1 b/plugins/providers/hyperv/scripts/configure_vm.ps1 index 908bb1f24..ff2b8ca3b 100644 --- a/plugins/providers/hyperv/scripts/configure_vm.ps1 +++ b/plugins/providers/hyperv/scripts/configure_vm.ps1 @@ -26,7 +26,7 @@ $ErrorActionPreference = "Stop" try { $VM = Hyper-V\Get-VM -Id $VMID } catch { - Write-Error-Message "Failed to locate VM: ${PSItem}" + Write-ErrorMessage "Failed to locate VM: ${PSItem}" exit 1 } @@ -34,7 +34,7 @@ if($Processors) { try { Set-VagrantVMCPUS -VM $VM -CPUCount ($Processors -as [int]) } catch { - Write-Error-Message "Failed to configure CPUs: ${PSItem}" + Write-ErrorMessage "Failed to configure CPUs: ${PSItem}" exit 1 } } @@ -43,7 +43,7 @@ if($Memory -or $MaxMemory) { try { Set-VagrantVMMemory -VM $VM -Memory $Memory -MaxMemory $MaxMemory } catch { - Write-Error-Message "Failed to configure memory: ${PSItem}" + Write-ErrorMessage "Failed to configure memory: ${PSItem}" exit 1 } } @@ -52,7 +52,7 @@ if($AutoStartAction -or $AutoStopAction) { try { Set-VagrantVMAutoActions -VM $VM -AutoStartAction $AutoStartAction -AutoStopAction $AutoStopAction } catch { - Write-Error-Message "Failed to configure automatic actions: ${PSItem}" + Write-ErrorMessage "Failed to configure automatic actions: ${PSItem}" exit 1 } } @@ -66,7 +66,7 @@ if($VirtualizationExtensions) { try { Set-VagrantVMVirtExtensions -VM $VM -Enabled $virtex } catch { - Write-Error-Message "Failed to configure virtualization extensions: ${PSItem}" + Write-ErrorMessage "Failed to configure virtualization extensions: ${PSItem}" exit 1 } @@ -75,7 +75,7 @@ if($SwitchID) { $SwitchName = Get-VagrantVMSwitch -NameOrID $SwitchID Set-VagrantVMSwitch -VM $VM -SwitchName $SwitchName } catch { - Write-Error-Message "Failed to configure network adapter: ${PSItem}" + Write-ErrorMessage "Failed to configure network adapter: ${PSItem}" } } @@ -90,6 +90,6 @@ if($EnableCheckpoints) { try { Hyper-V\Set-VM -VM $VM -CheckpointType $checkpoints } catch { - Write-Error-Message "Failed to ${CheckpointAction} checkpoints on VM: ${PSItem}" + Write-ErrorMessage "Failed to ${CheckpointAction} checkpoints on VM: ${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/create_snapshot.ps1 b/plugins/providers/hyperv/scripts/create_snapshot.ps1 index 775f91898..4a61acf68 100644 --- a/plugins/providers/hyperv/scripts/create_snapshot.ps1 +++ b/plugins/providers/hyperv/scripts/create_snapshot.ps1 @@ -12,6 +12,6 @@ try { $VM = Hyper-V\Get-VM -Id $VmId Hyper-V\Checkpoint-VM $VM -SnapshotName $SnapName } catch { - Write-Error-Message "Failed to create snapshot: ${PSItem}" + Write-ErrorMessage "Failed to create snapshot: ${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/delete_snapshot.ps1 b/plugins/providers/hyperv/scripts/delete_snapshot.ps1 index bba44b588..54633fa59 100644 --- a/plugins/providers/hyperv/scripts/delete_snapshot.ps1 +++ b/plugins/providers/hyperv/scripts/delete_snapshot.ps1 @@ -12,5 +12,5 @@ try { $VM = Hyper-V\Get-VM -Id $VmId Hyper-V\Remove-VMSnapshot $VM -Name $SnapName } catch { - Write-Error-Message "Failed to delete snapshot: ${PSItem}" + Write-ErrorMessage "Failed to delete snapshot: ${PSItem}" } diff --git a/plugins/providers/hyperv/scripts/delete_vm.ps1 b/plugins/providers/hyperv/scripts/delete_vm.ps1 index 53e160b16..18349b475 100644 --- a/plugins/providers/hyperv/scripts/delete_vm.ps1 +++ b/plugins/providers/hyperv/scripts/delete_vm.ps1 @@ -11,6 +11,6 @@ try { $VM = Hyper-V\Get-VM -Id $VmId Hyper-V\Remove-VM $VM -Force } catch { - Write-Error-Message "Failed to delete VM: ${PSItem}" + Write-ErrorMessage "Failed to delete VM: ${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/export_vm.ps1 b/plugins/providers/hyperv/scripts/export_vm.ps1 index 263c12be2..828992291 100644 --- a/plugins/providers/hyperv/scripts/export_vm.ps1 +++ b/plugins/providers/hyperv/scripts/export_vm.ps1 @@ -13,7 +13,7 @@ try { $vm = Hyper-V\Get-VM -Id $VmId $vm | Hyper-V\Export-VM -Path $Path } catch { - Write-Error-Message "Failed to export VM: ${PSItem}" + Write-ErrorMessage "Failed to export VM: ${PSItem}" exit 1 } @@ -24,6 +24,6 @@ try { Remove-Item -Path $Path/Snapshots -Force -Recurse Remove-Item -Path $Path/$name -Force } catch { - Write-Error-Message "Failed to format exported box: ${PSItem}" + Write-ErrorMessage "Failed to format exported box: ${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/file_sync.ps1 b/plugins/providers/hyperv/scripts/file_sync.ps1 index ffe340407..8207a9f4c 100644 --- a/plugins/providers/hyperv/scripts/file_sync.ps1 +++ b/plugins/providers/hyperv/scripts/file_sync.ps1 @@ -120,4 +120,4 @@ $resultHash = @{ message = "OK" } $result = ConvertTo-Json $resultHash -Write-Output-Message $result +Write-OutputMessage $result diff --git a/plugins/providers/hyperv/scripts/get_network_config.ps1 b/plugins/providers/hyperv/scripts/get_network_config.ps1 index 959501add..639fc6341 100644 --- a/plugins/providers/hyperv/scripts/get_network_config.ps1 +++ b/plugins/providers/hyperv/scripts/get_network_config.ps1 @@ -10,7 +10,7 @@ $ErrorActionPreference = "Stop" try { $vm = Hyper-V\Get-VM -Id $VmId } catch { - Write-Error-Message "Failed to locate VM: ${PSItem}" + Write-ErrorMessage "Failed to locate VM: ${PSItem}" exit 1 } @@ -57,12 +57,12 @@ try { ip = $guest_ipaddress } $result = ConvertTo-Json $resultHash - Write-Output-Message $result + Write-OutputMessage $result } else { - Write-Error-Message "Failed to determine IP address" + Write-ErrorMessage "Failed to determine IP address" exit 1 } } catch { - Write-Error-Message "Unexpected error while detecting network configuration: ${PSItem}" + Write-ErrorMessage "Unexpected error while detecting network configuration: ${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/get_network_mac.ps1 b/plugins/providers/hyperv/scripts/get_network_mac.ps1 index 88d4c0306..c00be744f 100644 --- a/plugins/providers/hyperv/scripts/get_network_mac.ps1 +++ b/plugins/providers/hyperv/scripts/get_network_mac.ps1 @@ -25,8 +25,8 @@ try { mac = "$mac_address" } $result = ConvertTo-Json $resultHash - Write-Output-Message $result + Write-OutputMessage $result } catch { - Write-Error-Message "Unexpected error while fetching MAC: ${PSItem}" + Write-ErrorMessage "Unexpected error while fetching MAC: ${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/get_switches.ps1 b/plugins/providers/hyperv/scripts/get_switches.ps1 index 83632aaa8..5c56854fd 100644 --- a/plugins/providers/hyperv/scripts/get_switches.ps1 +++ b/plugins/providers/hyperv/scripts/get_switches.ps1 @@ -7,4 +7,4 @@ $Switches = @(Hyper-V\Get-VMSwitch ` | Select-Object Name,SwitchType,NetAdapterInterfaceDescription,Id) -Write-Output-Message $(ConvertTo-JSON $Switches) +Write-OutputMessage $(ConvertTo-JSON $Switches) diff --git a/plugins/providers/hyperv/scripts/get_vm_status.ps1 b/plugins/providers/hyperv/scripts/get_vm_status.ps1 index 90c05cbcc..dbe538440 100644 --- a/plugins/providers/hyperv/scripts/get_vm_status.ps1 +++ b/plugins/providers/hyperv/scripts/get_vm_status.ps1 @@ -46,4 +46,4 @@ $resultHash = @{ status = "$Status" } $result = ConvertTo-Json $resultHash -Write-Output-Message $result +Write-OutputMessage $result diff --git a/plugins/providers/hyperv/scripts/has_vmcx_support.ps1 b/plugins/providers/hyperv/scripts/has_vmcx_support.ps1 index bf7d89cda..9edba13d8 100644 --- a/plugins/providers/hyperv/scripts/has_vmcx_support.ps1 +++ b/plugins/providers/hyperv/scripts/has_vmcx_support.ps1 @@ -6,4 +6,4 @@ $result = @{ result = $check } -Write-Output-Message $(ConvertTo-Json $result) +Write-OutputMessage $(ConvertTo-Json $result) diff --git a/plugins/providers/hyperv/scripts/import_vm.ps1 b/plugins/providers/hyperv/scripts/import_vm.ps1 index 06fc65622..e339a754e 100644 --- a/plugins/providers/hyperv/scripts/import_vm.ps1 +++ b/plugins/providers/hyperv/scripts/import_vm.ps1 @@ -30,8 +30,8 @@ try { $Result = @{ id = $VM.Id.Guid; } - Write-Output-Message (ConvertTo-Json $Result) + Write-OutputMessage (ConvertTo-Json $Result) } catch { - Write-Error-Message "${PSItem}" + Write-ErrorMessage "${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/list_snapshots.ps1 b/plugins/providers/hyperv/scripts/list_snapshots.ps1 index 7e4b85583..33740cc04 100644 --- a/plugins/providers/hyperv/scripts/list_snapshots.ps1 +++ b/plugins/providers/hyperv/scripts/list_snapshots.ps1 @@ -11,9 +11,9 @@ try { $VM = Hyper-V\Get-VM -Id $VmId $Snapshots = @(Hyper-V\Get-VMSnapshot $VM | Select-Object Name) } catch { - Write-Error-Message "Failed to get snapshot list: ${PSItem}" + Write-ErrorMessage "Failed to get snapshot list: ${PSItem}" exit 1 } $result = ConvertTo-json $Snapshots -Write-Output-Message $result +Write-OutputMessage $result diff --git a/plugins/providers/hyperv/scripts/restore_snapshot.ps1 b/plugins/providers/hyperv/scripts/restore_snapshot.ps1 index 192e56075..d8924dc26 100644 --- a/plugins/providers/hyperv/scripts/restore_snapshot.ps1 +++ b/plugins/providers/hyperv/scripts/restore_snapshot.ps1 @@ -12,6 +12,6 @@ try { $VM = Hyper-V\Get-VM -Id $VmId Hyper-V\Restore-VMSnapshot $VM -Name $SnapName -Confirm:$false } catch { - Write-Error-Message "Failed to restore snapshot: ${PSItem}" + Write-ErrorMessage "Failed to restore snapshot: ${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/resume_vm.ps1 b/plugins/providers/hyperv/scripts/resume_vm.ps1 index f30e05b73..1fe35dd1c 100644 --- a/plugins/providers/hyperv/scripts/resume_vm.ps1 +++ b/plugins/providers/hyperv/scripts/resume_vm.ps1 @@ -11,6 +11,6 @@ try { $VM = Hyper-V\Get-VM -Id $VmId Hyper-V\Resume-VM $VM } catch { - Write-Error-Message "Failed to resume VM: ${PSItem}" + Write-ErrorMessage "Failed to resume VM: ${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/set_name.ps1 b/plugins/providers/hyperv/scripts/set_name.ps1 index ac97fad48..6cb34286e 100644 --- a/plugins/providers/hyperv/scripts/set_name.ps1 +++ b/plugins/providers/hyperv/scripts/set_name.ps1 @@ -12,13 +12,13 @@ $ErrorActionPreference = "Stop" try { $VM = Hyper-V\Get-VM -Id $VMID } catch { - Write-Error-Message "Failed to locate VM: ${PSItem}" + Write-ErrorMessage "Failed to locate VM: ${PSItem}" exit 1 } try { Hyper-V\Set-VM -VM $VM -NewVMName $VMName } catch { - Write-Error-Message "Failed to assign new VM name ${VMName}: ${PSItem}" + Write-ErrorMessage "Failed to assign new VM name ${VMName}: ${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/set_network_mac.ps1 b/plugins/providers/hyperv/scripts/set_network_mac.ps1 index 3942eb621..09338a860 100644 --- a/plugins/providers/hyperv/scripts/set_network_mac.ps1 +++ b/plugins/providers/hyperv/scripts/set_network_mac.ps1 @@ -13,6 +13,6 @@ try { $vm = Hyper-V\Get-VM -Id $VmId Hyper-V\Set-VMNetworkAdapter $vm -StaticMacAddress $Mac } catch { - Write-Error-Message "Failed to set VM MAC address: ${PSItem}" + Write-ErrorMessage "Failed to set VM MAC address: ${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/set_network_vlan.ps1 b/plugins/providers/hyperv/scripts/set_network_vlan.ps1 index 26dc8941d..e61360c44 100644 --- a/plugins/providers/hyperv/scripts/set_network_vlan.ps1 +++ b/plugins/providers/hyperv/scripts/set_network_vlan.ps1 @@ -18,5 +18,5 @@ try { Hyper-V\Set-VMNetworkAdapterVlan $vm -Access -Vlanid $VlanId } catch { - Write-Error-Message "Failed to set VM's Vlan ID $_" + Write-ErrorMessage "Failed to set VM's Vlan ID $_" } diff --git a/plugins/providers/hyperv/scripts/set_vm_integration_services.ps1 b/plugins/providers/hyperv/scripts/set_vm_integration_services.ps1 index 458ddbaf3..9e8092b55 100644 --- a/plugins/providers/hyperv/scripts/set_vm_integration_services.ps1 +++ b/plugins/providers/hyperv/scripts/set_vm_integration_services.ps1 @@ -14,7 +14,7 @@ $ErrorActionPreference = "Stop" try { $VM = Hyper-V\Get-VM -Id $VMID } catch { - Write-Error-Message "Failed to locate VM: ${PSItem}" + Write-ErrorMessage "Failed to locate VM: ${PSItem}" exit 1 } @@ -22,6 +22,6 @@ try { Set-VagrantVMService -VM $VM -Name $Name -Enable $Enable } catch { if($Enable){ $action = "enable" } else { $action = "disable" } - Write-Error-Message "Failed to ${action} VM integration service ${Name}: ${PSItem}" + Write-ErrorMessage "Failed to ${action} VM integration service ${Name}: ${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/start_vm.ps1 b/plugins/providers/hyperv/scripts/start_vm.ps1 index 8380e1c8f..83ed9b8f5 100644 --- a/plugins/providers/hyperv/scripts/start_vm.ps1 +++ b/plugins/providers/hyperv/scripts/start_vm.ps1 @@ -19,8 +19,8 @@ try { name = "$name" } $result = ConvertTo-Json $resultHash - Write-Output-Message $result + Write-OutputMessage $result } catch { - Write-Error-Message "Failed to start VM ${PSItem}" + Write-ErrorMessage "Failed to start VM ${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/stop_vm.ps1 b/plugins/providers/hyperv/scripts/stop_vm.ps1 index 5cf88e636..6624e43cb 100644 --- a/plugins/providers/hyperv/scripts/stop_vm.ps1 +++ b/plugins/providers/hyperv/scripts/stop_vm.ps1 @@ -12,6 +12,6 @@ try{ $VM = Hyper-V\Get-VM -Id $VmId Hyper-V\Stop-VM $VM -Force } catch { - Write-Error-Message "Failed to stop VM: ${PSItem}" + Write-ErrorMessage "Failed to stop VM: ${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/suspend_vm.ps1 b/plugins/providers/hyperv/scripts/suspend_vm.ps1 index 43993ac15..a56bd76b0 100644 --- a/plugins/providers/hyperv/scripts/suspend_vm.ps1 +++ b/plugins/providers/hyperv/scripts/suspend_vm.ps1 @@ -11,6 +11,6 @@ try{ $VM = Hyper-V\Get-VM -Id $VmId Hyper-V\Suspend-VM $VM } catch { - Write-Error-Message "Failed to suspend VM: ${PSItem}" + Write-ErrorMessage "Failed to suspend VM: ${PSItem}" exit 1 } diff --git a/plugins/providers/hyperv/scripts/utils/VagrantMessages/VagrantMessages.psm1 b/plugins/providers/hyperv/scripts/utils/VagrantMessages/VagrantMessages.psm1 index 2f934b6c0..59ea87f75 100644 --- a/plugins/providers/hyperv/scripts/utils/VagrantMessages/VagrantMessages.psm1 +++ b/plugins/providers/hyperv/scripts/utils/VagrantMessages/VagrantMessages.psm1 @@ -3,7 +3,7 @@ # All Rights Reserved. Licensed under the MIT License. #-------------------------------------------------------------------------- -function Write-Error-Message { +function Write-ErrorMessage { param ( [parameter (Mandatory=$true,Position=0)] [string] $Message @@ -16,7 +16,7 @@ function Write-Error-Message { Write-Host "===End-Error===" } -function Write-Output-Message { +function Write-OutputMessage { param ( [parameter (Mandatory=$true,Position=0)] [string] $Message