2017-11-13 5 views
0

私はPowerShellのトラブルシューティングスキルを構築しようとしていますが、私は同様のツールをbashのtypeに見つけることを望んでいました。 typePowershellの `type -a`に相当します

使用例:

17:07 Mac Shell: Git/>$ type -a shell_session_save 
shell_session_save is a function 
shell_session_save() 
{ 
    if [ -n "$SHELL_SESSION_FILE" ]; then 
     echo -n 'Saving session...'; 
     (umask 077; 
     echo 'echo Restored session: "$(date -r '$(date +%s)')"' >|"$SHELL_SESSION_FILE"); 
     declare -F shell_session_save_user_state > /dev/null && shell_session_save_user_state; 
     shell_session_history_allowed && shell_session_save_history; 
     echo 'completed.'; 
    fi 
} 
17:07 Mac Shell: Git/>$ 

私はただのPowerShellのCLI関数のコードを表示する簡単な方法をしたいです。これはネイティブに可能ですか?

ありがとうございました。

+0

あなたは「の出力内容を意味しますか関数'?これが意味するところは、 'Get-Content Function:\ functionname'です。 –

答えて

1

それはのようなGet-Commandを使用してネイティブに提供されています:

Get-Command MyFunctionName -ShowCommandInfo 

は、ここで私はGet-OutputFilePathという名前の手元に保つ私の関数のいずれかの出力です:

Name   : Get-OutputFilePath 
ModuleName : 
Module  : @{Name=} 
CommandType : Function 
Definition : 
       [CmdletBinding()] 
       Param(
        [String]$Filter = "All Files (*.*)|*.*", 
        [String]$InitialDirectory, 
        [Parameter(ValueFromPipelineByPropertyName,ValueFromPipeline)] 
        [Alias('DefaultFileName')] 
        [String]$FullName, 
        [Switch]$Force) 
        BEGIN{ 
         [void][System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") 
        } 
        PROCESS{ 
         If($FullName -match "\\.+$" -and !$InitialDirectory){$InitialDirectory = Split-Path $FullName;$FullName = Split-Path $FullName -Leaf}ElseIf(!$InitialDirectory){$InitialDirectory=[Environment]::GetFolderPath('Desktop')} 
         $SaveFileDialog = New-Object System.Windows.Forms.SaveFileDialog 
         $SaveFileDialog.initialDirectory = $InitialDirectory 
         Try{$SaveFileDialog.filter = $Filter}Catch{Throw $_;Break} 
         $SaveFileDialog.FileName = $FullName 
         $SaveFileDialog.OverwritePrompt = !$Force 
         If($SaveFileDialog.ShowDialog() -eq "OK"){$SaveFileDialog.FileName} 
        } 

ParameterSets : {@{Name=__AllParameterSets; IsDefault=False; Parameters=System.Management.Automation.PSObject[]}} 
関連する問題