Re: Qryedit and SMS 2003
- From: Kim Oppalfens <kim@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 4 Aug 2005 09:19:21 +0200
Yups,
Had the same problem, so I decided to create a quick workaround.
That's it just run the script export to txt, run the script again
Import. You have to specify whether you want the export is meant to be
reimported in sms2003 because the addremprogs table in wmi was modified
to be named add_remove_programs.
Enjoy.
Option Explicit
Dim objArgs, Command, qryfile, Sitecode, strSiteServer
Dim objFSO, WmiQuery, objWmiService, query, colQuery, oFile
Dim Line, queryexpression
Dim qryParameters, newquery
Set objArgs = WScript.Arguments
if (objArgs.count > 2) then
Command = Wscript.arguments.item(0)
Qryfile = Wscript.arguments.item(1)
Sitecode = wscript.arguments.item(2)
If (objArgs.count = 3) then
strSiteServer = "."
Else
strSiteServer = wscript.arguments.item(3)
End If
else
Wscript.echo("Usage: migratequeries.vbs IMPORT|EXPORT20|EXPORT2003
File SITECODE [SITESERVER]")
Wscript.echo("Example: migratequeries.vbs EXPORT2003 c:\expqueries.txt
S01 SMSSVR01")
Wscript.echo("")
Wscript.echo("IMPORT|EXPORT20|Choose whether you want to import or
export queries")
Wscript.echo("EXPORT2003, EXPORT20 will export to format for
reimporting to sms 2.0")
Wscript.echo(" EXPORT2003 will export to format for
reimporting to sms 2003")
Wscript.echo("File, Filename of the textfile where to
import/export queries")
Wscript.echo(" to/from")
Wscript.echo("SITECODE, 3-char SMS sitecode of the site for which you
want to ")
Wscript.echo(" import/export queries")
Wscript.echo("SITESERVER, Name of the SMS siteserver you want to
export packages from.")
Wscript.echo(" Default is Local Server")
Wscript.Quit(1)
end if
Set objFSO = Createobject ("Scripting.filesystemobject")
If ucase(command) = "EXPORT20" OR ucase(command) = "EXPORT2003" Then
WmiQuery = "select * from sms_query where limittocollectionid = " & CHR
(34) & CHR(34) & _
"And queryid like " & CHR(34) & sitecode & "%" & CHR(34)
Set objWMIService = GetObject ("Winmgmts:
{impersonationlevel=impersonate}!\\" & _
strSiteServer & "\root\sms\site_" & sitecode)
Set colquery = objWMIService.Execquery(wmiQuery)
Set oFile = objFSO.CreateTextFile(qryfile,TRUE)
For Each query in colquery
If ucase(command) = "EXPORT20" Then
queryexpression = query.Expression
Else
queryexpression = replace
(query.Expression,"SMS_G_System_ADDREMPROGS","SMS_G_System_ADD_REMOVE_PR
OGRAMS")
End If
line = query.name & ";" & _
query.comments & ";" & _
query.limittocollectionid & ";" & _
query.TargetClassname & ";" & _
queryexpression
Wscript.echo line
ofile.WriteLine Line
Next
ofile.close
End If
If ucase(command) = "IMPORT" Then
set objfso = Createobject ("Scripting.filesystemobject")
Set ofile = objfso.opentextfile (qryfile,1)
Set objWMIService = GetObject ("Winmgmts:
{impersonationlevel=impersonate}!\\" & _
strSiteServer & "\root\sms\site_" & sitecode)
Do While NOT ofile.atendofstream
line = ofile.readline
QryParameters = Split (line,";",-1,1)
Set newquery = objWMIService.get("SMS_Query").SpawnInstance_()
newquery.name = Qryparameters(0)
newquery.comments = Qryparameters(1)
newquery.limittocollectionid = Qryparameters(2)
newquery.TargetClassname = Qryparameters(3)
newquery.Expression = Qryparameters(4)
newquery.put_
WScript.echo newquery.name & " was imported"
Loop
ofile.close
End if
In article <6210D373-765E-4170-8694-994E6891CC6B@xxxxxxxxxxxxx>,
WernerDeKuyffer@xxxxxxxxxxxxxxxxxxxxxxxxx says...
> Hi,
>
> When I try to use the SMS 2.0 Resource Kit utility Qryedit.exe to import
> user defined queries from an SMS 2.0 site into an SMS 2003 site, I get the
> following error:
>
> Cannot get a SQL connection
>
> Can someone explain me what I' m doing wrong?
>
> Kind regards,
> Werner
>
--
Kim Oppalfens
MVP SMS
Computacenter Belgium
.
- References:
- Qryedit and SMS 2003
- From: Werner De Kuyffer
- Qryedit and SMS 2003
- Prev by Date: Re: Making a purchasing decision on SMS
- Next by Date: Can you schedule SMS software(& update) installs
- Previous by thread: Qryedit and SMS 2003
- Next by thread: RE: Making a purchasing decision on SMS
- Index(es):
Relevant Pages
|
Loading