public Task Install(string identity)
{
//did not use DirectoryEntry to avoid a ref to the DirectoryServices.dll
try
{
if (!ElevateChecker.IsCurrentUserElevated())
{
logger.InfoFormat(@"Did not attempt to add user '{0}' to group '{1}' since the process is not running with elevated privileges. Processing will continue. To manually perform this action, run the following command from an admin console:
net localgroup ""{1}"" ""{0}"" /add", identity, builtinPerformanceMonitoringUsersName);
return TaskEx.CompletedTask;
}
StartProcess(identity);
}
catch (Exception win32Exception)
{
var message = string.Format(
@"Failed adding user '{0}' to group '{1}' due to an Exception.
To help diagnose the problem try running the following command from an admin console:
net localgroup ""{1}"" ""{0}"" /add", identity, builtinPerformanceMonitoringUsersName);
logger.Warn(message, win32Exception);
}
return TaskEx.CompletedTask;
}