Ejemplo n.º 1
0
            protected override void ProcessRecord()
            {
                var apiCopy = Api.Copy();

                apiCopy.QueryParams = QueryParams;

                if (ParameterSetName.StartsWith("named"))
                {
                    apiCopy.Endpoint = new string[] { "cards", "named" };
                }
                else if (ParameterSetName.StartsWith("search"))
                {
                    apiCopy.Endpoint = new string[] { "cards", "search" };
                }
                else
                {
                    throw new InvalidOperationException($"I dunno what this wacko parameter set is!!!! {ParameterSetName}");
                }

                this.InvokeRestCommand(
                    apiCopy.Uri,
                    WebRequestMethod.Get,
                    null,
                    null
                    );
            }
Ejemplo n.º 2
0
 /// <summary>
 /// Parse the input of the cmdlet depending on the parameter set provided.
 /// </summary>
 protected override void ParseInput()
 {
     // Recover the resource group name and the sql virtual machine name if the resource id was provided
     if (ParameterSetName.StartsWith(ParameterSet.ResourceId))
     {
         Name = GetResourceNameFromId(ResourceId);
         ResourceGroupName = GetResourceGroupNameFromId(ResourceId);
     }
 }
Ejemplo n.º 3
0
        protected override void ProcessItem(Item item)
        {
            var accessRights = item.Security.GetAccessRules().ToList();

            if (ParameterSetName.StartsWith("Account ID"))
            {
                accessRights.Where(ar => ar.Account.Name.Equals(Identity.Name)).ForEach(WriteObject);
            }
            else if (ParameterSetName.StartsWith("Account Filter"))
            {
                WildcardWrite(Filter, accessRights, ar => ar.Account.Name);
            }
            else
            {
                WriteObject(accessRights, true);
            }
        }
Ejemplo n.º 4
0
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName.StartsWith(ResourceIdParameterSetPrefix))
            {
                var resourceId = new ResourceId(ResourceId);

                ResourceGroupName = resourceId.ResourceGroupName;
                Name = resourceId.ResourceName;
            }

            if (ParameterSetName.StartsWith(PipelineParameterSetPrefix))
            {
                ResourceGroupName = InputObject.ResourceGroupName;
                Name = InputObject.Name;
            }

            var serial = default(int?);
            var key    = default(string);

            if (Primary.IsPresent)
            {
                serial = 1;
                key    = "primary";
            }
            else if (Secondary.IsPresent)
            {
                serial = 2;
                key    = "secondary";
            }

            ConfirmAction(
                Force,
                $"Are you sure you want to regenerate {key} key of Remote Rendering Account '{Name}' in resource group '{ResourceGroupName}' ?",
                this.MyInvocation.InvocationName,
                Name,
                () =>
            {
                var result = Client.RemoteRenderingAccounts.RegenerateKeys(ResourceGroupName, Name, serial);

                WriteObject(result);
            });
        }
