$sn = Read-Host -Prompt "请输入SN号(7位 or 10位)"
$xl = New-Object -ComObject "Excel.Application"
$cmdbwb = $xl.Workbooks.Open("F:\Ivan\HZCMDB.xlsx")
$cmdbwss = "01--GE DST", "01--BBG DST", "01--Non GE DST", "02--Laptop"
ForEach ($cmdbwsname in $cmdbwss) {
$cmdbws = $cmdbwb.Worksheets.Item($cmdbwsname)
$row = $cmdbws.cells.find($sn).row
if($row -ne $null) {
[pscustomobject][ordered]@{
EmployeeNo = $cmdbws.range("A$row").text
EmployeeName = $cmdbws.range("B$row").text
SeatNo = $cmdbws.range("C$row").text
Project = $cmdbws.range("D$row").text
Model = $cmdbws.range("E$row").text
ServiceTag = $cmdbws.range("F$row").text
FinanceNo = $cmdbws.range("G$row").text
RAM = $cmdbws.range("H$row").text
Hostname = $cmdbws.range("I$row").text
}}}
$xl.Quit()
$cmdbws = $null
$cmdbwb = $null
$xl = $null
[GC]::Collect()