天天看點

基于Intune将企業内部固定資産編号寫入至ThinkPad系列BIOS

背景

如果你的公司内部有固定資産管理的要求,那麼你需要在

固定資産系統

中維護

資産類型

資産編号

采購日期

使用人資訊

産品序列号

産品型号

等等。同時,你還可能需要生成固定資産标簽,将其貼在對應的裝置上。

那麼當使用者歸還裝置、更換裝置、硬體保修、資産盤點核查等情況,如何幫助資産管理者便捷的擷取上述資産資訊?

假如資産标簽磨損、丢失又該如何去快速擷取?

如果你的環境中,終端大部分都是

ThinkPad

系列,你可以參考本文,基于

Intune

便捷的将企業内部的資産編号等相關資訊寫入至BIOS系統中。(

Lenovo

HP

也有相同的資産管理工具,但不在本文編寫範圍内,請自行搜尋)

說明

聯想提供了一個Windows實用工具:Windows Utility來讀取和寫入資産ID資訊,專門用于ThinkPad。使用此實用程式,您可以設定資産ID資料,例如所有者姓名,所有者位置,資産編号和其他一些資訊。

本文将主要配置以下資訊:

  • Asset Tag
  • Owner Name
  • Department
  • Location

基于終結點分析主動修正腳本包部署

建立主動修正配置

通路Microsoft EndPoint Manager管理中心

報表

終結點分析

主動修正

建立自定義腳本

基于Intune将企業内部固定資産編号寫入至ThinkPad系列BIOS
基于Intune将企業内部固定資産編号寫入至ThinkPad系列BIOS

配置腳本

Intune與SCCM配置類似,部署腳本主要分為

檢測腳本

修正腳本

,用于判斷不符合條件的計算機并執行相關修複操作。其中:

檢測腳本: 找出還未配置自定義

資産編号

ThinkPad

機型;

修正腳本: 将檢測出來的計算機通修正腳本自動下載下傳并執行Lenovo ThinkPad Windows Utility工具,并基于各自的需求去執行指令配置相關參數。

這裡我的資産管理政策是:以内部資産系統的資産編号為計算機名。是以下面的腳本中,将以計算機名作為資産編号。

  • 檢測腳本
$AssetTag = (Get-CimInstance -Namespace root/CIMV2 -ClassName Win32_SystemEnclosure).SMBIOSAssetTag
$Model = (Get-CimInstance -Namespace root/CIMV2 -ClassName Win32_ComputerSystemProduct).Version

if ($Model -notmatch "ThinkPad") {
    Write-Output "該裝置支援"; Exit 0
}

if ($AssetTag -match "No Asset") {
    Write-Output "資産編号未配置"; Exit 1
}
else {
    Write-Output "資産編号已配置"; Exit 0
}
           
  • 修正腳本
# URL to WinAIA Utility
$url = "https://download.lenovo.com/pccbbs/mobiles/giaw03ww.exe"
$destPath = Join-Path -Path (Join-Path -Path $env:ProgramData -ChildPath Lenovo) -ChildPath WinAIA
$destFile = $url.Split('/')[-1]

# Set your organization information
$ownerName = "ITPro"
$ownerDept = "IT Operation Team"
$ownerLocation = "CHINA,BJ"
$assetPrefix = "LAPTOP"
$PCHostName = hostname

try {
    
    # Create directory for utility
    if (!(Test-Path -Path $destPath)) {
        New-Item -Path $destPath -ItemType Directory
    }

    # Download utility via HTTPS
    if (!(Get-ChildItem -Path "$destPath\$destFile" -ErrorAction SilentlyContinue)) {
        Start-BitsTransfer -Source $url -Destination "$destPath\$destFile"
    }

    # Extract contents
    $extract = "/VERYSILENT /DIR=$destPath /EXTRACT=YES"
    if (!(Get-ChildItem -Path $destPath -Filter WinAIA*)) {
        Start-Process -FilePath "$destPath\$destFile" -ArgumentList $extract -Wait
    }

    # Variable for last 5 numbers of Unique ID
    $uuid = (Get-CimInstance -Namespace root/CIMV2 -ClassName Win32_ComputerSystemProduct).UUID.Split("-")[4].Substring(6)

    <# 
        Set Owner Data with WinAIA Utility. 
        These are sample values and can be changed.
    #>
    Set-Location -Path $destPath
    .\WinAIA64.exe -silent -set "OWNERDATA.OWNERNAME=$ownerName"
    .\WinAIA64.exe -silent -set "OWNERDATA.DEPARTMENT=$ownerDept"
    .\WinAIA64.exe -silent -set "OWNERDATA.LOCATION=$ownerLocation"

    <#  
        Set Asset Number. Available through WMI by querying the SMBIOSASSetTag field of the Win32_SystemEnclosure class
        Example shows the $uuid is prefixed with CDRT. This can be replaced as you see fit.
    #>
    # .\WinAIA64.exe -silent -set "USERASSETDATA.ASSET_NUMBER=$assetPrefix-$uuid" # IT ASSENT Number Auto Config with $assetPrefix-$uuid or Auto Config with system hostname
    .\WinAIA64.exe -silent -set "USERASSETDATA.ASSET_NUMBER=$PCHostName" # 


    # AIA Output file
    .\WinAIA64.exe -silent -output-file "$destPath\WinAIA.log" -get OWNERDATA USERASSETDATA

    # Remove Package
    Remove-Item -LiteralPath "$destPath\$destFile" -Force

    Write-Output "Asset Tag Set"; Exit 0
    
}
catch {
    Write-Output $_.Exception.Message; Exit 1
}
           
基于Intune将企業内部固定資産編号寫入至ThinkPad系列BIOS

定義腳本應用範圍

測試環境,我選擇應用至所有裝置。
基于Intune将企業内部固定資産編号寫入至ThinkPad系列BIOS

效果示範

隻有資産編号

Asset Tag

的資料能寫入BIOS,其他資訊隻能結合聯想的工具支援的指令查詢

BIOS效果

基于Intune将企業内部固定資産編号寫入至ThinkPad系列BIOS

其他資訊指令查詢

腳本或者手動安裝完上述聯想工具後,其工具所在路徑為:

C:\ProgramData\Lenovo\WinATA\

執行

.\WinAIA64.exe -get OWNERDATA USERASSETDATA

可以查詢我上述定義的四個資産資訊。

基于Intune将企業内部固定資産編号寫入至ThinkPad系列BIOS

也可以使用腳本将其靜默導出或傳輸至其他伺服器,指令及效果如下:

$hostname = hostname
.\WinAIA64.exe -silent -output-file c:\$hostname.txt -get OWNERDATA USERASSETDATA
get-content -path c:\$hostname.txt
           

繼續閱讀