pscmdlet

Detecting a PowerShell Switch

喜你入骨 提交于 2021-02-10 04:22:09
问题 I'm developing a PowerShell cmdlet in C#, and have true/false switch statements. I have noted that I need to specify -SwitchName $true, if I want the bool to be true, otherwise I get: Missing an argument for parameter 'SwitchName'. Specify a parameter of type 'System.Boolean' and try again. The switch is decorated as such: [Parameter(Mandatory = false, Position = 1, , ValueFromPipelineByPropertyName = true)] How can I just detect the presence of the switch (-SwitchName sets to true, absence

Clear-RecycleBin cmdlet's progress bar output is shown incorrectly

╄→尐↘猪︶ㄣ 提交于 2020-07-20 03:52:26
问题 Is the first time I'm using the Clear-RecycleBin cmdlet, and it seems obvious that this cmdlet paints a typical command-line progress bar that I think it should be filled with symbols or maybe color blocks from start to end, or maybe it should just print a percentage value in the middle of the bar, I don't know exactly because as I'm saying is the first time I'm using this cmdlet, however, seeying the image below its obvious the progress bar output is wrong. The proggress-bar is totally

Clear-RecycleBin cmdlet's progress bar output is shown incorrectly

偶尔善良 提交于 2020-07-20 03:52:19
问题 Is the first time I'm using the Clear-RecycleBin cmdlet, and it seems obvious that this cmdlet paints a typical command-line progress bar that I think it should be filled with symbols or maybe color blocks from start to end, or maybe it should just print a percentage value in the middle of the bar, I don't know exactly because as I'm saying is the first time I'm using this cmdlet, however, seeying the image below its obvious the progress bar output is wrong. The proggress-bar is totally

PSCmdlet dynamic auto complete a parameter (like Get-Process)

蓝咒 提交于 2019-12-22 12:33:30
问题 In powershell some parameter have a dynamic auto complete behavior. For Example, Get-Process the parameter Name. I can iterate trough all my processes with TAB. I want to use this behavior in my PSCmdlet. But the problem is, I only know how to do this with static auto complete valuee. See the example: public class TableDynamicParameters { [Parameter] [ValidateSet("Table1", "Table2")] public string[] Tables { get; set; } } Here an example how this is done with native powershell http://blogs

PSCmdlet dynamic auto complete a parameter (like Get-Process)

不想你离开。 提交于 2019-12-06 13:50:13
In powershell some parameter have a dynamic auto complete behavior. For Example, Get-Process the parameter Name. I can iterate trough all my processes with TAB. I want to use this behavior in my PSCmdlet. But the problem is, I only know how to do this with static auto complete valuee. See the example: public class TableDynamicParameters { [Parameter] [ValidateSet("Table1", "Table2")] public string[] Tables { get; set; } } Here an example how this is done with native powershell http://blogs.technet.com/b/heyscriptingguy/archive/2014/03/21/use-dynamic-parameters-to-populate-list-of-printer-names