English 中文(简体)
PowerShell -as Family of Paracals
原标题:PowerShell -as Family of Parameters

我怎么能够找到或列举强食——作为参数的家庭?

So far I found -as Type e.g. -as[Int] Also I have found -asHashTable

我的问题是其他的——因为有参数?

最佳回答

如果有人在其中作出任何努力,这种解决办法可能更可取:

PS Home:> gcm | where { $_.CommandType -eq  Cmdlet  } | foreach { $_ | Add-Member -PassThru NoteProperty AsParameters ($_.Parameters.GetEnumerator() | ? {$_.Key -cmatch  ^As([A-Z]|$) } | % { $_.Key }) } | where { $_.AsParameters } | select Name,AsParameters

Name                   AsParameters
----                   ------------
ConvertTo-Html         As
ConvertTo-SecureString AsPlainText
ConvertTo-Xml          As
Export-Alias           As
Get-EventLog           {AsBaseObject, AsString}
Get-Unique             AsString
Get-WmiObject          AsJob
Group-Object           {AsHashTable, AsString}
Import-Module          AsCustomObject
Invoke-Command         AsJob
Invoke-WmiMethod       AsJob
New-Module             AsCustomObject
Read-Host              AsSecureString
Remove-WmiObject       AsJob
Restart-Computer       AsJob
Set-WmiInstance        AsJob
Stop-Computer          AsJob
Test-Connection        AsJob

《刑法》规定:

# find all commands
Get-Command |
  # that are cmdlets (exclude aliases or functions)
  Where-Object { $_.CommandType -eq  Cmdlet  } |
  ForEach-Object {
    # Add another property that contains all parameters
    # that starts with  As  – I use a regex here to exclude
    # parameters like -Assembly
    $_ | Add-Member -PassThru NoteProperty AsParameters (
      $_.Parameters.GetEnumerator() |
        Where-Object { $_.Key -cmatch  ^As([A-Z]|$)  } |
        ForEach-Object { $_.Key }
    )
  } |
  # Exclude commands that don t have parameters that start with  As 
  Where-Object { $_.AsParameters } |
  Select-Object Name,AsParameters
问题回答

暂无回答




相关问题
Mutually exclusive powershell parameters

SCENARIO I m writing a cmdlet for Powershell 2.0 using Visual Studio 2008 and .NET 3.5 the cmdlet requires 3 arguments. my intended grammar of the cmdlet is something like this: cmdletname [foo|...

Elegant way building url request with parameters

There must me a more elegant way to build a URL with parameters in .NET then for example Response.Write("<a href=HeadOfMarketView.aspx"+Session["HOM"] != null ? Session["HOM"]+">Head of Market&...

Can you pass by reference in Java?

Sorry if this sounds like a newbie question, but the other day a Java developer mentioned about passing a paramter by reference (by which it was ment just pass a Reference object) From a C# ...

How to name a method that has an out parameter?

What is the common preference to name a method that has an out parameter inside? Usually I use Get as a prefix to mention that the method returns a value (like GetMyBusiness). But what if there is ...

How to create program startup parameters in python

I m just beginning to learn python and the program I m writing requires parameters for it to run with a specific task. For example (programs name is Samtho) samtho -i Mozilla_Firefox How can I do ...

Weird behaviour of h:commandLink action (MethodExpression)

I have two JSPs where I am displaying some info from database in a h:dataTable. One of them is showing all the info, and one of them user specifically. I have showXML.jsp that shows the "XML" column ...

using parameter in SQL with LIKE keyword

from my C#-programm, I access a SQL Server 2008 Database. I have a table with a fulltextindex and want to search for an indexed entry: SELECT page_id FROM page_categories WHERE page_title LIKE @title ...

采用网路服务方法

我撰写了一个网络服务,期望一个参数(所谓的“hlink”)成为一种ur。 在使用网络服务之前,URLEncode 所涉参数(“hlink”)。 然后我打电话......。

热门标签