Reputation: 197
I have a simple Powershell script to check the status of BitLocker drive encryption on a computer on the network. I'd like for the script to determine the status of multiple computers in a text file.
Here's my basic script so far:
$GetID = Read-Host "What is the Device ID?"
$ComputerID = manage-bde -status -cn "$GetID"
foreach ($Computer in $ComputerID) {
Write-Host("$Computer")
}
What this does is prompt the tech for the host name and gives the results. How can I have the script prompt the tech for a path to a text file and then have the script give a list of results from that text file?
Upvotes: 1
Views: 7426
Reputation: 3111
$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."
}
Upvotes: 3