Re: Migrating SMS 2.0 content to SMS 2003
- From: MSIGUY <MSIGUY@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 31 May 2005 06:20:08 -0700
Thanks to both of you,
Do you know of any progamatic way of exporting and importing collections or
adverts
"Kim Oppalfens" wrote:
>
> Upon Request script to import/export Queries
>
> '///////////////////////////////////////////////////////////////////////
> ////////
> '// Export All Queries to TXT
> '// Created by: Kim Oppalfens (MVP SMS)
> '///////////////////////////////////////////////////////////////////////
> 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 <35D9B539-638D-4AF3-8E92-7CE7C61E90E8@xxxxxxxxxxxxx>,
> Terri@xxxxxxxxxxxxxxxxxxxxxxxxx says...
> > I found this VBS Script that seems to work part way. This script will
> > generate a .SMS file that can then be used to import into SMS (in Packages,
> > select 'New'| 'Package from Definition'). This script was written for SMS
> > 2.0 but will work for SMS 2003. The only difference is that SMS 2003 will
> > prompt for source files and source directories even though it is defined in
> > the .SMS file. I have not found a way to get around this (I already asked
> > Microsoft if for documentation of the PDF format for SMS 2003, but they only
> > have one form SMS 2.0). Also, I would like to add logic to the script to
> > enumerate all the packages and automatically generate the .SMS files.
> > Currently, the script will export a specified package given the package id.
> > If you can improve on the script, I would appreciate it.
> >
> > '///////////////////////////////////////////////////////////////////////////////
> > '// Export Package to PDF
> > '// Created by: Brian Howson
> > '// Usage: change SmsSite and SmsServer to your site and server
> > '// This script will create a SMS 2.0 .sms file to import somewhere
> > '// at a different site.
> > '// useful for moving Packages from site to site
> > '//
> > '// You can freely use this script so long as you send me a copy of
> > '// all PDF's you export with this script to brian.howson@xxxxxxx :)
> > '//
> > '///////////////////////////////////////////////////////////////////////////////
> > '
> > '
> > 'REGEDIT4
> > '
> > '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MMC\NodeTypes\{3AD39FC7-EFD601D0-BDCF-00A0C909FDD7}
> >
> > \Extensions\SMS_Tools]
> > '
> > '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MMC\NodeTypes\{3AD39FC7-EFD601D0-BDCF-00A0C909FDD7}
> >
> > \Extensions\SMS_Tools\PDFExport]
> > '"Name"="PDFExport"
> > '"Description"="Export Package to PDF"
> > '"CommandLine"="cscript //NoLogo d:\\download\\wsh\\exppdf.vbs ##SUB:__PATH##"
> > '
> > '**Start Encode**
> >
> >
> > ' ##__Path## comes back as:
> > ' \\NJ01TS04\root\sms\site_SDR:SMS_Package.PackageID=SDR0001F
> >
> > Set objArgs = WScript.Arguments
> >
> > if (objArgs.count > 0) then
> > MyPos = InStr(objArgs(0), ":")
> > SmsPath = Left(objArgs(0), MyPos - 1)
>
> --
> Kim Oppalfens
> SMS MVP
>
.
- Follow-Ups:
- Re: Migrating SMS 2.0 content to SMS 2003
- From: Kim Oppalfens
- Re: Migrating SMS 2.0 content to SMS 2003
- References:
- Re: Migrating SMS 2.0 content to SMS 2003
- From: Terri
- Re: Migrating SMS 2.0 content to SMS 2003
- From: MSIGUY
- Re: Migrating SMS 2.0 content to SMS 2003
- From: Terri
- Re: Migrating SMS 2.0 content to SMS 2003
- From: Kim Oppalfens
- Re: Migrating SMS 2.0 content to SMS 2003
- Prev by Date: Re: Clients Not Showing Up
- Next by Date: SMS database maintenance tasks
- Previous by thread: Re: Migrating SMS 2.0 content to SMS 2003
- Next by thread: Re: Migrating SMS 2.0 content to SMS 2003
- Index(es):
Relevant Pages
|