0

基于Intune将企业内部固定资产编号写入至ThinkPad系列BIOS

 1 year ago
source link: https://blog.51cto.com/jasonhuang/5501152
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

基于Intune将企业内部固定资产编号写入至ThinkPad系列BIOS

推荐 原创

如果你的公司内部有固定资产管理的要求,那么你需要在固定资产系统中维护资产类型资产编号采购日期使用人信息产品序列号产品型号等等。同时,你还可能需要生成固定资产标签,将其贴在对应的设备上。

那么当用户归还设备、更换设备、硬件保修、资产盘点核查等情况,如何帮助资产管理员便捷的获取上述资产信息?
假如资产标签磨损、丢失又该如何去快速获取?

如果你的环境中,终端大部分都是ThinkPad系列,你可以参考本文,基于Intune便捷的将企业内部的资产编号等相关信息写入至BIOS系统中。(LenovoHP也有相同的资产管理工具,但不在本文编写范围内,请自行搜索)


联想提供了一个Windows实用工具: Windows Utility来读取和写入资产ID信息,专门用于ThinkPad。使用此实用程序,您可以设置资产ID数据,例如所有者姓名,所有者位置,资产编号和其他一些信息。

本文将主要配置以下信息:

  • Asset Tag
  • Owner Name
  • Department
  • Location

基于终结点分析主动修正脚本包部署

新建主动修正配置

访问Microsoft EndPoint Manager管理中心报表终结点分析主动修正创建自定义脚本

watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=
watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=

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
}
watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=

定义脚本应用范围

测试环境,我选择应用至所有设备。

watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=

只有资产编号Asset Tag的数据能写入BIOS,其他信息只能结合联想的工具支持的命令查询

BIOS效果

watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=

其他信息命令查询

脚本或者手动安装完上述联想工具后,其工具所在路径为:C:\ProgramData\Lenovo\WinATA\

执行.\WinAIA64.exe -get OWNERDATA USERASSETDATA可以查询我上述定义的四个资产信息。

watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=

也可以使用脚本将其静默导出或传输至其他服务器,命令及效果如下:

$hostname = hostname
.\WinAIA64.exe -silent -output-file c:\$hostname.txt -get OWNERDATA USERASSETDATA
get-content -path c:\$hostname.txt
watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_30,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=

其他命令请参考执行.\WinAIA.exe -help查询。


Enjoy 😄


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK