The C# (.NET) sample programs are located in the SDK\vsphere-ws\dotnet\cs\samples\ directory, as detailed in the following table. Each of the listed examples is actually a directory that contains a .cs file, a .csproj file, and an app.config file.

See the readme_dotnet.html file for more information. It explains how to build the examples using Visual Studio and run them from the command line.

Example Description
AcquireBearerTokenByUserCredential Generate a bearer token based on basic user credentials.
AcquireSessionInfo Acquire session with a vCenter Server or ESXi and print a CIM service ticket and related session information to a file.
AddVirtualNic Add a virtual NIC to the ESXi system. First specifies a HostVirtualNicSpec, and then adds the NIC to the host.
AddVirtualSwitch Add a virtual switch to the ESXi system.
AddVirtualSwitchPortGroup Add a virtual port group to the ESXi system.
AppUtil Contains the following utility applications:
  • AppUtil – Utility application that drives the user input mechanism for other samples and includes some other utility functions.
  • ArgumentHandlingException – Handles command-line exceptions. Used by AppUtil.
  • CertPolicy – Handles certification problems by displaying informational messages.
  • ClientUtil – Client utilities related to prompting the user and logging. Used by AppUtil.
  • Log – Logger to file or console.
  • OptionSpec – Option parsing utility.
  • ServiceUtil – Utility for connecting to the server.
  • VersionUtil – Utility to determine name space and supported versions.
  • VMUtils – Utility that sets values for a basic virtual machine. Some of the setup, such as adding a floppy disk drive, might not always be needed.
Basics Use the PerformanceManager for basic monitoring.
Browser Retrieve the contents of the ServiceInstance starting at the root folder, and print a listing of ManagedEntity objects. Optionally, obtain properties for a specific type, or by default, for ManagedEntity itself.
ColdMigration Migrate a powered off virtual machine from one host to another.
Connect Simple example that logs in and logs out.
Create Create 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.
CreateStorageDRS Demonstrates how to create a DRS group in storage.
CreateUser Create a user, specifying permissions for the user with the AuthorizationManager.
CredentialStorePSCmdLets Multiple cmdlets for managing the credential store.
Delete Delete a managed entity.
DeleteOneTimeScheduledTask Extract a task from scheduledTaskManager and delete it. This sample is well commented and illustrates using the PropertyCollector. You can create the task using the OneTimeScheduledTask example.
DisplayNewProperties Display properties of an ESXi host. The properties displayed depend on the version of the host.
DisplayNewPropertiesVM Display a set of properties for a virtual machine. The properties displayed depend on the version of the software on the host.
DVSCreate Create a distributed virtual switch, or add a port group.
EventFormat Retrieve and format the last event on the ESXi or vCenter Server system. Demonstrates event formatting.
EventHistoryCollectorMonitor Create an EventHistoryCollector and monitor the corresponding events.
GetUpdates Retrieve updates for a virtual machine or an ESXi host.
GetVirtualDiskFiles Retrieve the virtual disk files from a host’s datastores.
GetVMFiles Download the files in the virtual machine configuration directory as well as the files in the virtual machine snapshot, suspend, and log directories. Write progress to the console.
History Display the performance measurements of a specified counter of a specified ESXi for a specified duration, or 20 minutes (default) at the console.
HostPowerOps Perform reboot, shutdown, or suspend (power off to standby) operations on an ESXi system.
HostProfileManager

Demonstrates HostProfileManager and ProfileComplainceManager.

LicenseManager Display licensing information. The user can specify a license server.
MobStartPage Includes a program, image files, and HTML files for displaying a Managed Object browser.
MoveEntity Move a managed entity from one folder to another.
OneTimeScheduledTask Create a ScheduledTask that powers off a virtual machine and schedules the task using a OnceTaskScheduler. You can delete the task using the DeleteOneTimeScheduledTask cmdlet.
OVFManagerExportVapp

Export VMDK files and OVF descriptors of all virtual machines in the vApp to local disk.
OVFManagerExportVMDK Export VMDK files of a virtual machine to local disk.
OVFManagerImportLocalVapp

Import or deploy an OVF Appliance from the local drive.

PrintCounters Define a printEntityCounters function to print counters for a virtual machine, host, or resource pool.
PropertyCollector Illustrate use of the PropertyCollector.
QueryMemoryOverhead Illustrate use of the QueryMemoryOverhead method. The folder contains example QueryMemoryOverheadV25 using the currently valid QueryMemoryOverheadEx method.
RealTime Display the current performance measurements of selected CPU counters of any specified virtual machine at the console.
RecordSession Record a session that allows you to retrieve a specified set of properties for a specified managed object reference into an array of result objects.
RemoveManagedObject Remove 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 information to the command line.
RemoveVirtualNic Remove a virtual NIC from the ESXi host.
RemoveVirtualSwitch Remove a virtual switch from the vSphere datacenter.
RemoveVirtualSwitchPortGroup Remove a virtual port group from the vSphere datacenter.
RenameEntity Rename a managed entity.
SCSILunName Print the virtual machine file system volumes on a specified SCSI LUN.
SDRSRecommendation Run Storage DRS on a given SDRS cluster and generate a list of recommendations.
SDRSRules Show how to add, list, modify, and delete rules for an existing SDRS cluster.
SearchIndex Illustrate use of the SearchIndex API.
SimpleClient Demonstrate connecting to a service, logging on to service, obtaining service content, and logging out from the service.
SSPI Illustrate how to use an SDK application with Microsoft SSPI.
SSPICIMClient Illustrate how to use a CIM client application with Microsoft SSPI.
TaskList Display currently running tasks and their state.
VMClone Clone a virtual machine.
VMCreate Create a virtual machine.
VMEventHistoryCollectorMonitor Return all events on the latest page in the EventHistoryCollector.
VMotion Validate that migration with vMotion is feasible between two hosts, and perform the migration if hosts are compatible.
VmPowerOps Retrieve a reference to a virtual machine and invoke power operations specified on the command line for that virtual machine.
VMPowerStateAlarm Create 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 Reconfigure a virtual machine by changing its memory, cpu, disk, nic, or cd.
VMSnapshot Perform snapshot operations such as create, revert to, remove, remove all, and so on.
VMware.Binding.WsTrust

Illustrate endpoint behavior that implements the WS-Security protocol for VMware SSO authentication.

VMware.Security.CredentialStore Illustrate use of the VMware credential store.
WatchVM Monitor updates on a virtual machine using the PropertyCollector.
WeeklyRecurrenceScheduledTask Create a task that reboots a virtual machine once a week.
XVCvMotion Migrate (reloate) VM from one vCenter Server to another.
XVMotion

Migrate VM to another datastore using DRS placement recommendations.