Sunday, October 14, 2012

Enable/Disable logons of Citrix Servers using script.

Login to any citrix server and save the below script. I saved as Serverlogons.wsf.
Copy the server names in txt file and save. I saved as Servers.txt

I saved both the files on desktop.

In the citrix server go the script path and run in the cmd as follows:

cscript Serverlogons.wsf e Servers.txt -> for enable logons.
cscript Serverlogons.wsf d Servers.txt -> for disable logons.

_________________________________________________________________________________
<package>
<job id="Servers">
<comment>
File: ServerLogin.wsf
Description: Enable disable  Server Logins
Requirements: WSH 5.5 or higher.

</comment>
<runtime>
<description>
Description: Enable disable  Server Logins
</description>
<example>
CScript //nologo ServerLogons.wsf
</example>
</runtime>
<reference object="MetaFrameCOM.MetaFrameFarm"/>
<script language="VBScript">
Dim theFarm, aServer, choice , Found, CFound , ServerName
''If no command line argument
             if  WScript.Arguments.Count <> 2 Then
               WScript.Echo "USAGE To Enable Logins :  ServerLogons.wsf e Filename"
               WScript.Echo "USAGE To disable Logins : ServerLogons.wsf d filename"
               WScript.Echo ""
               WScript.Echo "Example to enable logins:  ServerLogons.wsf e filename"
               WScript.Quit 0
            Else
               
               
                choice    = WScript.Arguments(0) ' store the flag to enable or diable
                sFileName = WScript.Arguments(1) ' store the server name ..
                Found      = false ' store bool server found or not
                CFound     = false ' store bool choice found or not
                WScript.Echo ""
            End If

Set oFso = CreateObject("Scripting.FileSystemObject")
  
    if Err.Number <> 0 Then
               WScript.Echo "Can't create FileSystemObject "
                WScript.Echo "(" & Err.Number & ") " & Err.Description
                WScript.Echo ""
                WScript.Quit Err.Number
            End if
           
           
