views:

204

answers:

1

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!

+2  A: 

Unfortunately at this time, there aren't any native powershell cmdlets that provide similar functinality 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 funtion 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

Function Get-NetShIPInterface {
netsh int ip show int
}
$interface = Get-NetshIPinterface
$interface | select-string "Local Area Connection"

Eventually we will get networking cmdlets, but for now, netsh can get the job done.

Andy Schneider