<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>James&#039; Tools and Tricks &#187; Bulk Operations</title>
	<atom:link href="http://jrudd.org/tag/bulk-operations/feed/" rel="self" type="application/rss+xml" />
	<link>http://jrudd.org</link>
	<description>Tools, Tips and Hints for managing a network.</description>
	<lastBuildDate>Sun, 15 Aug 2010 23:11:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>HP Printers &#8211; &#8220;Printer driver is not installed&#8221; on Windows 2008 R2</title>
		<link>http://jrudd.org/2010/05/hp-printers-printer-driver-is-not-installed-on-windows-2008-r2/</link>
		<comments>http://jrudd.org/2010/05/hp-printers-printer-driver-is-not-installed-on-windows-2008-r2/#comments</comments>
		<pubDate>Mon, 17 May 2010 00:59:05 +0000</pubDate>
		<dc:creator>James Rudd</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[Bulk Operations]]></category>
		<category><![CDATA[hp printers]]></category>
		<category><![CDATA[HPTrayCount]]></category>
		<category><![CDATA[microsoft windows]]></category>
		<category><![CDATA[print management]]></category>
		<category><![CDATA[print servers]]></category>
		<category><![CDATA[printer driver]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[server 2008 R2]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://jrudd.org/wordpress/?p=134</guid>
		<description><![CDATA[Recently I migrated all our printers from a Server 2003 R2 x32 print server to Server 2008 R2 (x64). During this upgrade all the printers had x64 drivers added and their security settings checked. However, I kept experiencing problems in Print Management with the HP printers reporting the Printer driver is not installed, even after <a href='http://jrudd.org/2010/05/hp-printers-printer-driver-is-not-installed-on-windows-2008-r2/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Recently I <a href="http://trycatch.be/blogs/roggenk/archive/2008/05/13/windows-server-2008-printer-migration-and-consolidation.aspx">migrated all our printers</a> from a <a href="http://xmstechnology.glve.be/archives/41">Server 2003 R2 x32 print server to Server 2008 R2 (x64)</a>. During this upgrade all the printers had x64 drivers added and their security settings checked. However, I kept experiencing problems in Print Management with the HP printers reporting the <em>Printer driver is not installed</em>, even after it had been repeatedly added and appeared in list of installed drivers.</p>
<p>Finally I found a <a href="http://social.technet.microsoft.com/Forums/en/winserverprint/thread/5101195b-3aca-4699-9a06-db4578614e2d">Technet discussion</a> on the issue, which correctly identified an incorrect registry value <em>HPTrayCount </em>which is set to 0 when the printer driver is changed, but is not set back to a working value.</p>
<p>This value needs to be changed to 0&#215;12 (decimal 18) for each HP printer for it to work correctly. However, on print servers with lots of HP printers this can be very time consuming. To speed this process I have written the vbscript below which will check if the value exists for each printer, and if it is set to 0 will set it to 0&#215;12.</p>
<pre class="brush: vb;">
' For each Printer in Registry check if HPTrayCount exists and is set to 0, then set to 12

'http://social.technet.microsoft.com/Forums/en/winserverprint/thread/5101195b-3aca-4699-9a06-db4578614e2d

strKeyPath = &quot;SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers&quot;
strValueName = &quot;HPTrayCount&quot;
inHPValue = 18 ' Is equal to Hex 12, makesprinter driver work.

'http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/registry/#EnumRegVals.htm
const HKEY_LOCAL_MACHINE = &amp;H80000002
strComputer = &quot;.&quot;
Set StdOut = WScript.StdOut

Set oReg=GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; &amp; _
strComputer &amp; &quot;\root\default:StdRegProv&quot;)

' Get list of Printers
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

For Each subkey In arrSubKeys
  ' Read in HP Tray value
  strPrintPath = strKeyPath &amp; &quot;\&quot; &amp; subkey &amp; &quot;\PrinterDriverData&quot;
  oReg.GetDWORDValue HKEY_LOCAL_MACHINE,strPrintPath,strValueName,dwValue
  If Not IsNull (dwValue) And dwValue = 0 Then
    'If Exists and 0 then set it to a real value to make it work
    StdOut.WriteLine subkey &amp; &quot;: HP Tray: &quot; &amp; dwValue
    oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strPrintPath,strValueName,inHPValue
  End If
Next
</pre>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 620px; width: 1px; height: 1px; overflow: hidden;">
<pre></pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jrudd.org/2010/05/hp-printers-printer-driver-is-not-installed-on-windows-2008-r2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some useful Moodle SQL Queries</title>
		<link>http://jrudd.org/2007/12/some-useful-moodle-sql-queries/</link>
		<comments>http://jrudd.org/2007/12/some-useful-moodle-sql-queries/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 14:28:55 +0000</pubDate>
		<dc:creator>James Rudd</dc:creator>
				<category><![CDATA[Moodle]]></category>
		<category><![CDATA[Bulk Operations]]></category>
		<category><![CDATA[Delete]]></category>
		<category><![CDATA[Roles]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Statistics]]></category>

		<guid isPermaLink="false">http://jrudd.org/wordpress/2007/12/15/some-useful-moodle-sql-queries/</guid>
		<description><![CDATA[I occasionally use the following SQL statements to clean-up our Moodle system and identify old courses. I recommend backing up your database before using any and knowing enough SQL to understand what they are doing before running them. I usually use phpMyAdmin for execution and export, but use what ever works best for you. Find <a href='http://jrudd.org/2007/12/some-useful-moodle-sql-queries/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I occasionally use the following SQL statements to clean-up our Moodle system and identify old courses. I recommend backing up your database before using any and knowing enough SQL to understand what they are doing before running them. I usually use <a href="http://www.phpmyadmin.net/" target="_blank">phpMyAdmin</a> for execution and export, but use what ever works best for you.</p>
<h2>Find Empty Moodle Courses</h2>
<p>If you use an auto-enrolment module you will often find you have lots of courses created that are never used. We have used the LDAP and Database enrolment before and both have created large numbers of courses. Some are not used by teachers,others are just used as child courses for year wide meta courses. Either way at the end of the year you may wish to identify any class that hasn&#8217;t been used. (Perhaps to delete using the <a href="http://jrudd.org//2007/12/14/moodle-bulk-deletion-operations/" target="_blank">Bulk Deletion</a> options).</p>
<h3>No Content</h3>
<p>Following SQL code I&#8217;ve written will generate a list containing a sum of most of the resources and activities a course has, allowing you to quickly identify those with little to no content. It bases this count on having no labels, resources, assignments, etc.</p>
<pre class="brush: sql;">
SELECT m.id, m.`shortname` , m.fullname, cCount.totalcount
FROM mdl_course m
LEFT JOIN (

SELECT courseCount.course, sum( courseCount.subcount ) AS totalcount
FROM (

SELECT course, count( * ) AS subcount
FROM mdl_resource
GROUP BY course
UNION ALL SELECT course, count( * ) AS subcount
FROM mdl_quiz
GROUP BY course
UNION ALL SELECT course, count( * ) AS subcount
FROM mdl_assignment
GROUP BY course
UNION ALL SELECT course, count( * ) AS subcount
FROM mdl_survey
GROUP BY course
UNION ALL SELECT course, count( * ) AS subcount
FROM mdl_label
GROUP BY course
UNION ALL SELECT course, count( * ) AS subcount
FROM mdl_glossary
GROUP BY course
UNION ALL SELECT course, count( * ) AS subcount
FROM mdl_homework
GROUP BY course
UNION ALL SELECT course, count( * ) AS subcount
FROM mdl_wiki
GROUP BY course
) AS courseCount
GROUP BY courseCount.course
) AS cCount ON cCount.course = m.id
</pre>
<p>You may need to edit above code if you do not have an activity installed (eg homework).</p>
<h3>No Users</h3>
<p>The following code generates a list of all your courses together with how many students are enrolled in each. Useful to find out if you have any courses with no one enrolled.</p>
<pre class="brush: sql;">

SELECT cr.shortname, cr.fullname, count( ra.id ) AS enrolled
FROM `mdl_course` cr
JOIN `mdl_context` ct ON ( ct.instanceid = cr.id )
LEFT JOIN `mdl_role_assignments` ra ON ( ra.contextid = ct.id )
WHERE ct.contextlevel =50
GROUP BY cr.shortname, cr.fullname
ORDER BY `enrolled` ASC
</pre>
<p>You can export either of the above queries into Excel and manipulate it from there. Order by the counts then copy the short names&#8217; of courses to delete, paste into a text file and upload to the <a href="http://jrudd.org//2007/12/14/moodle-bulk-deletion-operations/" target="_blank">Bulk Course Deletion</a> addon. Goodbye excess courses.</p>
<h2>Data Cleanup: Roles without Users</h2>
<p>Sometimes when a user gets deleted Moodle doesn&#8217;t clean up after it self as well as it should. The following code will list all the rows in your <span class="syntax"><span class="syntax_quote syntax_quote_backtick">role assignments </span></span>table that no longer match to a user:</p>
<pre class="brush: sql;">SELECT *
FROM `mdl_role_assignments`
WHERE `userid` NOT
IN (
SELECT id
FROM mdl_user
)
</pre>
<p>If you wish to the delete all of these just run following. As always make sure you have a good backup before deleting anything from DB.</p>
<pre class="brush: sql;">DELETE
FROM `mdl_role_assignments`
WHERE `userid` NOT
IN (
SELECT id
FROM mdl_user
)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jrudd.org/2007/12/some-useful-moodle-sql-queries/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Moodle: Bulk Deletion Operations</title>
		<link>http://jrudd.org/2007/12/moodle-bulk-deletion-operations/</link>
		<comments>http://jrudd.org/2007/12/moodle-bulk-deletion-operations/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 00:30:32 +0000</pubDate>
		<dc:creator>James Rudd</dc:creator>
				<category><![CDATA[Moodle]]></category>
		<category><![CDATA[Bulk Operations]]></category>
		<category><![CDATA[Delete]]></category>

		<guid isPermaLink="false">http://jrudd.org/wordpress/2007/12/14/moodle-bulk-deletion-operations/</guid>
		<description><![CDATA[At the recent CC day some people asked about bulk deletion of users and courses. Moodle 1.9 beta now supports bulk user operations, such as deleting, sending messages or confirming the account. You can use a filter to easily select the users you want. The Filter allows selection based on everything from name, last access, <a href='http://jrudd.org/2007/12/moodle-bulk-deletion-operations/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>At the recent CC day some people asked about bulk deletion of users and courses.<br />
<a href="http://docs.moodle.org/en/Release_Notes#Moodle_1.9_Beta" target="_blank">Moodle 1.9 beta</a> now supports bulk user operations, such as deleting, sending messages or confirming the account. You can use a filter to easily select the users you want. The Filter allows selection based on everything from name, last access, role, authentication system (manual, LDAP, etc.) to email as well as many other options. Hopefully it will be upgraded in the future to allow filtering by other user attributes such as ID number, Departments, Institution or the new attributes that can be added to users. For Bulk Deletion of courses there is a <a href="http://moodle.org/file.php/5/moddata/forum/33/367033/delete_course_for_1.7-1.8---v1.zip" target="_blank">php</a> file posted by <a href="http://moodle.org/mod/forum/discuss.php?d=82932#p367033" target="_blank">Jeff Church</a> which you can place somewhere in your Moodle installation and run manually to delete your courses. It takes a text file of the courses’ short names to delete, then confirms what to remove before deleting them all. I ran it recently to remove 323 courses from 2005-2006 and it removed them with no problems.</p>
<p>For some useful SQL queries that can be used to identify unused courses please see <a href="http://jrudd.org//2007/12/15/some-useful-moodle-sql-queries/">Some useful Moodle SQL Queries.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jrudd.org/2007/12/moodle-bulk-deletion-operations/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
