public static SystemState GetSystemState(ManagementScope scope, string serverName, string userName, string password, ILogger logger) { try { ManagementScope serverDefaultPath = WMIUtils.ConnectToServerDefaultPath(serverName, userName, password); return(SystemStateReader.GetSystemState(scope, serverDefaultPath, serverName, logger)); } catch (Exception ex) { logger.Verbose("Exception thrown getting the system state for server " + serverName + ". Exception: " + ex.Message, "SystemState"); throw; } }
public static ManagementScope ConnectToServerDefaultPath(string server, NetworkCredential credentials) { string userName = CUtils.CombinUsernameAndDomain(credentials.UserName, credentials.Domain); return(WMIUtils.ConnectToServerDefaultPath(server, userName, credentials.Password)); }