programing

지정된 cmdlet에 대한 모듈을 어떻게 찾습니까?

oldcodes 2023. 9. 11. 22:12
반응형

지정된 cmdlet에 대한 모듈을 어떻게 찾습니까?

cmdlet을 재정의하는 함수에서 직접 호출할 특정 cmdlet에 대한 모듈은 어떻게 결정합니까?

예를 들어 시작 스크립트가 Microsoft에 존재하는지 어떻게 알 수 있습니까?파워셸.호스트?

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]}

사용하다

Get-Command Start-Transcript | fl *

명령어에 대한 정보를 찾습니다.

PowerShell에는 몇 가지 옵션이 있습니다.검색하려는 특정 정보로 결과를 좁히기 위해 다음 방법 중 하나를 사용할 수 있습니다.

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

아니면

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

아니면

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

참고:

일반적으로 PowerShell 스크립트 내에서 사용하거나 사용자 지정 PowerShell 모듈을 개발할 때 별칭(fl, ft, select 등) 대신 전체 cmdlet 이름을 사용하는 것이 좋습니다.코드 가독성을 높여줍니다.

언급URL : https://stackoverflow.com/questions/10854746/how-do-i-find-the-module-for-a-given-cmdlet

반응형