myITforum.com Community Forum myITforum.com Community Forum

Home  Forums  Blogs  Live Support chat  Search Articles  Wiki  FAQ  Email Lists  Register  Login  My Profile  Inbox  Address Book  My Subscription  My Forums 

Photo Gallery  Member List  Search  Calendars  FAQ  Ticket List  Log Out

All Forums RSS Feed Subscription:


  


Copy Package to another SCCM site

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
  Printable Version
All Forums >> [Management Products] >> System Center Products >> System Center Configuration Manager >> Copy Package to another SCCM site Page: [1]
Login
Message << Older Topic   Newer Topic >>
Copy Package to another SCCM site - 11/19/2008 8:41:19 AM   
pteilloux

 

Posts: 34
Score: 0
Joined: 7/3/2002
Status: offline
Hi,

I would copy some package from a SCCM site to another SCCM site, does anywhone knows a script to make this ?
I have a SCCM site xxx for my test and i want to copy the package of this site to my production site yyy.

Thanks.
Post #: 1
RE: Copy Package to another SCCM site - 11/19/2008 8:51:50 AM   
hcortez463


Posts: 793
Score: 65
Joined: 4/8/2005
Status: offline
if its just a few packages i would just recreate them.  Do you have many?

_____________________________

If it Helps, Please rate....

(in reply to pteilloux)
Post #: 2
RE: Copy Package to another SCCM site - 11/19/2008 8:56:23 AM   
SMSExpert

 

Posts: 193
Score: 39
Joined: 10/28/2008
Status: offline
Hi,

just try this

Option Explicit
On Error Resume Next
Dim strDP
Dim wshShell
Dim strSiteCode
Dim strSiteServer
Dim objLocator
Dim objServer
Dim Length
Dim Result
Dim Length2
Dim strServer
Dim objService
Dim objLocSet
Dim objLoc
Dim strSite
Dim strProv
Dim strSiteName
Dim objSite
Dim objSiteName
Dim colVerify
Dim strVerify
Dim objVerify
Dim strPackages
Dim strPackage
Dim Query
Dim strResources
Dim strResource
Dim NALPath
Dim strDistPoint
Const wbemFlagReturnImmediately = &H10
Const wbemFlagForwardOnly = &H20
strDP = "SMS Distribution Point"
Set wshShell = wscript.CreateObject("wscript.shell")
'Get the name of the SMS Site for the DP
strSiteCode = InputBox("Enter the name of the site code to add" & _
VBCrLf & "all packages to.","Site Code",strSiteCode)
'Check to make sure text was entered
If strSiteCode = "" Then
wscript.echo "No Site Code entered, script will quit."
wscript.quit
End If
' Verify the correct length for a site code
If LEN(strSiteCode)<>3 Then
wscript.echo "Site Codes can only be 3 characters in length." & _
 VBCrLf & "Script will quit"
wscript.quit
Else
strSiteCode = UCASE(strSiteCode)
End If
' Get the name of the DP server
strSiteServer = InputBox("Enter the name of the Server to add" & _
VBCrLf & "all packages to.","Site Server",strSiteServer)
'Check to make sure text was entered
If strSiteServer = "" Then
wscript.echo "No Site Server entered, script will quit."
wscript.quit
End If
strSiteServer = UCASE(strSiteServer)
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Locate the primary site server
objServer=wshShell.RegRead _
("HKLM\Software\Microsoft\SMS\AdminUI\Connection\Server")
'If no server found, this will prompt for a primary server
If objServer="" Then
  strServer = InputBox _
   ("Enter the name of the primary site server", _
   "Primary Site Server",objServer)
  If strServer = "" Then
    wscript.echo "No Primary Site Server known, " & _
     "script will quit."
    wscript.quit
  End If
Else
'If the server name is found in the registry this removes
'the leading and trailing slashes
Length = LEN(objServer) - 2
Result = Right(objServer, Length)
Length2 = LEN(Result) - 1

strServer = Left(Result, Length2)
End If
'Connect to the SMS Namespace
Set objService = objLocator.ConnectServer(strServer, "root\sms")
'Verifies connection
If Err.Number <> 0 Then
  wscript.echo "Could not contact " & strServer & _
   vbCrLf & Err.Description
  wscript.quit
End If
Set objLocSet = objService.ExecQuery _
("select Machine, SiteCode from SMS_ProviderLocation where " & _
"ProviderForLocalSite=True", , _
wbemFlagForwardOnly Or wbemFlagReturnImmediately)
If Err.Number <> 0 Then
wscript.echo "Could not query " & strServer
wscript.quit
End If
'Retrieve information from query
For Each objLoc In objLocSet
  strSite = objLoc.SiteCode
  strProv = objLoc.Machine
Next
'Connect to the namespace for the site
Set objService = objLocator.ConnectServer _
(strProv, "root\sms\site_" & strSite)
'Verify Connection
If Err.Number <> 0 Then
  wscript.echo "Could not contact the site " & strSite & _
   " on " & strProv & vbCrLf & Err.Description
  wscript.quit
