none
Assigning static mac address via powershell RRS feed

  • Question

  • Hey,

    in our company i have to change the mac addresses of all vms from dynamic to static.

    so i wrote a little script, but the macadress wont swtich to static..

    here is what i did, maybe you can help me (im new to powershell)

    $vmname = "gpotest"
    
    
    foreach($vm in $vmname)
    {
    
    $macaddress = get-vm -name $vm | get-VMNetworkAdapter | fl MacAddress
    
    $macaddress = $macaddress | Out-String
    
    $macaddress = $macaddress.Substring(17)
    $macaddress = $macaddress.Insert(0,'"')
    $macaddress = $macaddress.insert(13,'"')
    
    get-vm -name $vm | get-VMNetworkAdapter | set-VMNetworkAdapter -StaticMacAddress $macaddress
    
    }
    

    thanks in advance

    Wednesday, January 15, 2014 9:14 AM