How to use Set-CMProgram Powershell Cmdlet

Hello, I'm trying to get the Set-CMProgram powershell cmdlet to work. What I'm trying to do is turn on the option to Suppress Program Notifications on all packages that have been migrated from SCCM 2007-2012.

At this stage I'm trying to run a powershell command to do this on one program for one package but cant get this to work.

I've tried getting a program from an existing package via:

$pkg=Get-CMProgram -packageid "XXX00179" -ProgramName "Install"

and then various combinations using -inputobject to turn on suppress but keep getting binding errors as below

Set-CMProgram -InputObject $pkg -StandardProgramName SPM -SuppressProgramNotifications $True

Set-CMProgram : Cannot bind argument to parameter 'InputObject', because PSTypeNames of the argument do not match the
PSTypeName required by the parameter: IResultObject#SMS_Package.

Does anyone know how to set options on an existing program using the above commands or have a better way of doing this?

Thanks

Carl

June 4th, 2013 7:11am

Ok I think I have figured out how I can do this using the packageid as opposed to an InputObject, so I should be able to iterate through all packages and programs and set this option.

Set-CMProgram -Id "XXX000F6" -StandardProgramName "Install" -SuppressProgramNotifications $True

Free Windows Admin Tool Kit Click here and download it now
June 4th, 2013 11:33am

It looks like Get-CMProgram returned an instance of SMS_Program and Set-CMProgram is expecting an instance of SMS_Package. This doesn't seem right to me and I would recommend filing a feedback on this at https://connect.microsoft.com/ConfigurationManagervnext/Feedback

June 4th, 2013 11:48pm

Hi Adam, I've raised this on connect.

Can you take a look at my other issue with Set-CMPackageDeployment and see if this is also an issue?

Thanks

Carl

Free Windows Admin Tool Kit Click here and download it now
June 5th, 2013 4:25am

Hi,

Set-CMProgram works in my environmnet. Please verify that Get-CMPackage actually returns an object

Best,

Kaido

  • Marked as answer by Carlitog Sunday, June 16, 2013 2:17 AM
June 11th, 2013 5:22am

Thanks for taking time to test these out Kaido. From your screenshots above I've realised there is nothing wrong with my Set-CMProgram command.

The issue I had was with obtaining the package in the first place. I was using $pkg=Get-CMProgram -packageid "XXX00179" -ProgramName "Install" instead of $pkg=Get-CMPackage -packageid "XXX00179" !!

Cant see the wood for the trees sometimes :-) All working now.

Thanks again.

Free Windows Admin Tool Kit Click here and download it now
June 16th, 2013 2:20am

I share with you this Script that use Get-CMProgram , Set-CMProgram, Get-CMPackage 

I tested it and it work fin it duplicate Package and move them on SCCM 2012

go here 

http://windowscapture.blogspot.fr/2015/07/heres-script-powershell-to-duplicate.html

July 24th, 2015 5:55am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics