private void Run()
        {
            // EncryptionSettingsCollection
            if (this.Disk.EncryptionSettingsCollection == null)
            {
                this.Disk.EncryptionSettingsCollection = new EncryptionSettingsCollection();
            }

            // EncryptionSettings
            if (this.Disk.EncryptionSettingsCollection.EncryptionSettings == null)
            {
                this.Disk.EncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
            }

            if (this.Disk.EncryptionSettingsCollection.EncryptionSettings.Count == 0)
            {
                var vEncryptionSettings = new EncryptionSettingsElement();
                this.Disk.EncryptionSettingsCollection.EncryptionSettings.Add(vEncryptionSettings);
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("SecretUrl"))
            {
                // DiskEncryptionKey
                if (this.Disk.EncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey == null)
                {
                    this.Disk.EncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey = new KeyVaultAndSecretReference();
                }
                this.Disk.EncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey.SecretUrl = this.SecretUrl;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("SourceVaultId"))
            {
                // DiskEncryptionKey
                if (this.Disk.EncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey == null)
                {
                    this.Disk.EncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey = new KeyVaultAndSecretReference();
                }
                // SourceVault
                if (this.Disk.EncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey.SourceVault == null)
                {
                    this.Disk.EncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey.SourceVault = new SourceVault();
                }
                this.Disk.EncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey.SourceVault.Id = this.SourceVaultId;
            }

            WriteObject(this.Disk);
        }
        private void Run()
        {
            // EncryptionSettingsCollection
            if (this.DiskUpdate.EncryptionSettingsCollection == null)
            {
                this.DiskUpdate.EncryptionSettingsCollection = new EncryptionSettingsCollection();
            }

            // EncryptionSettings
            if (this.DiskUpdate.EncryptionSettingsCollection.EncryptionSettings == null)
            {
                this.DiskUpdate.EncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
            }

            if (this.DiskUpdate.EncryptionSettingsCollection.EncryptionSettings.Count == 0)
            {
                var vEncryptionSettings = new EncryptionSettingsElement();
                this.DiskUpdate.EncryptionSettingsCollection.EncryptionSettings.Add(vEncryptionSettings);
            }

            if (this.IsParameterBound(c => c.KeyUrl))
            {
                // KeyEncryptionKey
                if (this.DiskUpdate.EncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey == null)
                {
                    this.DiskUpdate.EncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey = new KeyVaultAndKeyReference();
                }
                this.DiskUpdate.EncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey.KeyUrl = this.KeyUrl;
            }

            if (this.IsParameterBound(c => c.SourceVaultId))
            {
                // KeyEncryptionKey
                if (this.DiskUpdate.EncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey == null)
                {
                    this.DiskUpdate.EncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey = new KeyVaultAndKeyReference();
                }
                // SourceVault
                if (this.DiskUpdate.EncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey.SourceVault == null)
                {
                    this.DiskUpdate.EncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey.SourceVault = new SourceVault();
                }
                this.DiskUpdate.EncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey.SourceVault.Id = this.SourceVaultId;
            }

            WriteObject(this.DiskUpdate);
        }
