日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

PowerShell2.0之Windows排错(一)启动故障排错

發布時間:2025/6/15 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PowerShell2.0之Windows排错(一)启动故障排错 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

如果Windows Vista和Windows Server 2008無法正常啟動,則可以檢查引導配置文件是否出現錯誤;另外可以檢查啟動服務及其依存性。Windows中的一些服務依賴于其他服務、系統驅動程序和組件的加載順序。如果系統組件被停止或運行不正常,則依賴于它的服務會受到影響。

(1)檢查引導配置文件

檢查運行Windows Vista和Windows Server 2008的計算機引導配置文件通常可以為用戶解決引導有關的問題,提供很多有價值的信息。類似引導分區、引導目錄,以及Windows目錄等信息往往都對排除故障很有用,大多數情況下通過VBS腳本獲取這些信息需要花費很多時間。

創建名為“DisplayBootConfig.ps1”腳本讀取引導配置,其代碼如下:

param($computer="localhost", [switch]$help)

function funHelp()

{

$helpText=@"

DESCRIPTION:

NAME: DisplayBootConfig.ps1

Displays a boot up configuration of a Windows system

PARAMETERS:

-computer The name of the computer

-help prints help file

SYNTAX:

DisplayBootConfig.ps1 -computer WebServer

Displays boot up configuration of a computer named WebServer

DisplayBootConfig.ps1

Displays boot up configuration on local computer

DisplayBootConfig.ps1 -help

Displays the help topic for the script

"@

$helpText

exit

}

if($help){ "Obtaining help ..." ; funhelp }

$wmi = Get-WmiObject -Class win32_BootConfiguration `

-computername $computer

format-list -InputObject $wmi [a-z]*

該腳本使用param語句定義了$computer和$help變量,前者的默認值為localhost。設置-help參數為switch,即在使用該參數時不需要提供額外信息,并且使用Get-WmiObject cmdlet從Win32_BootConfiguration WMI類中獲取信息。如果需要,可以將$computer變量中的值提供給-computername參數。這樣可以通過Get-WmiObject cmdlet連接到遠程計算機,最終將返回的management對象傳遞給Format-List cmdlet。使用范圍運算符(range operator)[a-z]*選擇字符開頭的屬性,以過濾報告中的所有系統屬性(因為系統屬性均以下畫線開頭)。

該腳本的執行結果如圖1所示。

圖1 獲取Windows引導配置信息

(2)檢查啟動進程

在Windows Vista和Windows Server 2008系統中有部分程序伴隨系統啟動,它們以不同啟動組的形式存在。很多惡意軟件和病毒以這種形式啟動,當操作系統啟動出現問題時需要檢查這些啟動組。

創建名為“DetectStartupPrograms.ps1”的腳本顯示本地或遠程計算機的自動運行程序的狀態,并查看基本或完整的程序信息,其代碼如下:

param($computer="localhost", [switch]$full, [switch]$help)

function funHelp()

{

$helpText=@"

DESCRIPTION:

NAME: DetectStartUpPrograms.ps1

Displays a listing of programs that automatically start

PARAMETERS:

-computer the name of the computer

-full prints detailed information

-help prints help file

SYNTAX:

DetectStartUpPrograms.ps1 -computer WebServer -full

Displays name, command, location, and user information

about programs that automatically start on a computer named WebServer

DetectStartUpPrograms.ps1 -full

Displays name, command, location, and user information

about programs that automatically start on the local computer

DetectStartUpPrograms.ps1 -computer WebServer

Displays a listing of programs that automatically start on a computer named WebServer

DetectStartUpPrograms.ps1 -help ?

Displays the help topic for the script

"@

$helpText

exit

}

if($help){ "Obtaining help ..." ; funhelp }

if($full)

{ $property = "name", "command", "location", "user" }

else

{ $property = "name" }

Get-WmiObject -Class win32_startupcommand -computername $computer |

Sort-Object -property name |

format-list -property $property

該腳本中使用param語句定義了$computer、$full和$help變量,分別用于指定腳本作用的計算機及幫助信息。隨后定義了兩個switch參數,其中-full用于輸出完整的啟動程序信息;-help用于輸出幫助信息。

如果在腳本運行時提供了-full參數,則輸出程序的名稱、可執行文件、路徑及用戶名等信息;否則僅顯示名稱。腳本中通過調用Get-WmiObject cmdlet獲得所有的自動運行程序,將結果對象用管道發送給Sort-Object cmdlet,同時分類屬性名稱。最后使用Format-List cmdlet選擇由$property變量指定的屬性輸出,該腳本的執行結果如圖2所示。

圖2 執行結果

?

作者: 付海軍
出處:http://fuhj02.cnblogs.com
版權:本文版權歸作者和博客園共有
轉載:歡迎轉載,為了保存作者的創作熱情,請按要求【轉載】,謝謝
要求:未經作者同意,必須保留此段聲明;必須在文章中給出原文連接;否則必究法律責任
個人網站: http://txj.lzuer.com/

轉載于:https://www.cnblogs.com/fuhj02/archive/2011/01/16/1937007.html

總結

以上是生活随笔為你收集整理的PowerShell2.0之Windows排错(一)启动故障排错的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。