Very nice PowerShell automation work for Package and Program objects,
Daniel!

 

I'd just point out that you don't need the sccm_2007.psm1 module, or the
Connect-SccmServer function that's contained within it, unless you're
explicitly using something else from inside that module. It looks like
you're making direct calls to WMI over DCOM/RPC, using the built-in cmdlets,
which do not require any external modules.

 

I personally write a lot of automation scripts around the ConfigMgr WMI
provider, and do not rely on any external modules. Pretty much anything you
need to do can be done using Get-WmiObject, the [wmiclass], and [wmi] type
accelerators. The only scenario where you absolutely need to access a WMI
instance using the [wmi] type accelerator and its direct WMI path (aka.
moniker), is when you're working with Lazy Properties. More info here:
http://trevorsullivan.net/2010/09/28/powershell-configmgr-wmi-provider-feat-
lazy-properties/

 

Cheers,

Trevor Sullivan

 <http://trevorsullivan.net/>     <http://twitter.com/pcgeek86>
<http://facebook.com/trevor.sullivan>
<https://plus.google.com/106658223083457664096> 

 

From: [email protected] [mailto:[email protected]]
On Behalf Of Daniel Ratliff
Sent: Wednesday, May 15, 2013 2:50 PM
To: [email protected]
Subject: RE: [mssms] SMS File information for CM2007

 

Trevor nailed it. I actually am in the middle of writing a script for
ConfigMgr 2007 that will add a new program to a package. Everything works
except the OS choices. I am actually just creating a new program for Nomad
TS Hook that mirrors the existing install program. 

 

import-module .\sccm_2007.psm1

 

$server = "YOUR SERVER"

$site = "YOUR SITE CODE"

$prgflags = 1090560

 

write-host ""

write-host "Querying the site server for packages and programs..."
-foregroundcolor yellow

 

connect-sccmserver -server $server -site $site

 

$packages = Get-WmiObject SMS_Package -computername $server -Namespace
root\SMS\site_$site

$programs = Get-WmiObject SMS_Program -computername $server -Namespace
root\SMS\site_$site

 

write-host ""

write-host "1" -foregroundcolor cyan -nonewline;write-host " - List all
Packages"

write-host "2" -foregroundcolor cyan -nonewline;write-host " - Add Nomad TS
Hook to a package"

write-host ""

write-host "Enter your choice: " -foregroundcolor cyan -nonewline;

$choice = read-host

write-host ""

switch ($choice) {

    1 {

        $packages| select manufacturer, name, version, packageid | sort
manufacturer

    }

    2 {

         write-host "Enter your Package ID to modify: " -foregroundcolor
cyan -nonewline;

        $pkgid = Read-host

        $pkgmfg = ($packages | where {$_.packageid -eq $pkgid}).Manufacturer

        $pkgname = ($packages | where {$_.packageid -eq $pkgid}).Name

        $pkgversion = ($packages | where {$_.packageid -eq $pkgid}).Version

        write-host "You chose: " -foregroundcolor cyan -nonewline;
write-host $pkgid

        write-host "Package Title: " -foregroundcolor cyan
-nonewline;write-host $pkgmfg" "$pkgname" "$pkgversion

        write-host "Existing programs: " -foregroundcolor cyan

        $programs | where {$_.packageid -eq $pkgid} | select
ProgramName,CommandLine

        $cmdline = ($programs | where {$_.packageid -eq $pkgid -and
$_.programname -eq "HUMINST"}).commandline

        $arguments = @{

            PackageID = $pkgID;

            ProgramFlags = $prgflags;

            ProgramName = "Nomad TS Hook";

            CommandLine = "%ProgramFiles%\1E\NomadBranch\SMSNomad.exe " +
$cmdline;

            Duration = 120

        }

        write-host ""

        write-host "Adding Nomad TS Hook program to package"$pkgid
-foregroundcolor green

        Set-wmiinstance SMS_Program -arguments $arguments -computername
$server -namespace root\SMS\site_$site

        $programs = Get-WmiObject SMS_Program -computername $server
-Namespace root\SMS\site_$site

        write-host ""

        write-host "Existing programs:" -foregroundcolor cyan

        $programs | where {$_.packageid -eq $pkgid} | select
ProgramName,CommandLine

    }

    3 {

    }

    4 {

    }

    5 {

    }

    default { 

        write-host "Invalid Choice. Exiting. " -foregroundcolor red

        start-sleep -seconds 5

        exit            

    }

}

 

Daniel Ratliff

 

From: [email protected] <mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Trevor Sullivan
Sent: Wednesday, May 15, 2013 3:41 PM
To: [email protected] <mailto:[email protected]> 
Subject: RE: [mssms] SMS File information for CM2007

 

Henry,

 

Those settings are stored in the SMS_Program WMI class' ProgramFlags
property, if I recall correctly. It should be pretty easy to script out
those changes to Program objects. The specific bits to change are documented
in the ConfigMgr 2007 SDK. Let me know if you need help doing this.

 

Cheers,

Trevor Sullivan

 <http://trevorsullivan.net/>    <http://twitter.com/pcgeek86>
<http://facebook.com/trevor.sullivan>
<https://plus.google.com/106658223083457664096> 

 

From: [email protected] <mailto:[email protected]>
[mailto:[email protected]]
<mailto:[mailto:[email protected]]>  On Behalf Of
[email protected] <mailto:[email protected]> 
Sent: Wednesday, May 15, 2013 2:31 PM
To: [email protected] <mailto:[email protected]> 
Subject: [mssms] SMS File information for CM2007

 

Working in CM2007 our packagers are asking if there are commands that can be
added to the SMS file to enable/toggle the highlighted options? 



I found a script that will change all packages but that would not be a good
idea.  Also, the SMS file is created before the package ID is generated (saw
another script for that too).  This becomes a real PITA when you have to
check these after the package is created.

 

Any help would be appreciated.

Thanks

 

 


The information transmitted is intended only for the person or entity to
which it is addressed
and may contain CONFIDENTIAL material. If you receive this
material/information in error,
please contact the sender and delete or destroy the material/information.

 



<<image001.gif>>

<<image002.gif>>

<<image003.gif>>

<<image004.gif>>

<<image005.jpg>>

Reply via email to