2012-06-01 9 views
15

Come determinare il modulo per un determinato cmdlet per la chiamata diretta da una funzione che esegue l'override del cmdlet.Come trovo il modulo per un dato cmdlet?

Ad esempio, come dovrei scoprire che Start-Transcript vive in Microsoft.Powershell.Host?

get-module Start-Transcript 

non cedere nulla

Aggiornamento per risposta qui sotto. Questa è l'uscita:

PS C:\Windows> get-command -type cmdlet start-transcript | fl * 


HelpUri    : http://go.microsoft.com/fwlink/?LinkID=113408 
DLL     : C:\Windows\assembly\GAC_MSIL\Microsoft.PowerShell.ConsoleHost\1.0.0.0__31bf3856ad364e35\Microsoft 
         .PowerShell.ConsoleHost.dll 
Verb    : Start 
Noun    : Transcript 
HelpFile   : Microsoft.PowerShell.ConsoleHost.dll-Help.xml 
PSSnapIn   : Microsoft.PowerShell.Host 
ImplementingType : Microsoft.PowerShell.Commands.StartTranscriptCommand 
Definition   : Start-Transcript [[-Path] <String>] [-Append] [-Force] [-NoClobber] [-Verbose] [-Debug] [-ErrorAc 
         tion <ActionPreference>] [-WarningAction <ActionPreference>] [-ErrorVariable <String>] [-WarningV 
         ariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>] [-WhatIf] [-Confirm] 

DefaultParameterSet : 
OutputType   : {} 
Name    : Start-Transcript 
CommandType   : Cmdlet 
Visibility   : Public 
ModuleName   : Microsoft.PowerShell.Host <------------ HERE IT IS 
Module    : 
Parameters   : {[Path, System.Management.Automation.ParameterMetadata], [Append, System.Management.Automation.Pa 
         rameterMetadata], [Force, System.Management.Automation.ParameterMetadata], [NoClobber, System.Man 
         agement.Automation.ParameterMetadata]...} 
ParameterSets  : {[[-Path] <String>] [-Append] [-Force] [-NoClobber] [-Verbose] [-Debug] [-ErrorAction <ActionPref 
         erence>] [-WarningAction <ActionPreference>] [-ErrorVariable <String>] [-WarningVariable <String> 
         ] [-OutVariable <String>] [-OutBuffer <Int32>] [-WhatIf] [-Confirm]} 

risposta

8

Usa

get-command start-transcript | fl *

per trovare informazioni sul comando.

+0

C'è una proprietà ModuleName che non viene visualizzata nella tabella predefinita di get-command. (Cerca ModuleName: Microsoft.PowerShell.Host) – user1324792

+1

Funziona meglio: get-command -type cmdlet start-transcript | selezionare ModuleName – user1324792

+5

Una versione più succinta: '(Get-Command Start-Transcript) .ModuleName' –

2

Ci sono alcune opzioni in PowerShell. Al fine di risultato stretto per una specifica informazione che stai cercando - uno dei seguenti metodi possono essere usati:

(Get-Command -Name Start-Transcript).ModuleName 

o

Get-Command -Name Start-Transcript | Select-Object -Property ModuleName 

o

Get-Command -Name Start-Transcript | Format-List -Property ModuleName 

Nota:

Generalmente è consigliabile utilizzare un nome completo cmdlet instabile di alias (come fl, ft, select et c.) ogni volta che lo si utilizza nello script PowerShell o si sviluppa un modulo PowerShell personalizzato. Aumenta la leggibilità del codice.

Problemi correlati