檢查運行Windows Vista和區域網路聊天的電腦引導設定檔通常可以為使用者解決引導有關的問題,提供很多有價值的資訊。類似引導分區、引導目錄,以及Windows目錄等資訊往往都對排除故障很有用,大多數情況下通過VBS指令碼擷取這些資訊需要花費很多時間。
區域網路聊天-www.freeeim.com
如果Windows Vista和Windows Server 2008無法正常啟動,則可以檢查引導設定檔是否出現錯誤;另外可以檢查啟動服務及其依存性。Windows中的一些服務依賴於其他服務、系統驅動程式和組件的載入順序。如果系統組件被停止或運行不正常,則依賴於它的服務會受到影響。
建立名為“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所示。
Read more: PowerShell2.0之Windows排錯(一)啟動故障排錯 - 天行健@中國元素 - 部落格園 http://www.cnblogs.com/fuhj02/archive/2011/01/16/1937007.html#ixzz1BDVc3100