将powershell cmdlet导出为可执行文件

时间:2014-09-30 01:07:41

标签: windows powershell exe cmdlets

Windows power shell cmd是否可以作为单独的文件存储在计算机上。

如果是,那么这些文件的扩展名是什么。

如果没有办法将它们导出为单个文件? 这将是有用的说如果我只需要几个cmdlet我可以将它们作为单个文件并通过键入文件名来调用它们。

3 个答案:

答案 0 :(得分:1)

无法将Cmdlet导出为可执行命令并移至其他系统。它们需要PowerShell引擎才能运行并且不是独立的。

答案 1 :(得分:0)

Cmdlet驻留在这些DLL中,因此没有exe,我不相信可以将单个Cmdlet导出到另一个系统。

  

PS > (Get-Command Write-Host).DLL
  C:\windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Utility\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Commands.Utility.dll

     

PS > (Get-Command Get-ChildItem).DLL
  C:\windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Management\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Commands.Management.dll

答案 2 :(得分:0)

您可以使用proxy command并将此cmdlet导出为函数