protected void ExecuteVirtualMachineScaleSetVMGetInstanceViewMethod(object[] invokeMethodInputParameters) { string resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]); string vmScaleSetName = (string)ParseParameter(invokeMethodInputParameters[1]); string instanceId = (string)ParseParameter(invokeMethodInputParameters[2]); var result = VirtualMachineScaleSetVMsClient.GetInstanceView(resourceGroupName, vmScaleSetName, instanceId); WriteObject(result); }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); ExecuteClientAction(() => { string resourceGroupName = this.ResourceGroupName; string vmScaleSetName = this.VMScaleSetName; string instanceId = this.InstanceId; if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(vmScaleSetName) && !string.IsNullOrEmpty(instanceId)) { if (this.ParameterSetName.Equals("FriendMethod")) { var result = VirtualMachineScaleSetVMsClient.GetInstanceView(resourceGroupName, vmScaleSetName, instanceId); var psObject = new PSVirtualMachineScaleSetVMInstanceView(); ComputeAutomationAutoMapperProfile.Mapper.Map <VirtualMachineScaleSetVMInstanceView, PSVirtualMachineScaleSetVMInstanceView>(result, psObject); WriteObject(psObject); } else { var result = VirtualMachineScaleSetVMsClient.Get(resourceGroupName, vmScaleSetName, instanceId); var psObject = new PSVirtualMachineScaleSetVM(); ComputeAutomationAutoMapperProfile.Mapper.Map <VirtualMachineScaleSetVM, PSVirtualMachineScaleSetVM>(result, psObject); WriteObject(psObject); } } else if (!string.IsNullOrEmpty(resourceGroupName) && !string.IsNullOrEmpty(vmScaleSetName)) { var result = VirtualMachineScaleSetVMsClient.List(resourceGroupName, vmScaleSetName); var resultList = result.ToList(); var nextPageLink = result.NextPageLink; while (!string.IsNullOrEmpty(nextPageLink)) { var pageResult = VirtualMachineScaleSetVMsClient.ListNext(nextPageLink); foreach (var pageItem in pageResult) { resultList.Add(pageItem); } nextPageLink = pageResult.NextPageLink; } var psObject = new List <PSVirtualMachineScaleSetVMList>(); foreach (var r in resultList) { psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map <VirtualMachineScaleSetVM, PSVirtualMachineScaleSetVMList>(r)); } WriteObject(psObject, true); } }); }