Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Simple question: Can I avoid using NETSH in Windows Server 2008 R2 and instead use PowerShell CmdLets to manipulate things like HTTP?

If so, what are some CmdLets to get me started and are they part of some extra module?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

There's a NetAdapter module in Powershell 3.0 which appears to cover the functionality of netsh, however the module only ships with Windows 8 or Windows Server 2012, so you're still stuck with netsh or CIM/WMI on Windows Server 2008 R2.

Although unrelated to netsh question, version 3 added an invoke-webrequest cmdlet which is includes in 2008 R2 and Windows 7.

share|improve this answer
    
Chad, this is close to an answer as I think it gets today and led me to the documentation about the whole arsenal of PowerShell CmdLets in Server 2012. technet.microsoft.com/en-us/library/hh801904.aspx –  Luke Puplett Nov 28 '12 at 14:11
add comment

powershell is running on top of .NET so you should be able to do whatever you want with http for example here is a simple RSS function :

function RSS{
    Param ($Rssurl='http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&output=rss')
    $proxy = New-Object System.Net.WebProxy("http://10.10.18.18:8080")
    $Webclient = new-object net.webclient 
    $Webclient.proxy=$proxy
    $Webclient.UseDefaultCredentials = $True
    $rss = [xml]$Webclient.DownloadString($Rssurl)
    $rss.rss.channel.item | ForEach {
    New-Object PSObject -Property @{
        Title = $_.Title
        PublicationDate = (Get-Date $_.PubDate)
        Link = $_.Link
    }
}

here is an other example in pure PS to change the network card settings :

$card=Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled=true"
if($profile -eq 'dhcp' ){
    $card.EnableDhcp()
    write-host OK -ForegroundColor 'green'
    exit
}
# manual IP settings :
$card.EnableStatic($address,'255.255.255.0')
$card.SetGateways($gw)
$card.SetDNSServerSearchOrder(@($dns,'10.24.1.8'))
share|improve this answer
    
Although useful, and I'll +1, I will keep the question open to see if anyone knows of some simple 'purpose built' CmdLets that are intentionally designed to replace NETSH as the way to fiddle with things like HTTP.sys port registrations. –  Luke Puplett Nov 28 '12 at 12:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.