diff --git a/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 new file mode 100644 index 0000000..f3e54ec --- /dev/null +++ b/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 @@ -0,0 +1,36 @@ +function Import-ZertoVpg { + [cmdletbinding()] + param( + [Parameter( + HelpMessage = "VPG settings JSON file(s) to import.", + Mandatory = $true, + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true + )] + [Alias("FullName")] + [string[]]$settingsFile + ) + + begin { + $baseUri = "vpgSettings" + } + + process { + foreach ($file in $settingsFile) { + $importedSettings = Get-Content -Path $file -Raw | ConvertFrom-Json + $vpgSettingsIdentifier = New-ZertoVpgSettingsIdentifier -newVpg + $importedSettings.VpgIdentifier = $null + $importedSettings.VpgSettingsIdentifier = $vpgSettingsIdentifier + $uri = "{0}/{1}" -f $baseUri, $vpgSettingsIdentifier + Invoke-ZertoRestRequest -uri $uri -method "PUT" -body $($importedSettings | convertto-json -Depth 10) + $vpgSettingsIdentifier | Save-ZertoVpgSettings + if ($settingsFile.Count -gt 1) { + Start-Sleep 5 + } + } + } + + end { + + } +}