PowerShell 2 中是否有 cmdlet 可以处理 ipsec 更改?
我正在使用 System.Management.Automation 构建一个本质上充当防火墙的程序,我想知道 PowerShell 2 中是否有特定的 cmdlet 来处理服务器的 ipsec 更改? (即,重复 netsh ipsec 功能)?
或者我必须写一篇? :P
我希望有一个比在 PowerShell 代码中调用 [diagnostics.process] 来处理 netsh 查询更干净的解决方案,并且认为 cmdlet 会更好。
有人有任何提示或技巧吗?或者我应该开始深入研究“编写 Windows PowerShell cmdlet”文档:
http://msdn.microsoft.com/en-us/library/dd878294%28VS.85%29.aspx
感谢您的任何想法!
I am using System.Management.Automation to build a program that serves as a firewall, essentially, and I was wondering if there is a specific cmdlet in PowerShell 2 to handle ipsec changes for a server? (i.e., that duplicates netsh ipsec functionality)?
Or would I have to write one? :P
I am hoping for a cleaner solution than calling a [diagnostics.process] within the PowerShell code to handle the netsh queries, and figured a cmdlet would be better.
Anyone have any tips or tricks? Or should I just start digging through the 'Writing a Windows PowerShell cmdlet' documentation at:
http://msdn.microsoft.com/en-us/library/dd878294%28VS.85%29.aspx
Thanks for any ideas!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,目前还没有任何本机 powershell cmdlet 可以提供与 netsh 类似的功能。
话虽这么说,您不必启动新进程即可在 PowerShell 函数中运行 netsh 命令。您可以在 PS 函数或内联脚本中运行通常在 CMD 中运行的任何 exe,就像运行 cmdlet 一样。您可以将输出保存到变量并使用 select-string 或 -match 运算符处理文本。
举个例子,
最终我们将获得网络 cmdlet,但现在,netsh 可以完成这项工作。
Unfortunately at this time, there aren't any native powershell cmdlets that provide similar functionality to netsh.
That being said, You wouldn't have to fire up a new process to run netsh commands in a PowerShell function. You can run any exe you normally run in CMD in a PS function or script inline just as you would a cmdlet. You can save the output to a variable and process the text with select-string or the -match operator.
Just as an example
Eventually we will get networking cmdlets, but for now, netsh can get the job done.