gpt4 book ai didi

powershell - set-AzureStaticVNetIP 未在 Azure VM 上设置静态 IP

转载 作者:行者123 更新时间:2023-12-03 06:02:33 26 4
gpt4 key购买 nike

我尝试使用以下脚本设置虚拟机的 IP。但是它返回了这个我无法解决的神秘错误。

$cloudSvcName = "My-SPService";
Test-AzureStaticVNetIP –VNetName My-SPNetwork –IPAddress 10.0.0.4
$dns = Get-AzureVM -Name "My-DNS" -ServiceName $cloudSvcName ;
stop-AzureVM -Name $dns.Name -ServiceName $cloudSvcName -Force;
set-AzureStaticVNetIP -VM $dns -IPAddress 10.0.0.4 | update-AzureVM;

这是错误:

[ERROR] update-AzureVM : BadRequest: The value for parameter 'SubnetNames' is null or empty.
[ERROR] At C:\Users\Tim\Source\Repos\Powershell Azure\AzurePowerShell\ScratchPad.ps1:12 char:104
[ERROR] + ... ess 10.0.0.4 | update-AzureVM -ServiceName $cloudSvcName;
[ERROR] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ERROR] + CategoryInfo : CloseError: (:) [Update-AzureVM], CloudException
[ERROR] + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.UpdateAzureVMCommand

最佳答案

这有效吗?

$sub = "PubSubnet";  #Set to whatever subnet you have set up

$cloudSvcName = "My-SPService";
Test-AzureStaticVNetIP –VNetName My-SPNetwork –IPAddress 10.0.0.4
$dns = Get-AzureVM -Name "My-DNS" -ServiceName $cloudSvcName ;
stop-AzureVM -Name $dns.Name -ServiceName $cloudSvcName -Force;

$dns | Set-AzureSubnet –SubnetNames $sub | set-AzureStaticVNetIP -IPAddress 10.0.0.4 | update-AzureVM;

关于powershell - set-AzureStaticVNetIP 未在 Azure VM 上设置静态 IP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24152219/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com