【发布时间】:2012-07-31 00:59:30
【问题描述】:
我正在为 PowerShell 创建一个 cmdlet,我需要能够从 cmdlet 中调用Set-Location(又名cd)。我会这样做
var setLocation = new Microsoft.PowerShell.Commands.SetLocationCommand();
setLocation.Path = path;
setLocation.Invoke();
除了它给了我一个错误,上面写着You cannot invoke a cmdlet that derrives from PSCmdlet。我想使用 Set-Location,但我很乐意只更改 shell 的目录。
【问题讨论】:
标签: c# powershell cmdlets