Open ananace opened 6 years ago
This might be a good thing to prioritize doing - if only to make object passing easier to support;
$Args = @(
'Id' = '<guid>';
'ComputerName' = '<computer>';
)
$VM = Get-VM @Args
$Args = @(
'VM' = $VM;
'ComputerName' = '<computer>';
'Switch' = '<switch>';
)
Add-VMNetworkAdapter @Args
Or maybe even something alike;
$VMArgs = @(
'Id' = '<guid>';
'ComputerName' = '<computer>';
)
$Args = @(
'VM' = Get-VM @VMArgs;
'ComputerName' = '<computer>';
'Switch' = '<switch>';
)
Add-VMNetworkAdapter @Args
Code is now available for argument splatting, and can be enabled with connection or method level flags.
c = Fog::Compute.new provider: :HyperV, hyperv_host: '...' # ...
c.bake_optmap = true # Splat arguments into pre-baked option maps
c.bake_json = true # Additionally bake option maps by transferring JSON blobs
The code works in many places, but there are cases where the sending of false
and nil
leads to other responses from the cmdlets.
To replace stupidly long command lists with something more shell-ish.
New-VM -BootDevice NetworkAdapter -Generation 1 -Name aimee-nappo.example.com -NewVHDPath C:\VHD\Disk.vhdx -NewVHDSizeBytes 68719467636 -SwitchName net_switch -MemoryStartupBytes 536870912
Would instead become;This would probably also allow transferring argument values in JSON format, which would drastically reduce the risk of encoding problems and code execution issues.