天天看點

Powershell SCCM WMI Class

最近打算把CMDB 當中的字段資訊與SCCM 做內建, 我們的CMDB 環境中定義了資産的業務等級, 例如: 生産, 測試, QA, 開發

  1. Powershell 導入SCCM 子產品 ​​Import-Moudle ConfigurationManager​​
  2. 連接配接SCCM 站點
$SCCMSiteServer = 'SCCM2016'
$SCCMsiteCode = 'BeijingOffice'
$CMCollection = [wmiclass]("\\$SCCMSiteServer\ROOT\sms\site_$SCCMsiteCode" + ":SMS_Collection")      
  1. ​​更新Device Category​​
[String]$CategoryID = ''
[Int]$ResourceID = ''
$CMCollection.SetDeviceCategory($CategoryID,$ResourceID)