示例#3
0
        private void Run()
        {
            // EncryptionSettingsCollection
            EncryptionSettingsCollection vEncryptionSettingsCollection = null;

            // EncryptionSettingsCollection
            EncryptionSettingsElement vEncryptionSettingsElement = null;

            // Sku
            DiskSku vSku = null;

            if (this.MyInvocation.BoundParameters.ContainsKey("EncryptionSettingsEnabled"))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }
                vEncryptionSettingsCollection.Enabled = (bool)this.EncryptionSettingsEnabled;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("DiskEncryptionKey"))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsElement == null)
                {
                    vEncryptionSettingsElement = new EncryptionSettingsElement();
                    vEncryptionSettingsCollection.EncryptionSettings.Add(vEncryptionSettingsElement);
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("KeyEncryptionKey"))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsElement == null)
                {
                    vEncryptionSettingsElement = new EncryptionSettingsElement();
                    vEncryptionSettingsCollection.EncryptionSettings.Add(vEncryptionSettingsElement);
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey = this.KeyEncryptionKey;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("SkuName"))
            {
                if (vSku == null)
                {
                    vSku = new DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            var vDiskUpdate = new PSDiskUpdate
            {
                OsType            = this.MyInvocation.BoundParameters.ContainsKey("OsType") ? this.OsType : (OperatingSystemTypes?)null,
                DiskSizeGB        = this.MyInvocation.BoundParameters.ContainsKey("DiskSizeGB") ? this.DiskSizeGB : (int?)null,
                DiskIOPSReadWrite = this.MyInvocation.BoundParameters.ContainsKey("DiskIOPSReadWrite") ? this.DiskIOPSReadWrite : (int?)null,
                DiskMBpsReadWrite = this.MyInvocation.BoundParameters.ContainsKey("DiskMBpsReadWrite") ? this.DiskMBpsReadWrite : (int?)null,
                Tags = this.MyInvocation.BoundParameters.ContainsKey("Tag") ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                EncryptionSettingsCollection = vEncryptionSettingsCollection,
                Sku = vSku,
            };

            WriteObject(vDiskUpdate);
        }
        private void Run()
        {
            // EncryptionSettingsCollection
            EncryptionSettingsCollection vEncryptionSettingsCollection = null;

            // EncryptionSettingsCollection
            EncryptionSettingsElement vEncryptionSettingsElement = null;

            // Encryption
            Encryption vEncryption = null;

            // Sku
            DiskSku vSku = null;

            // SupportedCapabilities
            SupportedCapabilities vSupportedCapabilities = null;

            if (this.IsParameterBound(c => c.EncryptionSettingsEnabled))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }
                vEncryptionSettingsCollection.Enabled = (bool)this.EncryptionSettingsEnabled;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsElement == null)
                {
                    vEncryptionSettingsElement = new EncryptionSettingsElement();
                    vEncryptionSettingsCollection.EncryptionSettings.Add(vEncryptionSettingsElement);
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.IsParameterBound(c => c.KeyEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsElement == null)
                {
                    vEncryptionSettingsElement = new EncryptionSettingsElement();
                    vEncryptionSettingsCollection.EncryptionSettings.Add(vEncryptionSettingsElement);
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey = this.KeyEncryptionKey;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionSetId))
            {
                if (vEncryption == null)
                {
                    vEncryption = new Encryption();
                }
                vEncryption.DiskEncryptionSetId = this.DiskEncryptionSetId;
            }

            if (this.IsParameterBound(c => c.EncryptionType))
            {
                if (vEncryption == null)
                {
                    vEncryption = new Encryption();
                }
                vEncryption.Type = this.EncryptionType;
            }

            if (this.IsParameterBound(c => c.SkuName))
            {
                if (vSku == null)
                {
                    vSku = new DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            if (this.IsParameterBound(c => c.AcceleratedNetwork))
            {
                if (vSupportedCapabilities == null)
                {
                    vSupportedCapabilities = new SupportedCapabilities();
                }
                vSupportedCapabilities.AcceleratedNetwork = AcceleratedNetwork;
            }

            if (this.IsParameterBound(c => c.Architecture))
            {
                if (vSupportedCapabilities == null)
                {
                    vSupportedCapabilities = new SupportedCapabilities();
                }
                vSupportedCapabilities.Architecture = this.Architecture;
            }

            var vDiskUpdate = new PSDiskUpdate
            {
                OsType            = this.IsParameterBound(c => c.OsType) ? this.OsType : (OperatingSystemTypes?)null,
                DiskSizeGB        = this.IsParameterBound(c => c.DiskSizeGB) ? this.DiskSizeGB : (int?)null,
                DiskIOPSReadWrite = this.IsParameterBound(c => c.DiskIOPSReadWrite) ? this.DiskIOPSReadWrite : (int?)null,
                DiskMBpsReadWrite = this.IsParameterBound(c => c.DiskMBpsReadWrite) ? this.DiskMBpsReadWrite : (int?)null,
                DiskIOPSReadOnly  = this.IsParameterBound(c => c.DiskIOPSReadOnly) ? this.DiskIOPSReadOnly : null,
                DiskMBpsReadOnly  = this.IsParameterBound(c => c.DiskMBpsReadOnly) ? this.DiskMBpsReadOnly : null,
                MaxShares         = this.IsParameterBound(c => c.MaxSharesCount) ? this.MaxSharesCount : null,
                Tags = this.IsParameterBound(c => c.Tag) ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                NetworkAccessPolicy          = this.IsParameterBound(c => c.NetworkAccessPolicy) ? this.NetworkAccessPolicy: null,
                DiskAccessId                 = this.IsParameterBound(c => c.DiskAccessId) ? this.DiskAccessId: null,
                EncryptionSettingsCollection = vEncryptionSettingsCollection,
                Encryption            = vEncryption,
                Sku                   = vSku,
                Tier                  = this.IsParameterBound(c => c.Tier) ? this.Tier : null,
                BurstingEnabled       = this.IsParameterBound(c => c.BurstingEnabled) ? this.BurstingEnabled : null,
                PurchasePlan          = this.IsParameterBound(c => c.PurchasePlan) ? this.PurchasePlan : null,
                SupportsHibernation   = this.IsParameterBound(c => c.SupportsHibernation) ? SupportsHibernation : null,
                SupportedCapabilities = vSupportedCapabilities,
                PublicNetworkAccess   = this.IsParameterBound(c => c.PublicNetworkAccess) ? PublicNetworkAccess : null,
                DataAccessAuthMode    = this.IsParameterBound(c => c.DataAccessAuthMode) ? DataAccessAuthMode : null
            };

            WriteObject(vDiskUpdate);
        }
示例#5
0
        private void Run()
        {
            // EncryptionSettingsCollection
            EncryptionSettingsCollection vEncryptionSettingsCollection = null;

            // EncryptionSettingsCollection
            EncryptionSettingsElement vEncryptionSettingsElement = null;

            // Encryption
            Encryption vEncryption = null;

            // Sku
            DiskSku vSku = null;

            if (this.IsParameterBound(c => c.EncryptionSettingsEnabled))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }
                vEncryptionSettingsCollection.Enabled = (bool)this.EncryptionSettingsEnabled;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsElement == null)
                {
                    vEncryptionSettingsElement = new EncryptionSettingsElement();
                    vEncryptionSettingsCollection.EncryptionSettings.Add(vEncryptionSettingsElement);
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.IsParameterBound(c => c.KeyEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsElement == null)
                {
                    vEncryptionSettingsElement = new EncryptionSettingsElement();
                    vEncryptionSettingsCollection.EncryptionSettings.Add(vEncryptionSettingsElement);
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey = this.KeyEncryptionKey;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionSetId))
            {
                if (vEncryption == null)
                {
                    vEncryption = new Encryption();
                }
                vEncryption.DiskEncryptionSetId = this.DiskEncryptionSetId;
            }

            if (this.IsParameterBound(c => c.EncryptionType))
            {
                if (vEncryption == null)
                {
                    vEncryption = new Encryption();
                }
                vEncryption.Type = this.EncryptionType;
            }

            if (this.IsParameterBound(c => c.SkuName))
            {
                if (vSku == null)
                {
                    vSku = new DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            var vDiskUpdate = new PSDiskUpdate
            {
                OsType            = this.IsParameterBound(c => c.OsType) ? this.OsType : (OperatingSystemTypes?)null,
                DiskSizeGB        = this.IsParameterBound(c => c.DiskSizeGB) ? this.DiskSizeGB : (int?)null,
                DiskIOPSReadWrite = this.IsParameterBound(c => c.DiskIOPSReadWrite) ? this.DiskIOPSReadWrite : (int?)null,
                DiskMBpsReadWrite = this.IsParameterBound(c => c.DiskMBpsReadWrite) ? this.DiskMBpsReadWrite : (int?)null,
                DiskIOPSReadOnly  = this.IsParameterBound(c => c.DiskIOPSReadOnly) ? this.DiskIOPSReadOnly : null,
                DiskMBpsReadOnly  = this.IsParameterBound(c => c.DiskMBpsReadOnly) ? this.DiskMBpsReadOnly : null,
                MaxShares         = this.IsParameterBound(c => c.MaxSharesCount) ? this.MaxSharesCount : null,
                Tags = this.IsParameterBound(c => c.Tag) ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                NetworkAccessPolicy          = this.IsParameterBound(c => c.NetworkAccessPolicy) ? this.NetworkAccessPolicy: null,
                DiskAccessId                 = this.IsParameterBound(c => c.DiskAccessId) ? this.DiskAccessId: null,
                EncryptionSettingsCollection = vEncryptionSettingsCollection,
                Encryption = vEncryption,
                Sku        = vSku,
                Tier       = this.IsParameterBound(c => c.Tier) ? this.Tier : null,
            };

            WriteObject(vDiskUpdate);
        }