Parce que la carte réseau non le projet Get-AzureRmVm
, nous ne pouvons pas utiliser Get-AzureRmVM | select-object NIC
pour obtenir le nom NIC:
PS D:\testdata> get-azurermvm | gm
TypeName: Microsoft.Azure.Commands.Compute.Models.PSVirtualMachineList
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToPSVirtualMachine Method Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine ToPSVirtualMachine()
ToString Method string ToString()
AvailabilitySetReference Property Microsoft.Azure.Management.Compute.Models.SubResource AvailabilitySetReference {...
DiagnosticsProfile Property Microsoft.Azure.Management.Compute.Models.DiagnosticsProfile DiagnosticsProfile ...
DisplayHint Property Microsoft.Azure.Commands.Compute.Models.DisplayHintType DisplayHint {get;set;}
Extensions Property System.Collections.Generic.IList[Microsoft.Azure.Management.Compute.Models.Virtu...
HardwareProfile Property Microsoft.Azure.Management.Compute.Models.HardwareProfile HardwareProfile {get;s...
Id Property string Id {get;set;}
Identity Property Microsoft.Azure.Management.Compute.Models.VirtualMachineIdentity Identity {get;s...
InstanceView Property Microsoft.Azure.Management.Compute.Models.VirtualMachineInstanceView InstanceVie...
LicenseType Property string LicenseType {get;set;}
Location Property string Location {get;set;}
Name Property string Name {get;set;}
NetworkProfile Property Microsoft.Azure.Management.Compute.Models.NetworkProfile NetworkProfile {get;set;}
OSProfile Property Microsoft.Azure.Management.Compute.Models.OSProfile OSProfile {get;set;}
Plan Property Microsoft.Azure.Management.Compute.Models.Plan Plan {get;set;}
ProvisioningState Property string ProvisioningState {get;set;}
RequestId Property string RequestId {get;set;}
ResourceGroupName Property string ResourceGroupName {get;}
StatusCode Property System.Net.HttpStatusCode StatusCode {get;set;}
StorageProfile Property Microsoft.Azure.Management.Compute.Models.StorageProfile StorageProfile {get;set;}
Tags Property System.Collections.Generic.IDictionary[string,string] Tags {get;set;}
Type Property string Type {get;set;}
VmId Property string VmId {get;set;}
Quelqu'un peut-il me guider sur la façon de filtrer les noms de carte réseau et les noms VM ?
Pour contourner ce problème, nous pouvons utiliser ce script pour obtenir le nom NIC:
$a = get-azurermvm -ResourceGroupName jasonvm -Name jasonvm
$b = $a.NetworkProfile.NetworkInterfaces.id -split "/"
$nic = $b[-1]
$nic
Ensuite, nous pouvons utiliser $nic
pour obtenir les informations sur la carte réseau, comme ceci:
Get-AzureRmNetworkInterface -Name $nic -ResourceGroupName jasonvm