Skip to content

Instantly share code, notes, and snippets.

Add-VMNetworkAdapter -VMName dhcpserver -Name ExternalNetwork
$sw = Get-VMSwitch | Where {$_.SwitchType -eq "External"}
Connect-VMNetworkAdapter -VMName dhcpserver -Name "ExternalNetwork" -VMSwitch $sw
Add-VMNetworkAdapter -VMName dhcpserver -Name TestNetwork -StaticMacAddress 00602F123456 -SwitchName ate-internal
Get-VMNetworkAdapter -VMName dhcpserver
Remove-VMNetworkAdapter -VMName dhcpserver -Name "Network Adapter"
New-VMSwitch -Name ate-internal -SwitchType Internal
$TemplateDirectory = $env:TEMPLATE_DIRECTORY
$ImageDirectory = $env:IMAGE_DIRECTORY
$Image = $env:IMAGE
$Template = $env:TEMPLATE
$vmcx = ls "$TemplateDirectory\$Template\Virtual Machines\*.vmcx"
$path = "$TemplateDirectory\$Template\Virtual Machines\" + $vmcx.Name
$vmpath = "$ImageDirectory\$Image"
Import-VM -Path $path -Copy -GenerateNewId -VirtualMachinePath $vmpath -VhdDestinationPath "$vmpath\Virtual Hard Disks"
$vm = Get-VM | Where {$_.Path.StartsWith($vmpath)}
public class TestCommand : ICommand
{
private bool _whatShouldWeReturnForCanExecute;
public bool WhatShouldWeReturnForCanExecute
{
get => _whatShouldWeReturnForCanExecute;
set
{
if (_whatShouldWeReturnForCanExecute == value)
private void Button_Click(object sender, RoutedEventArgs e)
{
Commands.TestCommand.WhatShouldWeReturnForCanExecute =
!Commands.TestCommand.WhatShouldWeReturnForCanExecute;
}
<Window x:Class="Z12_Commands.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Z12_Commands"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<DockPanel LastChildFill="True">
<Menu IsMainMenu="True" DockPanel.Dock="Top">
$vm = Get-VM | Where-Object {$_.Path.StartsWith('D:\working-images\img001')}
Rename-VM -VM $vm -NewName img001
Import-VM -Path 'D:\ate\images\ate-windows-base\Virtual Machines\2005C276-155C-4AD1-8DB6-963EDFB6DB84.vmcx' -Copy -GenerateNewId -VirtualMachinePath D:\working-images\img001 -VhdDestinationPath 'D:\working-images\img001\Virtual Hard Disks'