Dynamic Body Creation

This commit is contained in:
Wes Carroll
2019-04-06 22:49:54 -04:00
parent d6d72a5be2
commit b3d649e495
@@ -56,9 +56,9 @@ function Invoke-ZertoFailover {
# Setup Defaults # Setup Defaults
$body['commitpolicy'] = $commitPolicy $body['commitpolicy'] = $commitPolicy
$body['TimeToWaitBeforeShutdownInSec'] = $timeToWaitBeforeShutdownInSec $body['TimeToWaitBeforeShutdownInSec'] = $timeToWaitBeforeShutdownInSec
foreach ($key in $PSBoundParameters.Keys) { foreach ($param in $PSBoundParameters.GetEnumerator()) {
if ($key -notlike 'vpgName' -and $key -notlike 'vmName' -and $key -notlike 'WhatIf' -and $key -notlike 'TimeToWaitBeforeShutdownInSec' -and $key -notlike 'commitpolicy') { if ($param.key -notlike 'vpgName' -and $param.key -notlike 'vmName' -and $param.key -notlike 'WhatIf' -and $param.key -notlike 'TimeToWaitBeforeShutdownInSec' -and $param.key -notlike 'commitpolicy') {
$body[$key] = $PSBoundParameters['key'] $body[$param.key] = $param.value
} }
} }
if ($PSBoundParameters.ContainsKey('vmName')) { if ($PSBoundParameters.ContainsKey('vmName')) {