如何確定給定cmdlet的模塊,以便從覆蓋該cmdlet的函數直接調用該模塊。如何找到給定cmdlet的模塊?
例如,我該如何發現Start-Transcript存在於Microsoft.Powershell.Host中?
get-module Start-Transcript
不會產生任何
更新下面的答案。 這是輸出:
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]}
有一個ModuleName屬性不會顯示在get-command的默認表中。 (查找ModuleName:Microsoft.PowerShell.Host) – user1324792
這會更好:get-command -type cmdlet start-transcript |選擇ModuleName – user1324792
更簡潔的版本:'(Get-Command Start-Transcript).ModuleName' –