首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用远程PC的Get-MPComputerStatus?

如何使用远程PC的Get-MPComputerStatus?
EN

Stack Overflow用户
提问于 2021-03-10 17:53:11
回答 1查看 2.6K关注 0票数 0

我试图远程获取域pc的反病毒状态,使用powershell脚本。以下代码按预期工作,但我不知道如何将-computername参数传递给命令。它将返回运行脚本的本地pc的恶意软件状态,但不返回AD pc的恶意软件状态。其他变量(如位置、设备名称、序列号)将正确返回:

代码语言:javascript
复制
    import-module ActiveDirectory

Get-ADComputer -filter "name -like '*'" |
Select -expandproperty name |

    ForEach {

 
  
   $results =  % { Get-ADComputer -Identity $_ -Properties Description }
   
   $cs = gwmi win32_bios -ComputerName $_ -ErrorAction SilentlyContinue

   $os = Get-Wmiobject -class Win32_operatingsystem  -computername $_  -ErrorAction SilentlyContinue  
         
   $bios = Get-WmiObject Win32_ComputerSystem -ComputerName $_ -ErrorAction SilentlyContinue 

 
      
   $rs =  Get-MpComputerStatus 

 #$rs = Get-WmiObject Win32_ComputerSystem -ComputerName $_ -ErrorAction SilentlyContinue |  Get-MpComputerStatus 

   $Object = New-Object PSObject -Property @{
    
    
       "Device Name" = $results.name 
       "Physical Location" = $results.description
       "Employee" = $bios.UserName        
       "Last Logon Date" = $results.LastLogonDate
       "Category" = $bios.ChassisSKUNumber
       "Vendor" = $bios.Manufacturer
       "Make/Model" = $bios.Model
       "Serial Number" = $cs.SerialNumber        
       'OS' = $os.caption
       'Malware Updated' = $rs.AntivirusSignatureLastUpdated
       'AntiSpyware Status' = $rs.AntispywareEnabled
       'AntiMalware Version' = $rs.AMServiceVersion
     
        }
        

       $Object |
  Select-Object "Physical Location", "Employee", "Device Name", "Malware Updated",'AntiSpyware Status','AntiMalware Version', "Serial Number", "Vendor", "Make/Model", "OS"|
  Export-Csv  -Append -Force  -NoTypeInformation "$($env:USERPROFILE)\documents\WinDef.csv"  #"c:\data\asset_inventory2.csv
 }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-10 18:48:18

您可以使用-CimSession,如MS中所解释的:

在远程会话或远程计算机上运行cmdlet。输入计算机名称或会话对象,例如或cmdlet的输出。默认值是本地计算机上的当前会话。

或者你可以$rs=Invoke-Command RemoteComputer {Get-MpComputerStatus}

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66570269

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档