0

I need some help regarding a PowerShell script that exports to a CSV file the following: the computer hostname, the operating system name (windows 10 enterprise, windows 10 pro, etc).

So far I managed to do all of the above using :

Get-ADComputer -Filter * -Properties * |
 Select -Property Name,DNSHostName,Operatingsystem,BitLockerRecoveryInfo,Enabled,LastLogonDate | 
 Export-CSV "C:\\AllComputers.csv" -NoTypeInformation -Encoding UTF8

But when trying to add the "Get-BitLockerRecovery" argument, powershell returns:

Get-ADComputer -Filter { name -like "*" } `
Select -Property Name,DNSHostName,Operatingsystem,BitLockerRecoveryInfo,Enabled,LastLogonDate |
Get-BitLockerRecovery |
Export-CSV "C:\\Bit.csv" -NoTypeInformation -Encoding UTF8

Get-BitLockerRecovery: The term 'Get-BitLockerRecovery' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:4 char:1
+ Get-BitLockerRecovery |
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-BitLockerRecovery:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Can someone please explain to me why? Or help me with adding the necessary commands to my script?

Hamed
  • 5,867
  • 4
  • 32
  • 56
  • AFAIK `Get-BitLockerRecovery` is not a standard Powershell cmdlet. You would need to install it first to be able to use it. – Olaf Jan 23 '20 at 12:03

1 Answers1

0

Pretty sure that the information is not in the directory - you need to query each machine.

Iterate through your machine list, querying with Get-BitlockerVolume

Get-ADComputer -Filter * -Properties Enabled,LastLogonDate,OperatingSystem | ForEach-Object {
    $BitLockerStatus = Invoke-Command -ComputerName $_.Name -ScriptBlock { Get-BitLockerVolume }
    [pscustomobject]@{Name = $_.Name
                    DNSHostName = $_.DNSHostName
                    Enabled = $_.Enabled
                    LastLogon = $_.LastLogonDate
                    BitLockerStatus = $BitLockerStatus.ProtectionStatus
                    OperatingSystem = $_.OperatingSystem
                }
}
Scepticalist
  • 3,737
  • 1
  • 13
  • 30