Ejemplo n.º 5
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ExecuteClientAction(() =>
            {
                if (ParameterSetName.StartsWith("InvokeByDynamicParameters"))
                {
                    argumentList = ConvertDynamicParameters(dynamicParameters);
                }
                else
                {
                    argumentList = ConvertFromArgumentsToObjects((object[])dynamicParameters["ArgumentList"].Value);
                }

                switch (MethodName)
                {
                case "AvailabilitySetCreateOrUpdate":
                    ExecuteAvailabilitySetCreateOrUpdateMethod(argumentList);
                    break;

                case "AvailabilitySetDelete":
                    ExecuteAvailabilitySetDeleteMethod(argumentList);
                    break;

                case "AvailabilitySetGet":
                    ExecuteAvailabilitySetGetMethod(argumentList);
                    break;

                case "AvailabilitySetList":
                    ExecuteAvailabilitySetListMethod(argumentList);
                    break;

                case "AvailabilitySetListAvailableSizes":
                    ExecuteAvailabilitySetListAvailableSizesMethod(argumentList);
                    break;

                case "ContainerServiceCreateOrUpdate":
                    ExecuteContainerServiceCreateOrUpdateMethod(argumentList);
                    break;

                case "ContainerServiceDelete":
                    ExecuteContainerServiceDeleteMethod(argumentList);
                    break;

                case "ContainerServiceGet":
                    ExecuteContainerServiceGetMethod(argumentList);
                    break;

                case "ContainerServiceList":
                    ExecuteContainerServiceListMethod(argumentList);
                    break;

                case "ContainerServiceListByResourceGroup":
                    ExecuteContainerServiceListByResourceGroupMethod(argumentList);
                    break;

                case "ContainerServiceListByResourceGroupNext":
                    ExecuteContainerServiceListByResourceGroupNextMethod(argumentList);
                    break;

                case "ContainerServiceListNext":
                    ExecuteContainerServiceListNextMethod(argumentList);
                    break;

                case "DiskCreateOrUpdate":
                    ExecuteDiskCreateOrUpdateMethod(argumentList);
                    break;

                case "DiskDelete":
                    ExecuteDiskDeleteMethod(argumentList);
                    break;

                case "DiskGet":
                    ExecuteDiskGetMethod(argumentList);
                    break;

                case "DiskGrantAccess":
                    ExecuteDiskGrantAccessMethod(argumentList);
                    break;

                case "DiskList":
                    ExecuteDiskListMethod(argumentList);
                    break;

                case "DiskListByResourceGroup":
                    ExecuteDiskListByResourceGroupMethod(argumentList);
                    break;

                case "DiskListByResourceGroupNext":
                    ExecuteDiskListByResourceGroupNextMethod(argumentList);
                    break;

                case "DiskListNext":
                    ExecuteDiskListNextMethod(argumentList);
                    break;

                case "DiskRevokeAccess":
                    ExecuteDiskRevokeAccessMethod(argumentList);
                    break;

                case "DiskUpdate":
                    ExecuteDiskUpdateMethod(argumentList);
                    break;

                case "ImageCreateOrUpdate":
                    ExecuteImageCreateOrUpdateMethod(argumentList);
                    break;

                case "ImageDelete":
                    ExecuteImageDeleteMethod(argumentList);
                    break;

                case "ImageGet":
                    ExecuteImageGetMethod(argumentList);
                    break;

                case "ImageList":
                    ExecuteImageListMethod(argumentList);
                    break;

                case "ImageListByResourceGroup":
                    ExecuteImageListByResourceGroupMethod(argumentList);
                    break;

                case "ImageListByResourceGroupNext":
                    ExecuteImageListByResourceGroupNextMethod(argumentList);
                    break;

                case "ImageListNext":
                    ExecuteImageListNextMethod(argumentList);
                    break;

                case "LogAnalyticExportRequestRateByInterval":
                    ExecuteLogAnalyticExportRequestRateByIntervalMethod(argumentList);
                    break;

                case "LogAnalyticExportThrottledRequests":
                    ExecuteLogAnalyticExportThrottledRequestsMethod(argumentList);
                    break;

                case "ResourceSkuList":
                    ExecuteResourceSkuListMethod(argumentList);
                    break;

                case "ResourceSkuListNext":
                    ExecuteResourceSkuListNextMethod(argumentList);
                    break;

                case "SnapshotCreateOrUpdate":
                    ExecuteSnapshotCreateOrUpdateMethod(argumentList);
                    break;

                case "SnapshotDelete":
                    ExecuteSnapshotDeleteMethod(argumentList);
                    break;

                case "SnapshotGet":
                    ExecuteSnapshotGetMethod(argumentList);
                    break;

                case "SnapshotGrantAccess":
                    ExecuteSnapshotGrantAccessMethod(argumentList);
                    break;

                case "SnapshotList":
                    ExecuteSnapshotListMethod(argumentList);
                    break;

                case "SnapshotListByResourceGroup":
                    ExecuteSnapshotListByResourceGroupMethod(argumentList);
                    break;

                case "SnapshotListByResourceGroupNext":
                    ExecuteSnapshotListByResourceGroupNextMethod(argumentList);
                    break;

                case "SnapshotListNext":
                    ExecuteSnapshotListNextMethod(argumentList);
                    break;

                case "SnapshotRevokeAccess":
                    ExecuteSnapshotRevokeAccessMethod(argumentList);
                    break;

                case "SnapshotUpdate":
                    ExecuteSnapshotUpdateMethod(argumentList);
                    break;

                case "VirtualMachineRunCommandGet":
                    ExecuteVirtualMachineRunCommandGetMethod(argumentList);
                    break;

                case "VirtualMachineRunCommandList":
                    ExecuteVirtualMachineRunCommandListMethod(argumentList);
                    break;

                case "VirtualMachineRunCommandListNext":
                    ExecuteVirtualMachineRunCommandListNextMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetRollingUpgradeCancel":
                    ExecuteVirtualMachineScaleSetRollingUpgradeCancelMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetRollingUpgradeGetLatest":
                    ExecuteVirtualMachineScaleSetRollingUpgradeGetLatestMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetRollingUpgradeStartOSUpgrade":
                    ExecuteVirtualMachineScaleSetRollingUpgradeStartOSUpgradeMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetCreateOrUpdate":
                    ExecuteVirtualMachineScaleSetCreateOrUpdateMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetDeallocate":
                    ExecuteVirtualMachineScaleSetDeallocateMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetDelete":
                    ExecuteVirtualMachineScaleSetDeleteMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetDeleteInstances":
                    ExecuteVirtualMachineScaleSetDeleteInstancesMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetForceRecoveryServiceFabricPlatformUpdateDomainWalk":
                    ExecuteVirtualMachineScaleSetForceRecoveryServiceFabricPlatformUpdateDomainWalkMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetGet":
                    ExecuteVirtualMachineScaleSetGetMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetGetInstanceView":
                    ExecuteVirtualMachineScaleSetGetInstanceViewMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetList":
                    ExecuteVirtualMachineScaleSetListMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetListAll":
                    ExecuteVirtualMachineScaleSetListAllMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetListAllNext":
                    ExecuteVirtualMachineScaleSetListAllNextMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetListNext":
                    ExecuteVirtualMachineScaleSetListNextMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetListSkus":
                    ExecuteVirtualMachineScaleSetListSkusMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetListSkusNext":
                    ExecuteVirtualMachineScaleSetListSkusNextMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetPowerOff":
                    ExecuteVirtualMachineScaleSetPowerOffMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetReimage":
                    ExecuteVirtualMachineScaleSetReimageMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetReimageAll":
                    ExecuteVirtualMachineScaleSetReimageAllMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetRestart":
                    ExecuteVirtualMachineScaleSetRestartMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetStart":
                    ExecuteVirtualMachineScaleSetStartMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetUpdate":
                    ExecuteVirtualMachineScaleSetUpdateMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetUpdateInstances":
                    ExecuteVirtualMachineScaleSetUpdateInstancesMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMDeallocate":
                    ExecuteVirtualMachineScaleSetVMDeallocateMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMDelete":
                    ExecuteVirtualMachineScaleSetVMDeleteMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMGet":
                    ExecuteVirtualMachineScaleSetVMGetMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMGetInstanceView":
                    ExecuteVirtualMachineScaleSetVMGetInstanceViewMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMList":
                    ExecuteVirtualMachineScaleSetVMListMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMListNext":
                    ExecuteVirtualMachineScaleSetVMListNextMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMPowerOff":
                    ExecuteVirtualMachineScaleSetVMPowerOffMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMReimage":
                    ExecuteVirtualMachineScaleSetVMReimageMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMReimageAll":
                    ExecuteVirtualMachineScaleSetVMReimageAllMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMRestart":
                    ExecuteVirtualMachineScaleSetVMRestartMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMStart":
                    ExecuteVirtualMachineScaleSetVMStartMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMUpdate":
                    ExecuteVirtualMachineScaleSetVMUpdateMethod(argumentList);
                    break;

                case "VirtualMachineCapture":
                    ExecuteVirtualMachineCaptureMethod(argumentList);
                    break;

                case "VirtualMachineConvertToManagedDisks":
                    ExecuteVirtualMachineConvertToManagedDisksMethod(argumentList);
                    break;

                case "VirtualMachineCreateOrUpdate":
                    ExecuteVirtualMachineCreateOrUpdateMethod(argumentList);
                    break;

                case "VirtualMachineDeallocate":
                    ExecuteVirtualMachineDeallocateMethod(argumentList);
                    break;

                case "VirtualMachineDelete":
                    ExecuteVirtualMachineDeleteMethod(argumentList);
                    break;

                case "VirtualMachineGeneralize":
                    ExecuteVirtualMachineGeneralizeMethod(argumentList);
                    break;

                case "VirtualMachineGet":
                    ExecuteVirtualMachineGetMethod(argumentList);
                    break;

                case "VirtualMachineInstanceView":
                    ExecuteVirtualMachineInstanceViewMethod(argumentList);
                    break;

                case "VirtualMachineList":
                    ExecuteVirtualMachineListMethod(argumentList);
                    break;

                case "VirtualMachineListAll":
                    ExecuteVirtualMachineListAllMethod(argumentList);
                    break;

                case "VirtualMachineListAllNext":
                    ExecuteVirtualMachineListAllNextMethod(argumentList);
                    break;

                case "VirtualMachineListAvailableSizes":
                    ExecuteVirtualMachineListAvailableSizesMethod(argumentList);
                    break;

                case "VirtualMachineListNext":
                    ExecuteVirtualMachineListNextMethod(argumentList);
                    break;

                case "VirtualMachinePerformMaintenance":
                    ExecuteVirtualMachinePerformMaintenanceMethod(argumentList);
                    break;

                case "VirtualMachinePowerOff":
                    ExecuteVirtualMachinePowerOffMethod(argumentList);
                    break;

                case "VirtualMachineRedeploy":
                    ExecuteVirtualMachineRedeployMethod(argumentList);
                    break;

                case "VirtualMachineRestart":
                    ExecuteVirtualMachineRestartMethod(argumentList);
                    break;

                case "VirtualMachineRunCommand":
                    ExecuteVirtualMachineRunCommandMethod(argumentList);
                    break;

                case "VirtualMachineStart":
                    ExecuteVirtualMachineStartMethod(argumentList);
                    break;

                default: WriteWarning("Cannot find the method by name = '" + MethodName + "'."); break;
                }
            });
        }
