zoukankan      html  css  js  c++  java
  • SCCM Collection 集合获取计算机最后启动时间

    获取计算机客户端最后一次启动时间,我们可以通过多种来源获取,如活动目录组 ,而不仅仅是SCCM 收集,希望对您有所帮助,下面分享PowerShell 脚本

    # 1

    $CollectionName = 'CollectionName'
    
    $file = "Csv report file path"
    
    $SiteServer = 'SCCMSERVER'
    
    $SiteCode = 'YourSCCMSiteCode'
    
    #Get the collection using WMI
    
    $Collection = get-wmiobject -ComputerName $siteServer -NameSpace "ROOTSMSsite_$SiteCode" -Class SMS_Collection | where {$_.Name -eq "$CollectionName"}
    
    #Get the collection members
    
    $CollectionMmebers = Get-WmiObject -ComputerName $SiteServer -Namespace "ROOTSMSsite_$SiteCode" -Query "SELECT * FROM SMS_FullCollectionMembership WHERE CollectionID='$($Collection.CollectionID)' order by name" | select Name
    
    #The $CollectionMembers lastBoot

     $data = @() ForEach($Computer in $CollectionMmebers) { try { $operatingSystem = Get-WmiObject Win32_OperatingSystem -ComputerName $($Computer.Name) $lastBoot = [Management.ManagementDateTimeConverter]::ToDateTime($operatingSystem.LastBootUpTime) } catch { $lastBoot = "ERROR Connecting" } $data += New-Object PSObject -Property @{ Name = $Computer.Name "Last Boot" = $lastBoot } } $data | Export-Csv $file
  • 相关阅读:
    HTTP响应状态码整理
    Python通用爬虫,聚焦爬虫概念理解
    HTTP无状态协议理解
    会话与事务知识点总结
    并发一致性知识点整理
    使用隔离级别read committed隐式解决并发冲突
    多并发笔记整理
    git基本使用
    Docker其他
    Docker Bind Mount 与 Volume
  • 原文地址:https://www.cnblogs.com/Aldj/p/8609928.html
Copyright © 2011-2022 走看看