protected override void ProcessRecord() { try { Func<OSImage, OSImageContext> func = null; base.ProcessRecord(); Operation operation = null; IEnumerable<OSImage> vMImageProcess = this.GetVMImageProcess(out operation); if (vMImageProcess != null) { IEnumerable<OSImage> oSImages = vMImageProcess; if (func == null) { func = (OSImage d) => { OSImageContext oSImageContext = new OSImageContext(); oSImageContext.set_OperationId(operation.OperationTrackingId); oSImageContext.set_OperationDescription(this.CommandRuntime.ToString()); oSImageContext.set_OperationStatus(operation.Status); oSImageContext.AffinityGroup = d.AffinityGroup; oSImageContext.Category = d.Category; oSImageContext.Label = d.Label; oSImageContext.Location = d.Location; oSImageContext.MediaLink = d.MediaLink; oSImageContext.ImageName = d.Name; oSImageContext.OS = d.OS; oSImageContext.LogicalSizeInGB = d.LogicalSizeInGB; return oSImageContext; } ; } IEnumerable<OSImageContext> oSImageContexts = oSImages.Select<OSImage, OSImageContext>(func); base.WriteObject(oSImageContexts, true); } } catch (Exception exception1) { Exception exception = exception1; base.WriteError(new ErrorRecord(exception, string.Empty, ErrorCategory.CloseError, null)); } }