Re: Qryedit and SMS 2003




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
.



Relevant Pages

  • SSIS Script Task Error - Unspecified Error
    ... I have 11 different scripts like for different SMS queries. ... ' Microsoft SQL Server Integration Services Script Task ... Dim Locator As New SWbemLocator ... Dim SMSProviderSitecode As String ...
    (microsoft.public.sqlserver.dts)
  • Re: Distributing Software "Quickly" to Bare Metal Installs
    ... >> Nope, never seen any script like it, I just tought it would be a feasible ... >> ' Script By Kim Oppalfens - MVP SMS ... >> Dim objSWbemServices ... Set objCollection = objSWbemServices.ExecQuery _ ...
    (microsoft.public.sms.swdist)
  • RE: Scripting Export List for a Query
    ... SMS console... ... When I wrote the next script to make an export, using the same query into ... Dim Location ...
    (microsoft.public.sms.misc)
  • Re: Migrating SMS 2.0 content to SMS 2003
    ... Upon Request script to import/export Queries ... '// Created by: Kim Oppalfens (MVP SMS) ... Dim objFSO, WmiQuery, objWmiService, query, colQuery, oFile ... the script will export a specified package given the package id. ...
    (microsoft.public.sms.admin)
  • Re: How to add multiple computers into collection
    ... simplified the SMS administration. ... An alternative would be to build queries that expose the ... Put the following query code in to the respective query ... that script will dump the collection names + ID's ...
    (microsoft.public.sms.admin)

Loading