我有一个简单的Powershell脚本来检查网络上计算机上BitLocker驱动器加密的状态。我希望脚本在文本文件中确定多台计算机的状态。
这是我到目前为止的基本脚本:
$GetID = Read-Host "What is the Device ID?"
$ComputerID = manage-bde -status -cn "$GetID"
foreach ($Computer in $ComputerID) {
Write-Host("$Computer")
}
这样做是提示技术人员输入主机名并给出结果。如何让脚本提示技术人员输入文本文件的路径,然后让脚本提供该文本文件的结果列表?
$TextFilePath = Read-Host "What is the path to the text file?"
If (Test-Path $TextFilePath){
$ComputersArray = Get-Content $TextFilePath
ForEach ($Computer in $ComputersArray) {
If (Test-Connection $Computer -Count 1){
$ComputerStatus = manage-bde -status -cn "$Computer"
Write-Host($ComputerStatus)
} Else {
Write-Host("$Computer appears to be offline.")
}
}
} Else {
Write-Error "The text file was not found, check the path."
}