Hello Everyone, So completely new on Powershell.Starting to learn it. Ik have an issue with my script. Which i cannot find how to solve it. I created an array with computer information. (ip and mac addresses).
So i can do for example $computers.mac, I get a list of mac addresses. What i need is to remove the last 9 characters of the mac address.
What i found:
$mac = $computers.mac[0]
$mac.Substring(0,$mac.length-9)
this is working, but off course just for 1 item
So, it should be something with foreach i think, but till now cannot figure it out…
ForEach ($Mac in $LocalMacAddressList)
{
{
$mac.Substring(0,$computers.length-8)
}
}
I hope someone, can point me in the right direction. Help is appriciated.
That’s actually not needed. If all your MAC addresses have the same format as it’s usually is you don’t need to calculate the length for each individual element of the array. It could look like this: