#Change the networking properties of a Linux guest VM - setLinuxVMNetworking.ps1
#Erik Hinderer
#ehinderer@vmware.com
#Version 0.1
###Run the script and enter the vCenter and Linux VM network information as prompted###
$vclist = @(Read-Host "Please enter the FQDN or IP address of vCenter Server")
"Please enter your vCenter credentials"
$creds = get-credential "root"
$linuxVMname = @(Read-Host "Please enter the VM name of the Linux guest OS you wish to change")
$IP = @(Read-Host "Please enter the IP address you wish to set the Linux guest to")
$NETMASK = @(Read-Host "Please enter the NETMASK address you wish to set the Linux guest to")
$GATEWAY = @(Read-Host "Please enter the GATEWAY address you wish to set the Linux guest to")
connect-viserver -server $vclist -credential $creds -WarningAction 0
Get-VMGuestNetworkInterface $linuxVMname -GuestCredential (Get-Credential) | Where-Object { $_.ip -ne $null} | Set-vmguestnetworkinterface -ip $IP -netmask $NETMASK -gateway $GATEWAY -GuestCredential (Get-Credential)