我该如何在 PowerShell 中执行此操作。在批处理文件中我会这样做: %~d0%~p0
For PowerShell 3.0用户 - 以下适用于模块和脚本文件:
PowerShell 3.0
function Get-ScriptDirectory { Split-Path -parent $PSCommandPath }