Ejemplo n.º 6
0
        protected override void ProcessRecord()
        {
            if (ParameterSetName.EndsWith("Simple"))
            {
                FileSystemSecurity2.ConvertToFileSystemFlags(appliesTo, out inheritanceFlags, out propagationFlags);
            }

            if (ParameterSetName.StartsWith("Path"))
            {
                foreach (var path in paths)
                {
                    FileSystemInfo item = null;

                    try
                    {
                        item = GetFileSystemInfo2(path);
                    }
                    catch (Exception ex)
                    {
                        WriteError(new ErrorRecord(ex, "ReadFileError", ErrorCategory.OpenError, path));
                    }

                    if (ParameterSetName == "PathSimple")
                    {
                        FileSystemSecurity2.ConvertToFileSystemFlags(appliesTo, out inheritanceFlags, out propagationFlags);
                    }

                    try
                    {
                        FileSystemAccessRule2.RemoveFileSystemAccessRule(item, account.ToList(), accessRights, accessType, inheritanceFlags, propagationFlags);
                    }
                    catch (UnauthorizedAccessException)
                    {
                        try
                        {
                            var ownerInfo     = FileSystemOwner.GetOwner(item);
                            var previousOwner = ownerInfo.Owner;

                            FileSystemOwner.SetOwner(item, System.Security.Principal.WindowsIdentity.GetCurrent().User);

                            FileSystemAccessRule2.RemoveFileSystemAccessRule(item, account.ToList(), accessRights, accessType, inheritanceFlags, propagationFlags);

                            FileSystemOwner.SetOwner(item, previousOwner);
                        }
                        catch (Exception ex2)
                        {
                            WriteError(new ErrorRecord(ex2, "RemoveAceError", ErrorCategory.WriteError, path));
                        }
                    }
                    catch (Exception ex)
                    {
                        WriteError(new ErrorRecord(ex, "RemoveAceError", ErrorCategory.WriteError, path));
                    }

                    if (passThru == true)
                    {
                        FileSystemAccessRule2.GetFileSystemAccessRules(item, true, true).ForEach(ace => WriteObject(ace));
                    }
                }
            }
            else
            {
                foreach (var sd in securityDescriptors)
                {
                    FileSystemAccessRule2.RemoveFileSystemAccessRule(sd, account.ToList(), accessRights, accessType, inheritanceFlags, propagationFlags);

                    if (passThru == true)
                    {
                        FileSystemAccessRule2.GetFileSystemAccessRules(sd, true, true).ForEach(ace => WriteObject(ace));
                    }
                }
            }
        }
