Ejemplo n.º 1
0
 private static bool HaveAccessToServer(ServerConfig server)
 {
     Logger.Info(string.Format("Checking if WMI can be used to reach remote server [{0}]...", server.Name));
     var success = false;
     try
     {
         var registry = new RemoteRegistry(server.Name, server.DeploymentUser.UserName, server.DeploymentUser.Password);
         string windowsName;
         success = registry.TryGetStringValue(RegistryHive.LocalMachine, @"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName", out windowsName);
         if(success)
         {
             Logger.Info(string.Format("Contact was made with server [{0}] using WMI. Server is {1}.", server.Name, windowsName));
         }
         else
         {
             Logger.Error(string.Format("Unable to reach server [{0}] using WMI", server.Name));
         }
     }
     catch(UnauthorizedAccessException accessException)
     {
         Logger.Error(string.Format("Unable to access remote server [{0}] using WMI. Unauthorized Access Exception reported. Please check your credentials.", server.Name), accessException);
         return false;
     }
     catch(Exception ex)
     {
         Logger.Error(string.Format("Unable to access remote server [{0}] using WMI.", server.Name), ex);
         return false;
     }
     return success;
 }
Ejemplo n.º 2
0
        private static bool HaveNet40(ServerConfig server)
        {
            try
            {
                Logger.Info(string.Format("Checking if WMI can be used to check if .NET Framework 4.0 is installed on server [{0}]...", server.Name));
                var registry = new RemoteRegistry(server.Name, server.DeploymentUser.UserName, server.DeploymentUser.Password);

                int dotNet40Installed;
                var success = registry.TryGetDWordValue(RegistryHive.LocalMachine, @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full", "Install", out dotNet40Installed);
                if (!success || dotNet40Installed != 1)
                {
                    Logger.Error(string.Format("Missing Microsoft .NET Framework version 4.0 on [{0}].", server.Name));
                    return false;
                }

                Logger.Info(string.Format("Microsoft .NET Framework version 4.0 is installed on server [{0}].", server.Name));
                return true;
            }
            catch(Exception ex)
            {
                Logger.Error(string.Format("Unable to access remote server to check for .NET Framework 4.0 on server [{0}] using WMI.", server.Name), ex);
                return false;
            }
        }