查看powershell源代码
reference
- 魔法accelerateViewing PowerShell Function Contents | PDQ.com
- Types - PowerShell | Microsoft Docs
- powershell - Pass function as a parameter - Stack Overflow
通用方案
function showSrcCode
{
param(
[parameter(Mandatory = $true)]
# [scriptblock] $command
$command
)
Get-Command $command | Select-Object -ExpandProperty ScriptBlock
}
调用示例
PS C:\Users\cxxu> showSrcCode -command newjunction
param(
$Path,
$Target
)
sudo New-Item -Verbose -ItemType junction -Path $Path -Target $Target
对于某个函数
$function:<functionName>
$function: 调用示例
PS C:\Users\cxxu> $Function:newJunction
param(
$Path,
$Target
)
sudo New-Item -Verbose -ItemType junction -Path $Path -Target $Target
环境变量
$env:<environmentName>
别名
$alias:<AliasName>