0

我需要一些关于导出到 CSV 文件的 PowerShell 脚本的帮助:计算机主机名、操作系统名称(Windows 10 企业版、Windows 10 专业版等)。

到目前为止,我设法使用以下方法完成了上述所有操作:

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

但是当尝试添加“Get-BitLockerRecovery”参数时,powershell 会返回:

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

有人可以向我解释为什么吗?或者帮助我将必要的命令添加到我的脚本中?

4

1 回答 1

0

很确定信息不在目录中 - 您需要查询每台机器。

遍历您的机器列表,使用 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
                }
}
于 2020-01-23T12:26:02.747 回答