Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking Bitlocker status on a computer list

Status
Not open for further replies.

Leozack

MIS
Oct 25, 2002
867
0
0
GB
Hi all
I'm not used to using powershell compared to batch files. What i'm trying to do is script some results using manage-bde (is on my Win10 PC and seems to be standard, but isn't on our 2012 server?) to show the Encryption status of all PCs in a text list.
So far I've ended up with the following PS1
Code:
$InputFile = "\\server\share name\folder\ComputerList.txt"
    #Read in the contents of the file
    $hostnames=get-content $InputFile
    #Loop through the list of hostnames one at a time
    ForEach ($hostname in $hostnames)
    {
        #Check the Encryption Status of the C: drive, filter to the Conversion Status line
        $EncryptionStatus=(manage-bde -status -cn "$hostname" C: | where {$_ -match 'Conversion Status'})
        #Check a status was returned. 
        if ($EncryptionStatus)
        {
            #Status was returned, tidy up the formatting
            $EncryptionStatus=$EncryptionStatus.Split(":")[1].trim()
        }
        else
        {
            #Status was not returned. Explain why in the output
            $EncryptionStatus="Not Found On Network (or access denied)"
        }
        #Format the output object. 2 fields "Hostname" and "Status"
        [pscustomobject][ordered]@{
                    'Hostname'=$Hostname;
                    'Status'=$EncryptionStatus;
        }
    }#End of Loop through Hostnames
If I rightclick-run-in-powershell it on the sever (logged in as my "admin" acc that isn't actually an admin on the server) it says manage-bde isn't available (doesn't seem to be in the 2012 OS).
If I rightclick-run-in-powershell it on my local PC (as my non-admin acc) it takes a while and then starts giving me the results saying it's not available - even on a test laptop sat next to me available.
If I open CMD as admin and then run the ps1 from there, it works correctly and gives correct results on my test laptop that is available.
So I made a BAT file saying
Code:
powershell -noexit "& ""\\server\share name\folder\checklist.ps1"""
pause
(I forget where I got the formatting for that to make it work because by default I would've just put "powershell \\path\scriptname.ps1" myself)
If I run the BAT file on my local PC (as non admin) it does the same as when I rightclick-run-in-powershell the PS1 - takes a while and gives failing results.
If I rightclick-run-as-admin the BAT file, it flashes a window up that instantly closes.

Has anyone got any idea how I can do what felt like a relatively simple requirement for Bitlocker status checking on multiple remote machines that may or may not be connected at the time?
It would be nice if it ran on the 2012 server, but running on our local machines is ok as long as the onlyl requirement would be right-clicking a bat and running as admin (no simple run-as-admin options when clicking a PS1)

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top