日本好好热aⅴ|国产99视频精品免费观看|日本成人aV在线|久热香蕉国产在线

  • <cite id="ikgdy"><table id="ikgdy"></table></cite>
    1. 西西軟件園多重安全檢測下載網(wǎng)站、值得信賴的軟件下載站!
      軟件
      軟件
      文章
      搜索

      首頁西西教程操作系統(tǒng) → 使用PowerShell2.0管理網(wǎng)絡(luò)、查看網(wǎng)絡(luò)設(shè)置

      使用PowerShell2.0管理網(wǎng)絡(luò)、查看網(wǎng)絡(luò)設(shè)置

      相關(guān)軟件相關(guān)文章發(fā)表評論 來源:本站整理時間:2011/1/23 9:10:41字體大。A-A+

      作者:佚名點(diǎn)擊:169次評論:0次標(biāo)簽: PowerShell

      • 類型:編程輔助大。1.7M語言:中文 評分:10.0
      • 標(biāo)簽:
      立即下載

      本文將會介紹如何使用PowerShell管理網(wǎng)絡(luò),包括設(shè)置和TCP/IP堆棧有關(guān)的選項(xiàng);通過不同腳本提供網(wǎng)絡(luò)適配器的狀態(tài)信息,網(wǎng)絡(luò)適配器的連接狀態(tài)及屬性;設(shè)置靜態(tài)IP、啟動DHCP及配置DNS服務(wù)器;獲取防火墻設(shè)置信息并設(shè)置有關(guān)選項(xiàng)以啟用遠(yuǎn)程管理,以及遠(yuǎn)程共享文件等。

      Windows Vista開始在網(wǎng)絡(luò)功能方面有了很大改善,包括新的防火墻服務(wù)及IPv6協(xié)議的增強(qiáng)支持等。同時從Windows Vista開始WMI中增加了很多用于操作防火墻和IPv6的新特性和計數(shù)器,可以顯示和使用IPv6地址。

      Windows Vista和Windows Server 2008中包括強(qiáng)大的網(wǎng)絡(luò)功能,允許用戶以簡單且便捷的方式操作網(wǎng)絡(luò)。但是給網(wǎng)絡(luò)管理員帶來大量麻煩,如管理大量網(wǎng)絡(luò)適配器,如圖1所示。

      圖1 需要管理大量網(wǎng)絡(luò)適配器

      為了有效地管理網(wǎng)絡(luò)設(shè)備,創(chuàng)建名為“GetNetAdapterStatus.ps1”的腳本用于檢測網(wǎng)絡(luò)適配器的狀態(tài),其代碼如下:

      param($computer="localhost",$help)

      function funStatus($status)

      {

      switch($status)

      {

      0 { " Disconnected" }

      1 { " Connecting" }

      2 { " Connected" }

      3 { " Disconnecting" }

      4 { " Hardware not present" }

      5 { " Hardware disabled" }

      6 { " Hardware malfunction" }

      7 { " Media disconnected" }

      8 { " Authenticating" }

      9 { " Authentication succeeded" }

      10 { " Authentication failed" }

      }

      }

      function funHelp()

      {

      $helpText=@"

      DESCRIPTION:

      NAME: GetNetAdapterStatus.ps1

      Produces a listing of network adapters and status on a local or remote machine.

      PARAMETERS:

      -computerName Specifies the name of the computer upon which to run the script

      -help prints help file

      SYNTAX:

      GetNetAdapterStatus.ps1 -computer WebServer

      Lists all the network adapters and status on a computer named WebServer

      GetNetAdapterStatus.ps1

      Lists all the network adapters and status on local computer

      GetNetAdapterStatus.ps1 -help ?

      Displays the help topic for the script

      "@

      $helpText

      exit

      }

      function funline ($strIN)

      {

      $num = $strIN.length

      for($i=1 ; $i -le $num ; $i++)

      { $funline = $funline + "=" }

      Write-Host -ForegroundColor yellow $strIN

      Write-Host -ForegroundColor darkYellow $funline

      }

      if($help) { "Printing help now..." ; funHelp }

      $objWMI=Get-WmiObject -Class win32_networkadapter -computer $computer

      funline("Network adapters and status on $computer")

      foreach($net in $objWMI)

      {

      Write-Host "$($net.name)"

      funstatus($net.netconnectionstatus)

      }

      為了獲取網(wǎng)絡(luò)適配器的狀態(tài),在該腳本中使用Win32_NetWorkAdapter WMI類返回狀態(tài)代碼。并創(chuàng)建了一個名為“funStatus”的函數(shù),通過switch語句的代碼塊包括Win32_NetWorkAdapterWMI類定義的所有可能的狀態(tài)代碼。狀態(tài)代碼及其含義在Windows軟件開發(fā)包(SDK)中有詳細(xì)介紹,說明如下。

      Ø 0:Disconnected(斷開)。

      Ø 1:Connecting(連接中)。

      Ø 2:Connected(已連接)。

      Ø 3:Disconnecting(斷開中)。

      Ø 4:Hardware not present(硬件不存在)。

      Ø 5:Hardware disabled(硬件已禁用)。

      Ø 6:Hardware malfunction(硬件故障)。

      Ø 7:Media disconnected(媒介斷開)。

      Ø 8:Authenticating(權(quán)限認(rèn)證中)。

      Ø 9:Authentication succeeded(權(quán)限認(rèn)證成功)。

      Ø 10:Authentication failed(權(quán)限認(rèn)證失。

      在該腳本中通過funStatus函數(shù)將狀態(tài)值轉(zhuǎn)換為便于理解的內(nèi)容,其執(zhí)行結(jié)果如圖2所示。



      作者: 付海軍
      出處:http://fuhj02.cnblogs.com
      版權(quán):本文版權(quán)歸作者和博客園共有
      轉(zhuǎn)載:歡迎轉(zhuǎn)載,為了保存作者的創(chuàng)作熱情,請按要求【轉(zhuǎn)載】,謝謝

        相關(guān)評論

        閱讀本文后您有什么感想? 已有人給出評價!

        • 8 喜歡喜歡
        • 3 頂
        • 1 難過難過
        • 5 囧
        • 3 圍觀圍觀
        • 2 無聊無聊

        熱門評論

        最新評論

        發(fā)表評論 查看所有評論(0)

        昵稱:
        表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
        字?jǐn)?shù): 0/500 (您的評論需要經(jīng)過審核才能顯示)