''****** Get the Script Path Name  ******************************
sScriptFullName = WScript.ScriptFullName
sScriptPath = Left(sScriptFullName, InStrRev(sScriptFullName, "\"))
' Create MetaFrameFarm object
'

Set theFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
if Err.Number <> 0 Then
WScript.Echo "Can't create MetaFrameFarm object"
WScript.Echo "(" & Err.Number & ") " & Err.Description
WScript.Echo ""
WScript.Quit Err.Number
End if
'
' Initialize the farm object.
'
theFarm.Initialize(MetaFrameWinFarmObject)
if Err.Number <> 0 Then
WScript.Echo "Can't Initialize MetaFrameFarm object"
WScript.Echo "(" & Err.Number & ") " & Err.Description
WScript.Echo ""
WScript.Quit Err.Number
End if
'
' Are you Citrix Administrator?
'
if theFarm.WinFarmObject.IsCitrixAdministrator = 0 then
WScript.Echo "You must be a Citrix admin to run this script"
WScript.Echo ""
WScript.Quit 0
End If
'
' Print out the farm name.
'
WScript.Echo "MetaFrame Farm Name: " & theFarm.FarmName
WScript.Echo ""

Const ForReading = 1
Set oStream = oFSO.OpenTextFile(sScriptPath & sFilename, ForReading)
Wscript.Echo " Trying to read .. " & sScriptPath  & sFilename
If Err.Number <> 0 Then
LogFile.Writeline "Can't open ini file for reading "
LogFile.Writeline "(" & Err.Number & ") " & Err.Description
LogFile.Writeline ""
End if
'*****************************

Do Until oStream.AtEndOfStream

 sLine = oStream.ReadLine
 Wscript.Echo "processing : " & sLine

 ServerName=sLine


For Each aServer In theFarm.Servers
if Err.Number <> 0 Then
WScript.Echo "Can't enumerate servers"
WScript.Echo "(" & Err.Number & ") " & Err.Description
WScript.Echo ""
WScript.Quit Err.Number
End if

if ucase(aServer.ServerName)=ucase(ServerName) then
     
  Found = true

     if (choice="e") or (choice="E") then
     CFound = true
     aServer.WinServerObject3.EnableLogon=1

     if Err.Number <> 0 Then
  WScript.Echo "Did not enable logins on " & aServer.ServerName
  WScript.Echo "(" & Err.Number & ") " & Err.Description
  WScript.Echo ""
  End if
     WScript.Echo "Enabled logon "
   
     End if
     if (choice="d") or (choice="D") then
  CFound = true
      aServer.WinServerObject3.EnableLogon=0
    
     if Err.Number <> 0 Then
  WScript.Echo "Did not disable logins on " & aServer.ServerName
  WScript.Echo "(" & Err.Number & ") " & Err.Description
  WScript.Echo ""
  End if
 
       WScript.Echo "Disabled logon "
     
     
    
     End if
    
   
end if


Next
If Found = false  then
WScript.Echo "Server Name not found ..."
End if
If CFound = false  then
WScript.Echo "Invalid Argument .... Please use ( e or d ) to enable or disable logons "
End if

Loop

WScript.Echo "Press ENTER to exit..."
WScript.StdIn.Read(1)
</script>
</job>
</package>

Monday, September 3, 2012

Troubleshooting steps to resolve the issue : Citrix XML service is not running.

Please proceed with the following steps, if you get below error while starting the XML service.

“Some services stop automatically if they have no work to do.....”

1.       Go to Citrix AMC->Server->Properties->XML Service. See the port details:

Ex: For server ServerA.

Here Port 8008 is configured for Citrix XML service.


               

2.       Go to the server and run the command “netstat -p tcp –ano” in command prompt to determine which application or service is using the Port.

Ex: For server ServerA.

Here the Port 8008 is already in use by nsrexecd.exe process. Hence, unable to start it.
Please see the below screenshots.

Output for command : netstat -p tcp –ano

               
               

                Output for command : Tasklist

               
               

3.       To resolve the issue, either we need to reboot the server or need to kill the process.

Thursday, May 17, 2012

Issue on upgrading to Rollup Pack 6 (R06) from Rollup Pack 4 (R04)

After upgrading to Rollup Pack 6 (R06) from Rollup Pack 4 (R04) or some other Rollup pack, users are facing issues in initializing application. Citrix has addressed this issue and the same has been overcome in later Rollup pack 7 (R07).

As a workaround, we can replace the R06 dll files (“icammdrv.dll” and “icammdrv64.dll”) with R04 dll files (“icammdrv.dll and “icammdrv64.dll”).

Unable to Start Citrix IMA service, SMA service and MFCOM service.

Unable to Start Citrix IMA service, SMA service and MFCOM service.

MFCOM and IMA Service fail to start because the IPSEC Service is set to Disabled or stopped.

To resolve this please complete the following:

1. Stop the mfcom.exe service by using the Task Manager.
2. Set the IPSEC Service to Automatic and restart it.
3. Start the IMA Service and the MFCOM Service.

If unable to start the IPSEC service and it triggerss an event with a description that The IPSec driver has entered Block mode.

Then do the following:

1. Delete the subkey under HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\IPSec\Policy\Local

2. Then register the polstore.dll library with the command regsvr32 polstore.dll in Command prompt.

See http://support.microsoft.com/kb/912023 for reference.

If the IPSEC is not found under the HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows.

Then just register the polstore.dll library with the command regsvr32 polstore.dll in Command prompt.

You will be able to bring the IPSEC service back online.

After the IPSEC service is online, then start the Citrix IMA service, SMA service and MFCOM service.

Tuesday, March 6, 2012

Secure Gateway 3.0 Service Initialization Hangs - Users Cannot Connect Unless the Service is Manually Restarted

Symptoms
 
When a server containing Secure Gateway 3.0 is restarted, the Secure Gateway Service does not appear to start completely and users connecting may receive an Error (SSL Error 4, or similar) and cannot connect.
If the Secure Gateway Service process (CtxSGSvc.exe) is terminated manually and the Secure Gateway Service is restarted, the Secure Gateway works correctly until the server is restarted again.
After a restart the same behavior is observed.

Cause

An issue has been identified where starting certain third-party applications, based on Apache Web server (for example, System Management Homepage, version 7.5 from Hewlett-Packard), causes processes required by Secure Gateway 3.0 to terminate. The application replaces the process with the third-party version of the process.
The process in question is RotateLogs.exe, and in a normal setup of Secure Gateway 3.0 there should be five instances of this process running.
It can be verified that the third-party application has terminated the Secure Gateway specific processes by using Process Explorer (from Sysinternals.com at http://www.microsoft.com/technet/sysinternals/utilities/ProcessExplorer.mspx). The parent of the RotateLogs.exe process is the third-party software.
If the third-party software is disabled before the server is restarted, the issue does not occur.

Workaround

As this issue is caused by third-party software, it is recommended to contact the technical support team of the relevant software vendor for a permanent fix.
Citrix Technical Support suggests the following workaround as a temporary solution until the third-party software vendor can support a permanent fix for their application:
  1. Locate the rotatelogs.exe file for Secure Gateway. This file is normally located in the C:\Program Files\Citrix Secure Gateway\bin folder.
  2. Rename the rotatelogs.exe executable (for example, rotate.exe).
  3. Open the http.conf file located in the C:\Program Files\Citrix\Citrix Secure Gateway\conf folder. To do so, perform the following procedure:
    1. Open a command prompt window.
    2. Navigate to the C:\Program Files\Citrix\Citrix Secure Gateway\conf folder from within the command prompt.
    3. In the command prompt window, type notepad httpd.conf to open the httpd.conf file.
      Note
      : The httpd.conf file is hidden. You cannot open the file unless you use a text editor.
  4. Create a backup of the file (for example, httpd.conf.bak).
  5. Modify the httpd.conf file and replace rotatelogs.exe with the new executable name (for example, rotate.exe).
  6. Restart Secure Gateway (for the new changes to take effect. Process Explorer should reflect the new changes).
  7. After performing the changes, set the HP Management Homepage Service to Automatic (or the other third-party application).
  8. Restart the system and test against the problem.

The Secure Gateway Management Console Shows a Session Established in 1969

Symptoms
You experience the following symptoms:
  • The Secure Gateway Management Console shows a session established on December 31, 1969 (12/31/1969)
  • There is no information under the Client IP, User, or Domain headings.
  • The Time Elapsed heading shows 13696 days or more
  • New users receive a SSL 4 connection error or their connections hang, but existing users may not experience any issues
  • The server has been running for a while and has NOT been restarted recently
Refer to the following screen shot:

Cause
Initial analysis seems to indicate that one or more of the rotatelogs.exe processes has terminated or is being used by another application that also uses Apache (for example, hpsmhd.exe). There should be five rotatelogs.exe processes running.
Note: Citrix Technical Support manually terminated all file rotatelogs.exe processes as a test. The Secure Gateway Service could not be restarted without restarting the server.
Workaround
Restart the Secure Gateway Service and/or the entire server.

Data Store Grace Period Explained

"A subset of data store information, the local host cache, exists on each server in the farm, providing each member server with quick access to data store information. The local host cache also provides redundancy of the data store information, if for example, a server in the farm loses connectivity to the data store. In such a situation, the server can continue to function because it can access its local host cache for configuration information for a period up to 96 hours."
 
Since the MetaFrame Presentation Server 3.0 Administrator’s Guide has been published, the grace period for the data store has been removed in MetaFrame Presentation Server 3.0.

Data Store Offline

There are two items worth noting:

1. The data store being offline for over 96 hours will not prevent users from connecting to a MetaFrame Presentation Server 3.0 or later server. The MetaFrame server maintains an independent connection to the license server and will only deny connections if this link is broken for over 30 days.

2. A data store outage will not prevent IMA from starting after a reboot; however it will take a bit longer than normal to start loading the IMA plug-ins while the server is detecting that the data store is offline.

Note: The MetaFrame server must make an initial connection to the data store right after installation in order to know who the license server is.

It is important to note that while the data store is down, MetaFrame administrators will not be able to edit any configurations in the Management Console (such as publishing applications) and new MetaFrame Presentation Servers cannot be added to the farm.