我正在尝试设置一个主 CSV 文件,该文件在 MDT 任务序列期间运行 PowerShell 脚本时进行检查。脚本试图做的是获取物理连接的 nic 卡的 mac 地址并将其与 CSV 文件进行比较,以查看它是否与文件中保存的 Mac 地址匹配。如果 mac 地址与 CSV 中的值匹配,它会将计算机重命名为与 Mac 地址配对的值。如果没有匹配项,则根据计算机序列号对其进行重命名。
这里是我有一些远。
$computer = Get-WmiObject Win32_ComputerSystem -ComputerName $oldname
#$Machost is Mac Address of the active Network Card
$MacHost=Get-NetAdapter -Name "Ethernet" | Select Macaddress
$ConvertMacHost= $MacHost[0] -replace '(:|-|\.)'
Write-Host "You mac address is: " $MacHost
#MacHost gets reformatted to take out Semicolons - Ex 0011223344AA
#MacLab is a variable that stores the Computer name and Mac Address from File created in …Run Code Online (Sandbox Code Playgroud) powershell ×1