Page tree

OpBot - virtual assistant for your virtual datacenter

Skip to end of metadata
Go to start of metadata

General Commands

Whenever you don´t know how to execute commands and how the syntax works, just type @opbot help and OpBot will tell what can be done for you.

Important: You don't need to run connect-viserver to connect to the VMware vCenter, our OpBot PowerShell session handles that automatically

CommandDescription

posh <command>

starts the command in a PowerShell Session connected to the given VMware vSphere environment (vApp import settings)
powershell <command>same as posh

VMware PowerCLI Core Examples

CommandDescription

posh Get-VM -Name MyVM*

Retrieves all virtual machines whose names starting with "MyVM"
posh Get-VMGuest -VM MyVM
Retrieves the guest OS of the virtual machine named "MyVM".
posh Get-Datastore

list all Datastores

posh Get-VMHostlist all ESXi Hosts
posh Get-VM MyVM | Get-Datastorelist all Datastores, the VM MyVM is connected to


check out the PowerCLI command reference

PowerCLI CmdLet Poster and the direct Download

PowerShell Editor

CommandDescription

editor on

Open a web editor session to customize the PowerShell scripts and profiles for 30 minutes
editor off
Closes the web editor session


@opbot editor on is starting the PowerShell editor

you can access the editor using your browser and the built in PowerShell editor.


Files and FoldersDescription

profile.ps1

OpBot's PowerShell profile. You can add functions and alias commands here, that you want to use in every session. Nevertheless, we encourage you to leave that file unchanged and use custom/functions.ps1 instead
custom
all files within this folder are sourced, that means its content loaded to be used within the PowerShell session. Very helpful if you want to add your own functions.
modulesupload your psm1 function files here. These are loaded using the import-module command within the profile.ps1 file.

Advanced Users

Get Information about ESXi product installation:

posh Get-View -viewtype HostSystem | % {$_.Config.Product }

Get VMware Tools status information:

posh Get-VM win* | Select Name, @{N="Tools Installed";E={$_.Guest.ToolsVersion -ne ""}}, @{N="Tools Status";E={$_.ExtensionData.Guest.ToolsStatus}}, @{N="Tools version";E={if($_.Guest.ToolsVersion -ne ""){$_.Guest.ToolsVersion}}}


Test

Get latest Performance Data from a Virtual Machine:

posh Get-VM vm123 | Where {$_.PowerState -eq "PoweredOn"} | Select Name, VMHost, NumCpu, MemoryMB, @{N="CPU Usage (Average), Mhz" ; E={[Math]::Round((($_ | Get-Stat -Stat cpu.usagemhz.average -Start (Get-Date).AddDays(-1) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}}, @{N="Memory Usage (Average), %" ; E={[Math]::Round((($_ | Get-Stat -Stat mem.usage.average -Start (Get-Date).AddDays(-1) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} , @{N="Network Usage (Average), KBps" ; E={[Math]::Round((($_ | Get-Stat -Stat net.usage.average -Start (Get-Date).AddDays(-1) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} , @{N="Disk Usage (Average), KBps" ; E={[Math]::Round((($_ | Get-Stat -Stat disk.usage.average -Start (Get-Date).AddDays(-1) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}}

Get VM Disk detail information:

posh $report = @(); $vms = get-vm win10*; foreach($vm in $vms) {$vhds = Get-HardDisk $vm ; foreach ($vhd in $vhds){ $row = "" | select VMName, Name, FileName, CapacityGB; $row.VMName = $vhd.Parent; $row.Name = $vhd.Name; $row.FileName = $vhd.FileName; $row.CapacityGB = $vhd.CapacityGB; $report += $row;} } $report | fl


  • No labels
Write a comment…