OK i tried and just can't seem to get it correct. I tried reverse engineering a script from to now add a custom attribute to vSphere, the MAC address of the device, it's not getting it populated. The below does output the MAC addresses into the console. It will also of course create the attribute MAC in vSphere. But I'm also looking for only the first entry on any given VM if there are multiple NICs on the VM.
$caName = 'MAC'
try {
$ca = Get-CustomAttribute -Name $caName -ErrorAction Stop
} catch {
$ca = New-CustomAttribute -Name $caName -TargetType VirtualMachine
}
Get-VM -name "*" | Get-NetworkAdapter | select -ExpandProperty MacAddress
Where-Object { $_.MacAddress } |
ForEach-Object -Process {
Set-Annotation -Entity $_ -CustomAttribute $ca -Value $_.MacAddress
}
Get-Variable shows this:
Get-CustomAttribute CustomAttribute with name 'MAC' was not fo...
How does one go about finding the full error? I'm assuming it say it was not found but I dont' know for sure.
Thanks a bunch. Last one for vsphere attributes i promise