Try this:
$out = Invoke-VMScript -VM $vm -GuestUser $user -GuestPassword $password -scripttext "netsh interface ip show config"
$m = $out | Select-String -pattern "Local Area Connection \d+"
if ($m) {
$interface = $m.matches[0].value
if ($interface -ne $null) {
$cmd = "netsh interface ip set address name='$interface' static $ip"
$out = Invoke-VMScript -VM $vm -GuestUser $user -GuestPassword $password -scripttext $cmd
}
}