diff --git a/Tests/Public/Set-ZertoLicense.Tests.ps1 b/Tests/Public/Set-ZertoLicense.Tests.ps1 new file mode 100644 index 0000000..fbdb17a --- /dev/null +++ b/Tests/Public/Set-ZertoLicense.Tests.ps1 @@ -0,0 +1,22 @@ +$moduleFileName = "ZertoApiWrapper.psm1" +$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper' +$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.' +$modulePath = $filePath -replace "Public", "" +Import-Module $modulePath\$moduleFileName -Force + +$userName = "zerto\build" +$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force +$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password) + +# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml +$zertoServer = "192.168.1.100" +$zertoPort = "7669" + +Describe "Set-ZertoLicense" { + it "file should exist" { + "$filePath\$fileName" | should exist + } + it "module should have a function called Set-ZertoAlert" { + get-command Set-ZertoLicense | should be $true + } +} \ No newline at end of file diff --git a/ZertoApiWrapper/Public/Set-ZertoLicense.ps1 b/ZertoApiWrapper/Public/Set-ZertoLicense.ps1 new file mode 100644 index 0000000..6307840 --- /dev/null +++ b/ZertoApiWrapper/Public/Set-ZertoLicense.ps1 @@ -0,0 +1,25 @@ +function Set-ZertoLicense { + [cmdletbinding( SupportsShouldProcess = $true )] + param ( + [Parameter( + Mandatory = $true, + HelpMessage = "License Key to apply to the Zerto Virtual Manager" + )] + [string]$licenseKey + ) + + begin { + $baseUri = "license" + $body = @{"LicenseKey" = $licenseKey} + } + + process { + if ($PSCmdlet.ShouldProcess()) { + Invoke-ZertoRestRequest -uri $baseUri -body $($body | ConvertTo-Json) -method "PUT" + } + } + + end { + # Nothing to do + } +} \ No newline at end of file