大家好,
我创建了这个伟大的PowerShell脚本,使VM在AHV中。这是一段旅程,让我告诉你,但我做到了。我想添加的一件事是使用UEFI引导选项创建VM。我知道这需要在Creation时完成,我可以在ACLI中使用以下内容来创建它:
acli vm.create uefivm2 uefi_boot = true
然而;有没有办法使用PowerShell?我将考虑找到上面的SSH命令的方法
有什么方法可以使用PowerShell使用UEFI创建VM?
谢谢,
斯科特
最好的答案斯基特
add-type @\"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
\u00a0 \u00a0 public bool CheckValidationResult(
\u00a0 \u00a0 ServicePoint srvPoint, X509Certificate certificate,
\u00a0 \u00a0 WebRequest request, int certificateProblem) {
\u00a0 \u00a0 \u00a0 \u00a0 return true;
\u00a0 \u00a0 }
}
\"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$password = Read-Host -AsSecureString -Prompt \"Password\"
$NTNXCred = New-Object System.Management.Automation.PsCredential(\"Username\",$password)
$RESTAPIUser = $NTNXCred.UserName
$RESTAPIPassword = $NTNXCred.GetNetworkCredential().Password
$Header = @{
\"Authorization\" = \"Basic \"+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($RESTAPIUser+\":\"+$RESTAPIPassword ))}<\/p>
$Header.Add(\"content-type\", \"application\/json\")<\/p>
$response = Invoke-WebRequest -Uri 'https:\/\/CVMIP:9440\/PrismGateway\/services\/rest\/v2.0\/vms\/' -Method POST -Headers $Header -ContentType 'application\/json' -Body '{\"allow_live_migrate\":true,\"boot\":{\"secure_boot\":true,\"uefi_boot\":true},\"name\":\"UEFITest\",\"memory_mb\":2048,\"num_vcpus\":2}' -UseBasicParsing
\u00a0<\/p>","className":"post__content__best_answer"}">