Script variable trimming
Posted on May 8th, 2009
Suppose you are trying to run some scripts based on a command line variable, but the variable being passed to it is surrounded by quote marks.
i.e. “device_name” when all i want is device_name
There is an easy way to trim this. In the script need to set this passed variable to a seperate variable, and then trim it byt doing the following:
SET tempvariable=%1 (need to set %%1 if its run as a script file)
echo %1 (will show “device_name”)
echo %tempvariable% (will show “device_name”)
echo %tempvariable:~1,-1% (will show device_name)
The trimmed variable can then be used for another task, i.e. to start a service on a remote server
sc \\%tempvariable:~1,-1% start “ServiceName”
Happy trimming!
Tags: ", %1, clean, cmd, device_name, edgesight, remove, sc, script, set, trimming, variable
Filed under Scripts/Reg | 1 Comment »
Script to export all the servers in a Citrix Farm
Posted on April 27th, 2009
Sometimes it is useful to have a list of servers in a text file in order to perform some other task. The following script will export all servers from a Citrix Farm and add them to a text file.
This script uses the built in Citrix tool, qfarm, and cleans up the output to provide the required list. It uses a temporary file (qfarmservers.txt) during the process and deletes it at the end.
REM ***************************************************
REM qfarmservers = output from a qfarm /servers
REM serverlist = cleaned up list of all servers in farm
REM ***************************************************SET qfarmservers=c:\windows\temp\qfarmservers.txt
SET serverlist=c:\windows\temp\serverlist.txtqfarm /servers >>%qfarmServers%
for /f “skip=3 tokens=1″ %%1 in (%qfarmservers%) do (
echo %%1 >> %serverlist%
)
Del %qfarmservers% /q
Just change the log file location(s) as required.
Tags: Citrix, export, Presentation Server, qfarm, script, server, serverlist, servers, text, XenApp
Filed under Scripts/Reg | 1 Comment »
MFCOM script to export the current users of an application
Posted on April 27th, 2009
Sometimes is is necessary to have a list of users in a text file of which other scripts can be run. In this case I wanted a list of all users currently logged into a specific Citrix application in order to perform some other task.
The following MFCOM script will export all the users currently logged into a specified application and export them to a text file.
Set objFarm = CreateObject(“MetaFrameCOM.MetaFrameFarm”)
Dim ObjFSO, Objuserlist
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set Objuserlist = objFSO.OpenTextFile(“c:\windows\temp\userlist.log”, 8, True)objFarm.Initialize(1)
For Each objSession In objfarm.Sessions
if objsession.appname = (“My Application Name”) then
objuserlist.WriteLine(objSession.UserName)
End IF
NextWScript.Echo “userlist created here – c:\windows\temp\userlist.log”
Substitute “My Application name” and the log file location as appropriate.
Save this as a .vbs file and run.
Tags: Citrix, export, list, mfcom, Presentation Server, scipt, user, vb
Filed under Scripts/Reg | 1 Comment »
How to export the users of an AD Group.
Posted on January 23rd, 2009
This is the best and fastest way to export all users who are members of a group
dsquery group “CN=Group Name,OU=OU Location,DC=Domain Name,DC=local” | dsget group -members | dsget user -samid -c >>c:\windows\temp\groupmembers.txt
If there are nested groups it might fail with the following error message:
The object class of the target does not match the one specified on the command line.
This error is removed by adding the -c variable as this continues despite the error.
Tags: AD, dsget, dsquery, export, group extraction, script, users
Filed under Scripts/Reg | No Comments »
Resultant Set of Policy/gpresult: access denied error message
Posted on October 16th, 2008
When running a Resultant Set of Policy from the Group policy management Console (GPMC) the following error is displayed:
Also, the following ‘access denied’ error appears when running gpresult.exe from a command prompt on the server:
Running on other servers seems okay, but on these specific servers there is a problem.
Resolution
This can be resolved by doing the following:
cmd
c:
cd\windows\system32regsvr32 /n /I userenv.dll
cd\windows\system32\wbem
mofcomp scersop.mofgpupdate /force
Tested as working on Windows 2003 x64 Enterprise Edition. (and it doesn’t even need a reboot)
Tags: access denied, error, gpmc, gpresult, rsop, wmi
Filed under Scripts/Reg, Windows 2003 | 4 Comments »


