簡體   English   中英

將計算機主機名、操作系統以及是否啟用 Bitlocker 導出為 CSV 的 PowerShell 腳本

[英]PowerShell script that exports to CSV the computer Hostname, operating system and if Bitlocker is enabled or not

我需要一些有關導出到 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

有人可以向我解釋為什么嗎? 或者幫助我將必要的命令添加到我的腳本中?

非常確定該信息不在目錄中 - 您需要查詢每台機器。

遍歷您的機器列表,使用 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
                }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM