shell 往虚拟机中注入修改网卡ip 提示错误


PowerShell交流中心分类: 远程管理shell 往虚拟机中注入修改网卡ip 提示错误
0
zero. asked 6 年 ago

$vmName = “8030”
$Msvm_VirtualSystemManagementService = Get-WmiObject -Namespace root\virtualization\v2 `
-Class Msvm_VirtualSystemManagementService
$Msvm_ComputerSystem = Get-WmiObject -Namespace root\virtualization\v2 `
-Class Msvm_ComputerSystem -Filter “ElementName=’$vmName'”
$Msvm_VirtualSystemSettingData = ($Msvm_ComputerSystem.GetRelated(“Msvm_VirtualSystemSettingData”, `
“Msvm_SettingsDefineState”, $null, $null, “SettingData”, “ManagedElement”, $false, $null) | % {$_})
$Msvm_SyntheticEthernetPortSettingData = $Msvm_VirtualSystemSettingData.GetRelated(“Msvm_SyntheticEthernetPortSettingData”)
$Msvm_GuestNetworkAdapterConfiguration = ($Msvm_SyntheticEthernetPortSettingData.GetRelated( `
“Msvm_GuestNetworkAdapterConfiguration”, “Msvm_SettingDataComponent”, `
$null, $null, “PartComponent”, “GroupComponent”, $false, $null) | % {$_})
$Msvm_GuestNetworkAdapterConfiguration.DHCPEnabled = $false
$Msvm_GuestNetworkAdapterConfiguration.IPAddresses = @(“192.168.1.207”)
$Msvm_GuestNetworkAdapterConfiguration.Subnets = @(“255.255.255.0”)
$Msvm_GuestNetworkAdapterConfiguration.DefaultGateways = @(“192.168.1.1”)
$Msvm_GuestNetworkAdapterConfiguration.DNSServers = @(“192.168.1.10”, “192.168.1.11”)
$Msvm_VirtualSystemManagementService.SetGuestNetworkAdapterConfiguration( `
$Msvm_ComputerSystem.Path, $Msvm_GuestNetworkAdapterConfiguration.GetText(1))

=====================================================================
错误提示:
在此对象上找不到属性“DHCPEnabled”。请确认该属性存在并且可设置。
所在位置 C:\Users\Administrator\Desktop\关闭.ps1:18 字符: 1
+ $Msvm_GuestNetworkAdapterConfiguration.DHCPEnabled = $false
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [],RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException

在此对象上找不到属性“IPAddresses”。请确认该属性存在并且可设置。
所在位置 C:\Users\Administrator\Desktop\关闭.ps1:19 字符: 56
+ $Msvm_GuestNetworkAdapterConfiguration.IPAddresses = @(“192.168.1.207”)
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [],RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException

在此对象上找不到属性“Subnets”。请确认该属性存在并且可设置。
所在位置 C:\Users\Administrator\Desktop\关闭.ps1:20 字符: 52
+ $Msvm_GuestNetworkAdapterConfiguration.Subnets = @(“255.255.255.0”)
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [],RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException

在此对象上找不到属性“DefaultGateways”。请确认该属性存在并且可设置。
所在位置 C:\Users\Administrator\Desktop\关闭.ps1:21 字符: 60
+ $Msvm_GuestNetworkAdapterConfiguration.DefaultGateways = @(“192.168.1.1”)
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [],RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException

在此对象上找不到属性“DNSServers”。请确认该属性存在并且可设置。
所在位置 C:\Users\Administrator\Desktop\关闭.ps1:22 字符: 55
+ $Msvm_GuestNetworkAdapterConfiguration.DNSServers = @(“192.168.1.10”, “192.168.1 …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [],RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException

__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
Job : \\WIN-3GADJK2O\root\virtualization\v2:Msvm_ConcreteJob.InstanceID=”391AE919-DC68-42CF-A864-839
3E744B1B5″
ReturnValue : 4096
PSComputerName :