C# Sample Programs
The C# (.NET) sample programs are located in
the
file, and a
file.
SDK\vsphere-ws\dotnet\cs\samples\
directory.
Details listed in the following table. Each of the examples listed in the table
is actually a directory that contains a
.cs
file, a
.csproj
file, a
filename
2008.csprojfilename
2010.csprojThe samples include a
GeneratingStubs.txt
file and
a
readme_dotnet.html
file at
top level.
The
readme
file explains how to
build the examples using Visual Studio 2005 or Visual C# 2005 Express.
Example
| Description
|
---|---|
AddVirtualNic
| Adds a virtual NIC to
the ESXi system. First specifies a
HostVirtualNicSpec ,
and then adds the NIC to the host.
|
AddVirtualSwitch
| Adds a virtual switch
to the ESXi system.
|
AddVirtualSwitchPortGroup
| Adds a virtual port
group to the ESXi system.
|
AppUtil
| Contains the following
utility applications:
|
Basics
| Uses the
PerformanceManager for
basic monitoring.
|
Browser
| Retrieves the contents
of the
ServiceInstance
starting at the root folder, and prints a listing of
ManagedEntity objects.
Optionally, obtains properties for a specific type, or by default, for
ManagedEntity itself.
|
CIMInfo
| CIMInfo versioning sample that retrieves the
details of
CIM_Fan like
Activecooling ,
Caption ,
CommunicationStatus
and so on.
|
ColdMigration
| Migrates a powered off
virtual machine from one host to another.
|
Connect
| Simple example that
logs in and logs out.
|
Create
| Creates a
Folder ,
Cluster ,
Datacenter or
standalone host. Prompts the user for the item to create and where to put the
item, for example, in a folder.
|
CreateUser
| Creates a user.
Specifies permissions for the user using the
AuthorizationManager .
|
CredentialStorePSCmdLets
| Multiple commandlets
for managing the credential store.
|
Delete
| Deletes a managed
entity.
|
DeleteOneTimeScheduledTask
| Extracts a task from
scheduledTaskManager
and deletes it. This sample is well commented and illustrates using the
PropertyCollector . You
can create the task using the
OneTimeScheduledTask
example.
|
DisplayNewProperties
| Retrieves the specified
set of properties for the given managed object reference into an array of
result objects (returned in the same order as the property list)
|
DisplayNewPropertiesHost
| Displays properties of
an ESXi host. The properties displayed depend on the version of the host.
|
DisplayNewPropertiesVM
| Displays a set of
properties for a virtual machine. The properties displayed depend on the
version of the software on the host.
|
EventFormat
| Retrieves and formats
the last event on the ESXi or vCenter Server system. Demonstrates event
formatting.
|
EventHistoryCollectorMonitor
| Creates an
EventHistoryCollector
and monitors the corresponding events.
|
GetUpdates
| Retrieves updates for a
virtual machine or an ESXi host.
|
GetVirtualDiskFiles
| Retrieves the virtual
disk files from a host’s datastores.
|
GetVMFiles
| Downloads the files in
the virtual machine configuration directory as well as the files in the virtual
machine snapshot, suspend, and log directories. Writes progress to the console.
|
History
| Displays the
performance measurements of a specified counter of a specified ESXi for a
specified duration, or 20 minutes (default) at the console.
|
HostPowerOps
| Performs reboot,
shutdown, or suspend (power off to standby) operations on an ESXi system.
|
LicenseManager
| Displays licensing
information. The user can specify a license server,
|
MobStartPage
| Includes a program,
image files, and HTML files for displaying a Managed Object browser.
|
Move
| Moves a managed entity
from one folder to another.
|
OneTimeScheduledTask
| Creates a
ScheduledTask that
powers off a virtual machine and schedules the task using a
OnceTaskScheduler . You
can delete the task using the
DeleteOneTimeScheduledTask commandlet.
|
PrintCounters
| Defines a
printEntityCounters
function that prints counters for a virtual machine, host, or resource pool.
|
PropertyCollector
| Illustrates use of the
PropertyCollector .
|
QueryMemoryOverhead
| Illustrates use of the
QueryMemoryOverhead
method. The folder includes two examples,
QueryMemoryOverheadV25
uses the currently valid
QueryMemoryOverheadEx
method,
QueryMemoryOverhead
uses the deprecated
QueryMemoryOverhead
method.
|
RealTime
| Displays the current
performance measurements of selected CPU counters of any specified virtual
machine at the console.
|
RecordSession
| Records a session and
allows you to retrieve a specified set of properties for a specified managed
object reference into an array of result objects.
|
RemoveManagedObject
| Removes a host from a
cluster or a virtual machine from a host. Handles errors, for example, if the
host is not in a cluster, by printing that information to the command line.
|
RemoveVirtualNic
| Removes a virtual NIC
from the ESXi system.
|
RemoveVirtualSwitch
| Removes a virtual
switch from the ESXi system.
|
RemoveVirtualSwitchPortGroup
| Removes a virtual port
group from the ESXi system.
|
Rename
| Renames a managed
entity.
|
SCSILunName
| Prints the virtual
machine file system volumes on a specified SCSI LUN.
|
SearchIndex
| Illustrates the use of
the
SearchIndex API.
|
SimpleClient
| Demonstrates connecting
to a service, logging on to service, obtaining service content, and logging out
from the service.
|
SSPI
| Illustrates how to use
an SDK application with Microsoft SSPI.
|
SSPICIMClient
| Illustrates how to use
an CIM client application with Microsoft SSPI.
|
TaskList
| Displays currently
running tasks and their state.
|
VMClone
| Clones a virtual
machine.
|
VMCreate
| Creates a virtual
machine.
|
VMEventHistoryCollectorMonitor
| Returns all events on
the latest page on the
EventHistoryCollector .
|
VMotion
| Validates that
migration with VMotion is feasible between two hosts, and performs the
migration if the hosts are compatible.
|
VmPowerOps
| Retrieves a reference
to a virtual machine and invokes power operations specified on the command line
on that virtual machine.
|
VMPowerStateAlarm
| Creates an alarm that
monitors virtual machine state and sends email if the virtual machine power is
off. Includes error handling, for example, when the command is attempted with
an ESXi host as a target.
|
VMReconfig
| Reconfigures a virtual
machine by changing its memory, cpu, disk, nic, or cd.
|
VMSnapshot
| Performs snapshot
operations such as create, revert to, remove, remove all, and so on.
|
VMware.Security.CredentialStore
| Illustrates use of the
VMware credential store.
|
WatchVM
| Monitors updates on a
virtual machine using the
PropertyCollector .
|
WeeklyRecurrenceScheduledTask
| Creates a task that
reboots a virtual machine once a week.
|