[英]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.