Using a sub-select to find machines that do not have the most recent version of a package.

Many people have blogged about this – how to find machines that don’t have the most recent version of a package installed.

First we write a query to show machines that don’t have the software installed (in this case firefox)
 select SMS_R_System.Name,SMS_R_System.LastLogonUserName
	from SMS_R_System
		inner join SMS_G_System_SYSTEM on SMS_G_System_SYSTEM.ResourceID = SMS_R_System.ResourceId
	where SMS_R_System.Client = 1
		and SMS_G_System_SYSTEM.SystemRole = "Workstation"
		and SMS_G_System_SYSTEM.Name not in (
			select SMS_R_System.Name
			from  SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId
			where SMS_R_System.Client = 1
			and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "Mozilla Firefox%")
Next we write a query to show the machines that have the most recent software installed (this is used in the following query):
select SMS_R_System.Name, SMS_R_System.LastLogonUserName, SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName,
			SMS_G_System_ADD_REMOVE_PROGRAMS.Version
	from  SMS_R_System
		inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId
	where SMS_R_System.Client = 1
		and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "Mozilla Firefox%"
		and SMS_G_System_ADD_REMOVE_PROGRAMS.Version = "3.6.3 (en-US)"
	order by SMS_R_System.Name

Finally we write a query to show machines that aren’t in the query above

	select SMS_R_System.Name, SMS_R_System.LastLogonUserName, SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName, SMS_G_System_ADD_REMOVE_PROGRAMS.Version
	from  SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId
	where SMS_R_System.Client = 1
		and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "Mozilla Firefox%"
		and SMS_R_System.Name not in (
			select SMS_R_System.Name
			from  SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId
			where SMS_R_System.Client = 1
			and SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "Mozilla Firefox%"
			and SMS_G_System_ADD_REMOVE_PROGRAMS.Version = "3.6.3 (en-US)")
order by SMS_R_System.Name

Import the First and Third queries into a collection and we have a collection that shows machines that need the updated package (including machines that don’t have any version of the package installed.)

How I created a “Copy to new item” functionality for a SharePoint list – Part 2

Second part. First Part can be found here. On the second page (NewForm.aspx), I grabbed out of the querystring the values for the source list item and the name of the list.
I used this person’s query string parser.

Then I used the following SOAP query :

$(document).ready(function() {
 var sourceID = getQuerystring('SourceID');
 var listName = getQuerystring('ListName');

 var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
<soapenv:Body> \
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>" + listName + "</listName> \
<viewName>{GUID}</viewName> \
<viewFields /> \
<ViewFields /> \
<query> \
<Query><Where> \
<Eq> \
<FieldRef Name='ID' /> \
<Value Type='Integer'>" + sourceID + "</Value> \
</Eq> \
</Where></Query>\
</query> \
</GetListItems> \
</soapenv:Body> \
</soapenv:Envelope>";

 $.ajax({
 async: false,
 url: "http://site.com/subsite/_vti_bin/lists.asmx",
 type: "POST",
 dataType: "xml",
 data: soapEnv,
 complete: processResult,
 contentType: "text/xml; charset=\"utf-8\""
 });

 });
 function processResult(xData, status) {
 $(xData.responseXML).find("z\\:row").each(function() {
 $("input[title='Input']").val($(this).attr("ows_Input"));
 $("textarea[title='TextArea']").val($(this).attr("ows_TextArea"));
 $("select[title='DropDown']").val($(this).attr("ows_DropDown")).attr("selected", "selected"); 
 }
 )};

In the last three lines I changed the input box, textbox and dropdown boxes to their values in the results fromt the SOAP query.

Kinda fun. Just need to figure out how to do check boxes!

How I created a “Copy to new item” functionality for a SharePoint list – Part 1

I wanted to create a “copy to new item” functionality for a SharePoint list.