End If
'Set impersonation level
objService.Security_.ImpersonationLevel = 3
Set objLocator = Nothing
'Retrieve the sitecode for the server to add packages to
Set colVerify = objService.ExecQuery _
("select SiteCode from SMS_Site where" & _
" ServerName = '" & strSiteServer & "'",, 48)
'Verify sitecode found
If Err.Number <> 0 Then
wscript.echo "Could not fine the Site Server " & strSiteCode
wscript.quit
End If
'Get the instance of the site code
For Each objVerify In colVerify
strVerify = objVerify.SiteCode
Next
'Verify that the Server's site code is the same as the one
'entered above
If strVerify <> strSiteCode Then
wscript.echo "The server " & strSiteServer & _
 " is not in site " & strSiteCode & "." & _
 VBCrLf & "Please check the information and " & _
 "try again"
wscript.quit
End If  
'Retrieve the sitename
Set strSiteName = objService.ExecQuery _
("select SiteName from SMS_Site where SiteCode = '" & _
strSiteCode & "'",, 48)
If Err.Number <> 0 Then
wscript.echo "Could not find SiteName for " & strSiteCode
wscript.quit
End If
'Get the instance of the sitename
For Each objSite In strSiteName
  objSiteName = objSite.SiteName
Next
'Retrieve a list of all packages
Set strPackages = objService.ExecQuery _
("select PackageID from SMS_Package",, 0)
'Retrieve the NALPath for the server to add packages to
'This defines the Distribution Point on the server
Query = "select NALPath from SMS_SystemResourceList where " & _
"RoleName = '" & strDP & "' AND SiteCode = '" & strSiteCode & _
"' AND ServerName = '" & strSiteServer & "'"
'Execute NALPath query
Set strResources = objService.ExecQuery _
(Query,, wbemFlagForwardOnly Or wbemFlagReturnImmediately)
'Verifies the query completed
If Err.Number <> 0 Then
wscript.echo "Could not query " & strSiteServer
wscript.quit
End If

For Each strResource In strResources
NALPath = strResource.NALPath
For Each strPackage In strPackages
  Set strDistPoint = objService.Get _
   ("SMS_DistributionPoint").SpawnInstance_
  strDistPoint.PackageID = strPackage.PackageID
  strDistPoint.SiteCode = strSiteCode
  strDistPoint.ServerNALPath = NALPath
  strDistPoint.SiteName = objSiteName
  'Create the DP instance for each server
  strDistPoint.Put_()
Next
Next
wscript.echo "Finished adding all new packages to the " & _
"distribution" & VBCrLf & "point on " & strSiteServer & _
" in site " & strSiteCode & "."


Thanks

(in reply to hcortez463)
Post #: 3
RE: Copy Package to another SCCM site - 11/19/2008 8:57:04 AM   
pteilloux

 

Posts: 34
Score: 0
Joined: 7/3/2002
Status: offline
Approximatively 10 needed for a task Sequence.

(in reply to hcortez463)
Post #: 4
RE: Copy Package to another SCCM site - 11/19/2008 9:10:18 AM   
hcortez463


Posts: 793
Score: 65
Joined: 4/8/2005
Status: offline
cool, SMSExpert post a script.. i should have a couple laying around if needed

_____________________________

If it Helps, Please rate....

(in reply to pteilloux)
Post #: 5
RE: Copy Package to another SCCM site - 11/19/2008 9:25:21 AM   
pteilloux

 

Posts: 34
Score: 0
Joined: 7/3/2002
Status: offline
Yes cool, but it"s script copy all Package and i prefer if it's possible select some package :-(

(in reply to hcortez463)
Post #: 6
RE: Copy Package to another SCCM site - 11/19/2008 11:25:02 PM   
SMSExpert

 

Posts: 193
Score: 39
Joined: 10/28/2008
Status: offline
Ok, I will modify it accordingly and let you know.

Thanks. 

(in reply to pteilloux)
Post #: 7
RE: Copy Package to another SCCM site - 11/21/2008 3:01:31 PM   
michaelnowell

 

Posts: 16
Score: 0
Joined: 12/10/2007
Status: offline
Why not just use the copy packages wizard ?

(in reply to SMSExpert)
Post #: 8
RE: Copy Package to another SCCM site - 1/7/2009 4:34:24 PM   
javery15


Posts: 5
Score: 0
Joined: 7/23/2008
Status: offline
SMSExpert, can you enlighten me a little more on how this script should work?

For example, I have Server1 which has packages I would like to move to Server2. They are in different site codes and are not connected. I have about 64 apps that I need to move over.

So far, I was able to export and import the collections. I have the Programs (applications) and the Advertisements to move over. Any help would be appreciated.

Thanks!
James

< Message edited by javery15 -- 1/7/2009 4:38:09 PM >

(in reply to SMSExpert)
Post #: 9
Page:   [1]
All Forums >> [Management Products] >> System Center Products >> System Center Configuration Manager >> Copy Package to another SCCM site Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts



  
Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.375