Tagged: VBScript

MDT and Webservices – Small bug

Long time no blog…

Working on a move to CM2012 from CM2007, and with that we are trying to move to Webservices instead of client side VBScript.

I found a small bug in MDT (Looked at version 2010U1 and 2012U1 and it’s the same)

You will see this bug if you have a webservice call from CustomSettings where a parameter value have a space (or any other “strange” char).
Since the script ZTIDataAccess.vbs doesn’t URL-encode the parameters some of them will get messed up…

Heres how to fix it:
Search for the text “Handle it appropriately” in ZTIDataAccess.vbs and you can replace the code with this bugfixed version:

' Handle it appropriately
If IsObject(tmpValue) then
	oLogging.CreateEntry "Only the first " & sElement & " value will be used in the web service call.", LogTypeInfo
	tmpArray = tmpValue.Keys
	If UCase(sMethod) = "REST" then
		sEnvelope = sEnvelope & sColumn & " eq '" & tmpArray(0) & "' and "
	Else
' riro Buggfix
' Org: sEnvelope = sEnvelope & sColumn & "=" & tmpArray(0) & "&"
		sEnvelope = sEnvelope & sColumn & "=" & Escape(tmpArray(0)) & "&"
	End if
Else
	If UCase(sMethod) = "REST" then
		sEnvelope = sEnvelope & sColumn & " eq '" & tmpValue & "' and "
	Else
' riro Buggfix
' Org: sEnvelope = sEnvelope & sColumn & "=" & tmpValue & "&"
		sEnvelope = sEnvelope & sColumn & "=" & Escape(tmpValue) & "&"
	End If
End If

As you can see I have just added Escape() to the values. 🙂

Count files in SCCM-inboxes

Working on some problems with old DDR-files and googled up a script that exported count of files to excel… did a small hack to it and it’s a nice-to-have tool.

Set oFSO = CreateObject("Scripting.FileSystemObject")
ListFolders("\\MyServername\SMS_C01\inboxes")

Sub ListFolders(sPath)
	Set oFolder = oFSO.GetFolder(sPath)
	if oFolder.Files.Count <> 0 then
		wscript.echo Left(oFolder.Files.Count & "        ", 6) & vbTab & oFolder.Path
	End if
	For Each oFldr In oFolder.SubFolders
		ListFolders oFldr.Path
	Next
End Sub

Original script: http://myitforum.com/cs2/blogs/dhite/archive/2006/07/23/22467.aspx