public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            var parameters = new VirtualMachineExtensionImageGetParameters
            {
                Location = Location.Canonicalize(),
                PublisherName = PublisherName,
                Type = Type,
                FilterExpression = FilterExpression,
                Version = Version
            };

            VirtualMachineExtensionImageGetResponse result = this.VirtualMachineExtensionImageClient.Get(parameters);

            var image = new PSVirtualMachineExtensionImageDetails
            {
                RequestId = result.RequestId,
                StatusCode = result.StatusCode,
                Id = result.VirtualMachineExtensionImage.Id,
                Location = result.VirtualMachineExtensionImage.Location,
                Name = result.VirtualMachineExtensionImage.Name,
                HandlerSchema = result.VirtualMachineExtensionImage.HandlerSchema,
                OperatingSystem = result.VirtualMachineExtensionImage.OperatingSystem,
                ComputeRole = result.VirtualMachineExtensionImage.ComputeRole,
                SupportsMultipleExtensions = result.VirtualMachineExtensionImage.SupportsMultipleExtensions,
                VMScaleSetEnabled = result.VirtualMachineExtensionImage.VMScaleSetEnabled,
                PublisherName = this.PublisherName,
                Type = this.Type,
                Version = this.Version
            };

            WriteObject(image);
        }
 /// <summary>
 /// Gets a virtual machine extension image.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.Compute.IVirtualMachineExtensionImageOperations.
 /// </param>
 /// <param name='parameters'>
 /// Optional.
 /// </param>
 /// <returns>
 /// The get virtual machine extension image operation response.
 /// </returns>
 public static VirtualMachineExtensionImageGetResponse Get(this IVirtualMachineExtensionImageOperations operations, VirtualMachineExtensionImageGetParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IVirtualMachineExtensionImageOperations)s).GetAsync(parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// Gets a virtual machine extension image.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.Compute.IVirtualMachineExtensionImageOperations.
 /// </param>
 /// <param name='parameters'>
 /// Optional.
 /// </param>
 /// <returns>
 /// The get virtual machine extension image operation response.
 /// </returns>
 public static Task<VirtualMachineExtensionImageGetResponse> GetAsync(this IVirtualMachineExtensionImageOperations operations, VirtualMachineExtensionImageGetParameters parameters)
 {
     return operations.GetAsync(parameters, CancellationToken.None);
 }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            ExecuteClientAction(() =>
            {
                if (string.IsNullOrEmpty(this.Version))
                {
                    var parameters = new VirtualMachineExtensionImageListVersionsParameters
                    {
                        Location = Location.Canonicalize(),
                        PublisherName = PublisherName,
                        Type = Type,
                        FilterExpression = FilterExpression
                    };

                    VirtualMachineImageResourceList result = this.VirtualMachineExtensionImageClient.ListVersions(parameters);

                    var images = from r in result.Resources
                                 select new PSVirtualMachineExtensionImage
                                 {
                                     RequestId = result.RequestId,
                                     StatusCode = result.StatusCode,
                                     Id = r.Id,
                                     Location = r.Location,
                                     Version = r.Name,
                                     PublisherName = this.PublisherName,
                                     Type = this.Type,
                                     FilterExpression = this.FilterExpression
                                 };

                    WriteObject(images, true);
                }
                else
                {

                    var parameters = new VirtualMachineExtensionImageGetParameters
                    {
                        Location = Location.Canonicalize(),
                        PublisherName = PublisherName,
                        Type = Type,
                        FilterExpression = FilterExpression,
                        Version = Version
                    };

                    VirtualMachineExtensionImageGetResponse result = this.VirtualMachineExtensionImageClient.Get(parameters);

                    var image = new PSVirtualMachineExtensionImageDetails
                    {
                        RequestId = result.RequestId,
                        StatusCode = result.StatusCode,
                        Id = result.VirtualMachineExtensionImage.Id,
                        Location = result.VirtualMachineExtensionImage.Location,
                        HandlerSchema = result.VirtualMachineExtensionImage.HandlerSchema,
                        OperatingSystem = result.VirtualMachineExtensionImage.OperatingSystem,
                        ComputeRole = result.VirtualMachineExtensionImage.ComputeRole,
                        SupportsMultipleExtensions = result.VirtualMachineExtensionImage.SupportsMultipleExtensions,
                        VMScaleSetEnabled = result.VirtualMachineExtensionImage.VMScaleSetEnabled,
                        Version = result.VirtualMachineExtensionImage.Name,
                        PublisherName = this.PublisherName,
                        Type = this.Type,
                        FilterExpression = this.FilterExpression
                    };

                    WriteObject(image);
                }
            });
        }