Skip to content

Instantly share code, notes, and snippets.

@tckz
Created June 24, 2009 06:20
Show Gist options
  • Save tckz/135047 to your computer and use it in GitHub Desktop.
Save tckz/135047 to your computer and use it in GitHub Desktop.
ifdown/up for windows
$sh = New-Object -ComObject Shell.Application
$nc = $sh.NameSpace(3).Items() | ? { $_.Name -eq "ネットワーク接続" }
$lan = $nc.GetFolder.Items() | ? { $_.Name -eq "ローカル エリア接続" }
$disable = $lan.Verbs() | ? { $_.Name -eq "無効にする(&B)" }
if($disable)
{
write-host "disabling."
$disable.DoIt()
}
# disable後少し待たないとメソッドが現れない
$enable = $null
while($enable -eq $null)
{
write-host "Waiting to be available."
$enable = $lan.Verbs() | ? { $_.Name -eq "有効にする(&A)" }
}
$enable.DoIt()
sleep 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment