Awesome, works great. I added a function to grab the current package directory and then write it back in the method. I had assumed that was not required...that will teach me. Here is the final product in case someone else likes this idea. I will be making it into a script that prompts for package server name and then adds that package server's guid to the list of package servers that contain the package!
Thanks again, I do appreciate it!
Matt
OUTPUT:
E:\hold>cscript package.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
***Calling Sub to Display Package Info***
packageObject Item Details
packageObject.AgentDisplayDescription=
packageObject.AgentDisplayName=
packageObject.AlternateDownloadDestinationLocation=
packageObject.Attributes=Normal
packageObject.EnableVerboseEvents=False
packageObject.Description=
packageObject.PackageDirectory=
packageObject.Language=
packageObject.Location=e:\gold\tools
packageObject.Name=_test package
packageObject.Publisher=
packageObject.PackageSourceType=Local
packageObject.PackageType=Win32
packageObject.Version=1.0
packageObject.PurgeAfterDurationInMinutes=10080
packageObject.SelectedPackageServers=5d07498b-952c-4097-a339-156a4c1c1388,f1091
268-aec4-4bb4-8352-ad905b88d896
packageObject.Guid=bff09bbe-cb89-44d1-ab2a-6eafa657dd44
packageObject.ParentFolderGuid=18aa08d8-c2eb-4407-a7e6-f3ad9946d0db
***Calling Sub to get Package Server list***
Current List: 5d07498b-952c-4097-a339-156a4c1c1388,f1091268-aec4-4bb4-8352-ad905
b88d896
New List: 5d07498b-952c-4097-a339-156a4c1c1388,f1091268-aec4-4bb4-8352-ad905b88d
896,5d07498b-952c-4097-a339-156a4c1c1388
***Calling function to get the current package directory***
Current Package Directory:
***Calling Function to modify package server list***
Result of Function to modify package server list:True
***Calling Sub to Display Package Info***
packageObject Item Details
packageObject.AgentDisplayDescription=
packageObject.AgentDisplayName=
packageObject.AlternateDownloadDestinationLocation=
packageObject.Attributes=Normal
packageObject.EnableVerboseEvents=False
packageObject.Description=
packageObject.PackageDirectory=
packageObject.Language=
packageObject.Location=e:\gold\tools
packageObject.Name=_test package
packageObject.Publisher=
packageObject.PackageSourceType=Local
packageObject.PackageType=Win32
packageObject.Version=1.0
packageObject.PurgeAfterDurationInMinutes=10080
packageObject.SelectedPackageServers=5d07498b-952c-4097-a339-156a4c1c1388,f1091
268-aec4-4bb4-8352-ad905b88d896
packageObject.Guid=bff09bbe-cb89-44d1-ab2a-6eafa657dd44
packageObject.ParentFolderGuid=18aa08d8-c2eb-4407-a7e6-f3ad9946d0db
Current List: 5d07498b-952c-4097-a339-156a4c1c1388,f1091268-aec4-4bb4-8352-ad905
b88d896
E:\hold>
SCRIPT:
'vbscript function the add a package server to the list of package servers for a package
option explicit
Dim strGuid
Dim strPackageServerList,strNewPackageServer,strNewPackageServerList
Dim result
Dim strPackageDirectory
strGuid = "bff09bbe-cb89-44d1-ab2a-6eafa657dd44"
'Call sub to display object info for strGuid
wscript.echo "***Calling Sub to Display Package Info***"
DisplayObjectInfo(strGuid)
wscript.echo ""
'call function to get current package server list from object
wscript.echo "***Calling Sub to get Package Server list***"
strPackageServerList = GetCurrentPackageServerlist(strGuid)
wscript.echo "Current List: " & strPackageServerList
'package server to add to list - this will be changed to another sub at a later point
strNewPackageServer = "5d07498b-952c-4097-a339-156a4c1c1388"
'add the new package server to the comma seperated string of package servers to make the new list
strNewPackageServerList = strPackageServerList & "," & strNewPackageServer
wscript.echo "New List: " & strNewPackageServerList
wscript.echo ""
'call function to get the current package directory
wscript.echo "***Calling function to get the current package directory***"
strPackageDirectory = GetCurrentPackageDirectory(strGuid)
wscript.echo "Current Package Directory: " & strPackageDirectory
wscript.echo ""
'call function to set new package server list
wscript.echo "***Calling Function to modify package server list***"
result = ModifyPackageServerList(strGuid,strNewPackageServerList,strPackageDirectory)
wscript.echo "Result of Function to modify package server list:" & result
wscript.echo ""
'display the object info for strGuid again
wscript.echo "***Calling Sub to Display Package Info***"
DisplayObjectInfo(strGuid)
wscript.echo "Current List: " & strPackageServerList
Function ModifyPackageServerList(strGuid,strNewPackageServerList,strPackageDirectory)
'Function to modify the package server list for package 'strguid'
Dim PackageManagement
set packageManagement = CreateObject("Altiris.ASDK.NS.SoftwareDelivery.SWDSolnPackageManagementLib")
packageManagement.TargetServer = "localhost"
packageManagement.Authenticate()
'write the new list to the package
ModifyPackageServerList = PackageManagement.SetPackageExPackageServerOptions(strGuid, false, strNewPackageServerList, strPackageDirectory)
End Function
Function GetCurrentPackageServerList(strGuid)
'get the current package server list for the package with the provided guid and return it.
Dim PackageObject,PackageManagement
set packageManagement = CreateObject("Altiris.ASDK.NS.SoftwareDelivery.SWDSolnPackageManagementLib")
packageManagement.TargetServer = "localhost"
packageManagement.Authenticate()
set packageObject = packageManagement.GetPackageExbyGuid(strGuid)
GetCurrentPackageServerList = packageObject.SelectedPackageServers
End Function
Function GetCurrentPackageDirectory(strGuid)
'Get current Package directory
Dim PackageObject,PackageManagement
set packageManagement = CreateObject("Altiris.ASDK.NS.SoftwareDelivery.SWDSolnPackageManagementLib")
packageManagement.TargetServer = "localhost"
packageManagement.Authenticate()
set packageObject = packageManagement.GetPackageExbyGuid(strGuid)
GetCurrentPackageDirectory = PackageObject.PackageDirectory
End Function
sub DisplayObjectInfo(strGuid)
Dim CRLF,PackageObject,PackageManagement
CRLF = CHR( 13 ) & CHR( 10 ) 'Carrage Return Line Feed
set packageManagement = CreateObject("Altiris.ASDK.NS.SoftwareDelivery.SWDSolnPackageManagementLib")
packageManagement.TargetServer = "localhost"
packageManagement.Authenticate()
'Display all infor for package with guid strguid
set packageObject = packageManagement.GetPackageExByGuid(strGuid)
''''''''''''''''''''''''''''''''''''''''
' Run through the package Object details
''''''''''''''''''''''''''''''''''''''''
wscript.Echo "packageObject Item Details" & CRLF _
& " packageObject.AgentDisplayDescription=" & packageObject.AgentDisplayDescription & CRLF _
& " packageObject.AgentDisplayName=" & packageObject.AgentDisplayName & CRLF _
& " packageObject.AlternateDownloadDestinationLocation=" & packageObject.AlternateDownloadDestinationLocation & CRLF _
& " packageObject.Attributes=" & packageObject.Attributes & CRLF _
& " packageObject.EnableVerboseEvents=" & packageObject.EnableVerboseEvents & CRLF _
& " packageObject.Description=" & packageObject.Description & CRLF _
& " packageObject.PackageDirectory=" & packageObject.PackageDirectory & CRLF _
& " packageObject.Language=" & packageObject.Language & CRLF _
& " packageObject.Location=" & packageObject.Location & CRLF _
& " packageObject.Name=" & packageObject.Name & CRLF _
& " packageObject.Publisher=" & packageObject.Publisher & CRLF _
& " packageObject.PackageSourceType=" & packageObject.PackageSourceType & CRLF _
& " packageObject.PackageType=" & packageObject.PackageType & CRLF _
& " packageObject.Version=" & packageObject.Version & CRLF _
& " packageObject.PurgeAfterDurationInMinutes=" & packageObject.PurgeAfterDurationInMinutes & CRLF _
& " packageObject.SelectedPackageServers=" & packageObject.SelectedPackageServers & CRLF _
& " packageObject.Guid=" & packageObject.Guid & CRLF _
& " packageObject.ParentFolderGuid=" & packageObject.ParentFolderGuid & CRLF
End Sub