Ejemplo n.º 7
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ExecuteClientAction(() =>
            {
                if (ParameterSetName.StartsWith("InvokeByDynamicParameters"))
                {
                    argumentList = ConvertDynamicParameters(dynamicParameters);
                }
                else
                {
                    argumentList = ConvertFromArgumentsToObjects((object[])dynamicParameters["ArgumentList"].Value);
                }

                switch (MethodName)
                {
                case "ContainerServiceCreateOrUpdate":
                    ExecuteContainerServiceCreateOrUpdateMethod(argumentList);
                    break;

                case "ContainerServiceDelete":
                    ExecuteContainerServiceDeleteMethod(argumentList);
                    break;

                case "ContainerServiceGet":
                    ExecuteContainerServiceGetMethod(argumentList);
                    break;

                case "ContainerServiceList":
                    ExecuteContainerServiceListMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetCreateOrUpdate":
                    ExecuteVirtualMachineScaleSetCreateOrUpdateMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetDeallocate":
                    ExecuteVirtualMachineScaleSetDeallocateMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetDelete":
                    ExecuteVirtualMachineScaleSetDeleteMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetDeleteInstances":
                    ExecuteVirtualMachineScaleSetDeleteInstancesMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetGet":
                    ExecuteVirtualMachineScaleSetGetMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetGetInstanceView":
                    ExecuteVirtualMachineScaleSetGetInstanceViewMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetList":
                    ExecuteVirtualMachineScaleSetListMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetListAll":
                    ExecuteVirtualMachineScaleSetListAllMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetListAllNext":
                    ExecuteVirtualMachineScaleSetListAllNextMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetListNext":
                    ExecuteVirtualMachineScaleSetListNextMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetListSkus":
                    ExecuteVirtualMachineScaleSetListSkusMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetListSkusNext":
                    ExecuteVirtualMachineScaleSetListSkusNextMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetPowerOff":
                    ExecuteVirtualMachineScaleSetPowerOffMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetReimage":
                    ExecuteVirtualMachineScaleSetReimageMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetRestart":
                    ExecuteVirtualMachineScaleSetRestartMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetStart":
                    ExecuteVirtualMachineScaleSetStartMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetUpdateInstances":
                    ExecuteVirtualMachineScaleSetUpdateInstancesMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMDeallocate":
                    ExecuteVirtualMachineScaleSetVMDeallocateMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMDelete":
                    ExecuteVirtualMachineScaleSetVMDeleteMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMGet":
                    ExecuteVirtualMachineScaleSetVMGetMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMGetInstanceView":
                    ExecuteVirtualMachineScaleSetVMGetInstanceViewMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMList":
                    ExecuteVirtualMachineScaleSetVMListMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMListNext":
                    ExecuteVirtualMachineScaleSetVMListNextMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMPowerOff":
                    ExecuteVirtualMachineScaleSetVMPowerOffMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMReimage":
                    ExecuteVirtualMachineScaleSetVMReimageMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMRestart":
                    ExecuteVirtualMachineScaleSetVMRestartMethod(argumentList);
                    break;

                case "VirtualMachineScaleSetVMStart":
                    ExecuteVirtualMachineScaleSetVMStartMethod(argumentList);
                    break;

                default: WriteWarning("Cannot find the method by name = '" + MethodName + "'."); break;
                }
            });
        }