Delete Device (C# code sample)
Problem this snippet solves:
This C# client code sample uses Enterprise Manager's device inventory to delete a list of devices managed by the referenced Enterprise Manager.
Code :
using System;
using iControl;
/**
* A class for testing the Management::EM::delete_devices iControl interface.
*/
class ManagementEMDeleteDevices {
private static int MIN_ARGS = 3;
private static string USAGE =
"ManagementEMDeleteDevices " +
"[]";
private static int EM_PORT = 443;
/**
* The main method.
*
* @param args command line arguments
*/
static void Main(string[] args)
{
if (args.Length < MIN_ARGS) {
Console.WriteLine("Usage: " + USAGE);
Environment.Exit(1);
}
string emAddress = args[0];
string emUsername = args[1];
string emPassword = args[2];
String[] deviceAddresses = new String[args.Length - MIN_ARGS];
for (int i = 0; i < deviceAddresses.Length; i++) {
deviceAddresses[i] = args[i + MIN_ARGS];
}
try {
Interfaces ic = new Interfaces();
ic.initialize(emAddress, EM_PORT, emUsername, emPassword);
ic.ManagementEM.delete_devices(deviceAddresses);
}
catch (Exception e) {
Console.WriteLine("Failed to delete devices: " + e.Message);
Environment.Exit(1);
}
Console.WriteLine("Device(s) deleted.");
} // Main
} // class ManagementEMDeleteDevices Published Mar 07, 2015
Version 1.0CodeCentral_194
Cirrostratus
Joined May 05, 2019
CodeCentral_194
Cirrostratus
Joined May 05, 2019
No CommentsBe the first to comment