protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            var imageType = new VirtualMachineImageHelper(this.ComputeClient).GetImageType(this.ImageName);
            bool isOSImage = imageType.HasFlag(VirtualMachineImageType.OSImage);
            bool isVMImage = imageType.HasFlag(VirtualMachineImageType.VMImage);

            if (isOSImage && isVMImage)
            {
                WriteErrorWithTimestamp(
                    string.Format(Resources.DuplicateNamesFoundInBothVMAndOSImages, this.ImageName));
            }
            else if (isOSImage)
            {
                var parameters = new VirtualMachineOSImageUpdateParameters
                {
                    Label             = this.Label,
                    Eula              = this.Eula,
                    Description       = this.Description,
                    ImageFamily       = this.ImageFamily,
                    PublishedDate     = this.PublishedDate,
                    PrivacyUri        = this.PrivacyUri,
                    RecommendedVMSize = this.RecommendedVMSize,
                    Language          = this.Language,
                    IconUri           = this.IconUri,
                    SmallIconUri      = this.SmallIconUri,
                    ShowInGui         = this.DontShowInGui.IsPresent ? (bool?)false : null
                };

                this.ExecuteClientActionNewSM(
                    null,
                    this.CommandRuntime.ToString(),
                    () => this.ComputeClient.VirtualMachineOSImages.Update(this.ImageName, parameters),
                    (s, response) => this.ContextFactory<VirtualMachineOSImageUpdateResponse, OSImageContext>(response, s));
            }
            else
            {
                var osDiskConfig    = DiskConfig == null ? null : DiskConfig.OSDiskConfiguration;
                var dataDiskConfigs = DiskConfig == null ? null : DiskConfig.DataDiskConfigurations.ToList();

                var parameters = new VirtualMachineVMImageUpdateParameters
                {
                    Label                  = this.Label,
                    Eula                   = this.Eula,
                    Description            = this.Description,
                    ImageFamily            = this.ImageFamily,
                    PublishedDate          = this.PublishedDate,
                    PrivacyUri             = this.PrivacyUri,
                    RecommendedVMSize      = this.RecommendedVMSize,
                    OSDiskConfiguration    = Mapper.Map<OSDiskConfigurationUpdateParameters>(osDiskConfig),
                    DataDiskConfigurations = dataDiskConfigs == null ? null : dataDiskConfigs.Select(d => new DataDiskConfigurationUpdateParameters
                    {
                        HostCaching       = d.HostCaching,
                        LogicalUnitNumber = d.Lun,
                        Name              = d.Name
                    }).ToList(),
                    Language               = this.Language,
                    IconUri                = this.IconUri,
                    SmallIconUri           = this.SmallIconUri,
                    ShowInGui              = this.DontShowInGui.IsPresent ? (bool?)false : null
                };

                this.ExecuteClientActionNewSM(
                    null,
                    this.CommandRuntime.ToString(),
                    () => this.ComputeClient.VirtualMachineVMImages.Update(this.ImageName, parameters));
            }
        }
 /// <summary>
 /// The Update VM Image operation updates a VM image that in your image
 /// repository.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Compute.IVirtualMachineVMImageOperations.
 /// </param>
 /// <param name='imageName'>
 /// Required. The name of the virtual machine image to be updated.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Update Virtual Machine Image
 /// operation.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static OperationResponse Update(this IVirtualMachineVMImageOperations operations, string imageName, VirtualMachineVMImageUpdateParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IVirtualMachineVMImageOperations)s).UpdateAsync(imageName, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// The Update VM Image operation updates a VM image that in your image
 /// repository.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Compute.IVirtualMachineVMImageOperations.
 /// </param>
 /// <param name='imageName'>
 /// Required. The name of the virtual machine image to be updated.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Update Virtual Machine Image
 /// operation.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static Task<OperationResponse> UpdateAsync(this IVirtualMachineVMImageOperations operations, string imageName, VirtualMachineVMImageUpdateParameters parameters)
 {
     return operations.UpdateAsync(imageName, parameters, CancellationToken.None);
 }
        protected PSArgument[] CreateVirtualMachineVMImageUpdateParameters()
        {
            string imageName = string.Empty;
            VirtualMachineVMImageUpdateParameters parameters = new VirtualMachineVMImageUpdateParameters();

            return ConvertFromObjectsToArguments(new string[] { "ImageName", "Parameters" }, new object[] { imageName, parameters });
        }