Steps I came up with:

  1. The first thing I had to do was add a link to the context menu (I learned that it is called an ECB) and have it point to the NewForm.aspx.
  2. Once I got that, I could append a querystring variable to the url that contained the “Source ID” of the item to copy and the name of the current list.
  3. Then I would grab that querystring value on the other side – in the NewForm.aspx page
  4. Next I would use that variable to query the SharePoint List via SOAP
  5. Inject the results the  into the form

Here is my script (add to a CEWP, I already have the jquery pointers to google in a Delegate control)

<script language="javascript">
function Custom_AddListMenuItems(m, ctx) {
var editURL = window.location.protocol + "//" + window.location.host + ctx.listUrlDir + "/NewForm.aspx?SourceID=" + currentItemID + "&amp;ListName=" + ctx.ListTitle;
 CAMOpt(m, "Copy To New Item" ,"window.location=('" + editURL + "');" , "/_layouts/images/Copy.GIF");
 CAMSep(m);
}
</script>

More to come.

How to add a webpart to a Sharepoint “NewForm.aspx”

I wanted to put a hidden CEWP on top of a standard SharePoint input form (you know when you click “NEW” too add an item to a list). The edit page was grayed out. I added to the querystring “NewForm.aspx?ToolPaneView=2” and I can add the CEWP to the top of the page. Once I added that, the edit page option is no longer grayed out.

BASH (readline) keyboard shortcuts

I was just in training and the instructor was a command line keyboard shortcut wizard. He was magically making words disappear and reappear. So i fond this list of shortcuts. Many of them did not work in my OS X BASH prompt.I fond I had to go into the terminal.app preferences and select “use option key as meta key” on the keyboard tab (it is at the bottom). Now I can add a few shortcuts to my repertoire.

Create a blank floppy image in Mac OSX 10.6

  • dd if=/dev/zero bs=1024 count=1440 > floppy.img
  • Disk Utility -> File -> Open Disk Image -> floppy.img (you will get an error like no mountable filesystems)
  • Select floppy.img in Disk Utility, and the erase tab
  • Select MS-DOS FAT as the format.
  • Eject floppy.img

Install Windows 7 RSAT Silently and Activate All Features

  • wusa /quiet /norestart amd64fre_GRMRSATX_MSU.msu
  • ocsetup RemoteServerAdministrationTools;RemoteServerAdministrationTools-ServerManager;RemoteServerAdministrationTools-Roles;RemoteServerAdministrationTools-Roles-CertificateServices;RemoteServerAdministrationTools-Roles-CertificateServices-CA;RemoteServerAdministrationTools-Roles-CertificateServices-OnlineResponder;RemoteServerAdministrationTools-Roles-AD;RemoteServerAdministrationTools-Roles-AD-DS;RemoteServerAdministrationTools-Roles-AD-DS-SnapIns;RemoteServerAdministrationTools-Roles-AD-DS-AdministrativeCenter;RemoteServerAdministrationTools-Roles-AD-DS-NIS;RemoteServerAdministrationTools-Roles-AD-LDS;RemoteServerAdministrationTools-Roles-AD-Powershell;RemoteServerAdministrationTools-Roles-DHCP;RemoteServerAdministrationTools-Roles-DNS;RemoteServerAdministrationTools-Roles-FileServices;RemoteServerAdministrationTools-Roles-FileServices-Dfs;RemoteServerAdministrationTools-Roles-FileServices-Fsrm;RemoteServerAdministrationTools-Roles-FileServices-StorageMgmt;RemoteServerAdministrationTools-Roles-HyperV;RemoteServerAdministrationTools-Roles-RDS;RemoteServerAdministrationTools-Features;RemoteServerAdministrationTools-Features-BitLocker;RemoteServerAdministrationTools-Features-Clustering;RemoteServerAdministrationTools-Features-GP;RemoteServerAdministrationTools-Features-LoadBalancing;RemoteServerAdministrationTools-Features-SmtpServer;RemoteServerAdministrationTools-Features-StorageExplorer;RemoteServerAdministrationTools-Features-StorageManager;RemoteServerAdministrationTools-Features-Wsrm