From 73d7eaa99256fdb84cf9e4db0029413a0c79375e Mon Sep 17 00:00:00 2001 From: Wouter Kursten Date: Tue, 22 May 2018 19:22:02 +0200 Subject: [PATCH] added function to create vmware.hv.securestring password --- Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 b/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 index a0bfb26..faecc37 100644 --- a/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 +++ b/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 @@ -106,6 +106,23 @@ function Get-JsonObject { } } +function new-hvpassword{ +#Requires input of type securestring and replies with vmware.hv.securestring + param( + [string]$pwin + ) + + $temppw = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pwin) + $PlainPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($temppw) + $plainpassword + $SecPassword = New-Object VMware.Hv.SecureString + $enc = [system.Text.Encoding]::UTF8 + $SecPassword.Utf8String = $enc.GetBytes($PlainPassword) + return $SecPassword + +} + + function Get-MapEntry { param( [Parameter(Mandatory = $true)]