Manage Vmware ESxi via PowerShell

      Comments Off on Manage Vmware ESxi via PowerShell

vmware_ps_iconIntroduction

In my company we are use for Virtualize the servers the VmWare Esxi server. I recomand for everyone who what to use in the real PRODUCTION for litte server farms (some 10-20 servers)

But today i what to write about how can you manage via power shell this Virtual Enviroment and the Server itself.

Receipe

1. You are need a installed VmWare Esxi 4 server (In my case the 4 version)

2. The VMware vSphere PowerCLI – this is the PowerShell Add-On

3. Some time.

Let’s start

1. If you have the VmWare Esxi server m you need to create a nem user, its for your safety. I dont recomand the root user. Like in this way:

–  Open the VmWare VSphere Client, go to Users & Groups, add the new user like tester and osme password. Add to the users group and on The Permisions tab define the Read Only

2. Download and install the VMware vSphere PowerCLI, its easy with the Next, Next

3. Open the newly installed shell, or run Start-> All Programs -> Vmware -> VMware vSphere PowerCLI

4. Let’s start.

Posibilities

For beginners
1. Get the help CHM help. This command opens a CHM file.
[code lang=”bash”]
Get-VIToolkitDocumentation
[/code]

2 Get the VI commands
[code lang=”bash”]
Get-VIcommand
[/code]

3. Connect to VmWare Server (192.168.3.1 is the Server IP and the tester user is the created use on )
[code lang=”bash”]
Connect-VIServer -Server 192.168.3.1 -User tester -Password abcdefgh
[/code]

For Andvance users
4. Get the Storage Statisctics and all Virtual Machines infos with POWERON status
[code lang=”bash”]
cls
$srv= Connect-VIServer -Server 192.168.3.1-User tester-Password abcdefgh
$storage = Get-Datastore -Server $srv

$vm_name = Get-VM -Server $srv | Sort-Object “PowerState” -Descending | Where-Object { $_.PowerState -eq “PoweredOn” } | Select-Object “Name”,”MemoryMB”,”NetworkAdapters”,”HardDisks”,”PowerState”

Write-Output “Storage Status:” $storage

Write-Output “`nVirtual Maschine infos:” $vm_name

[/code]

The result:

vmwareps

Reference

1. VmWare Esxi 4.0

2. VMware vSphere PowerCLI