Hoping the community can help with this one. I’m trying to put together a script that pulls the MAC addresses from computers in AD by grabbing the corresponding computer objects IP from DNS and than querying for MAC address. This snippet of my script grabs the MAC address successfully as a string but in doing so, there is either a NULL entry or blank space above the string. This causes issues when I try and pass this as a variable to a parameter in a CMDLET.
Can someone assist in helping me get the string formatted correctly?
Try running $newmac.Trim() against it to trim off whitespace. That’s a method of System.String, if you want to look up more about it on MSDN. If it doesn’t have any effect, then you’re seeing something other than whitespace, although from here I can’t tell you what that would be.