# Create function new-sccmpackage sccm 2012

**URL:** <https://forums.powershell.org/t/create-function-new-sccmpackage-sccm-2012/1624>\
**Category:** PowerShell Help\
**Created:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/create-function-new-sccmpackage-sccm-2012/1624 "2011-12-31T18:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archives](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@archives](https://forums.powershell.org/u/archives)\
**Post date:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/create-function-new-sccmpackage-sccm-2012/1624/1 "2011-12-31T18:30:00Z")

</div>

by medodk at 2012-12-14 00:28:41

> Hello   
> I em new in powershell I try to make function to work new-sccmpackage in sccm 2012.  
>    
> I got Inspiration to from to places   
> 1.[http://www.jbmurphy.com/2012/05/10/powe … d-queries/](http://www.jbmurphy.com/2012/05/10/powershell-script-to-create-a-sccm-packageprogram-and-queries/)  
> This working with sccm 2007 but not in sccm 2012   
> I em using XML files .All information is in xml files.  
>   
> Implement,PackageName,PackageManufacturer,PackageVersion,PackageLanguage,PackageComment,PackageSourcePath,PackageFolder  
> Y,FireFox,Mozilla,17.0,Danish,New FireFox,\sccm13\deploy\appl\Moxila\Firefox 17,\<DONT FILL IN ID BUT PACKAGEFOLDER NAME\>  
>   
> Can anyone tell me how I wil do this   
>   
>   
> [powershell  
>   
> Function New-SCCMPackage {  
> [CmdletBinding()]  
> PARAM (  
> [Parameter(Mandatory=$true)][String] $PackageName,  
> [Parameter(Mandatory=$true)][String] $PackageManufacturer,  
> [Parameter(Mandatory=$true)][String] $PackageVersion,  
> [Parameter(Mandatory=$true)][String] $PackageLanguage,  
> [Parameter(Mandatory=$false)][String] $PackageComment = "",  
> [Parameter(Mandatory=$false)][String] $PackageType = "0",  
> [Parameter(Mandatory=$false)][String] $PkgSourceFlag = "2",  
> [Parameter(Mandatory=$true)][String] $PackageSourcePath,  
> [Parameter(Mandatory=$false)][String] $PackagePriority = "2"  
> )  
> $NewPackage = @{  
> Name = $PackageName;  
> Manufacturer = $PackageManufacturer;  
> Version = $PackageVersion;  
> Language = $PackageLanguage;  
> Description = $PackageComment;  
> PackageType = $PackageType;  
> PkgSourceFlag = $PkgSourceFlag;  
> PkgSourcePath = $PackageSourcePath;  
> Priority = $PackagePriority   
> }  
> $newPkg = Set-WmiInstance -class SMS\_Package -Arguments $newPackage -Namespace $Namespace  
> $GetnewPkg = $newPkg.PSBase | Select \* | out-null  
> $packageID.PackageID  
> $PackageID = $newPkg.PackageID}  
> [/powershell]

by Makovec at 2012-12-17 11:56:47

> Hi,  
> can you please describe what exactly you want to do?   
>   
> There is a lot of unclear things to me:  
> [list]  
> [_]You use ps1 file and use it as module?[/_]  
> [_]In Get-Package you use Set-WmiInstance. This is not correct IMHO.[/_][/list]  
> Can you please specify what’s your target and describe a bit your inputs?  
>   
> Thanks,  
> David

by medodk at 2012-12-19 13:31:35

> I run script   
> Set-ExecutionPolicy RemoteSigned  
> .\CreateFoldersAndCollections.ps1 .\Install.XML  
> I found inspiration here but this work only with sccm 2007 but not in sccm 2012 +  
> [http://www.jbmurphy.com/2012/05/10/powe … d-queries/](http://www.jbmurphy.com/2012/05/10/powershell-script-to-create-a-sccm-packageprogram-and-queries/)  
> I wont same results for Package(make package,make program,make qurey  
> 'I found som information on this page   
> [http://www.powershell.nu/2010/10/07/pow … -packages/](http://www.powershell.nu/2010/10/07/powershell-sccm-packages/)  
> gwmi -computer sccm13 -namespace root\sms\site\_P01 -class sms\_package -filter ‘name like"%office%"’  
> gwmi -computer sccm13 -namespace root\sms\site\_P01 -class sms\_package -filter ‘name like"%"’|gm  
> $pkgoffice =gwmi -computer sccm13 -namespace root\sms\site\_P01 -class sms\_package -filter ‘name like"%office%"’  
> $pkgoffice | Select-Object -Property Name, Description, Version | Format-Table -AutoSize  
> $pkgoffice.Description = "PowerShell Rocks"  
> $pkgoffice.Put()  
> I would like use powershell script to read information from xml files and create package,qurey,dp,programs.  
> I hope someone will help me.

by medodk at 2012-12-19 13:33:00

> I run script   
> Set-ExecutionPolicy RemoteSigned  
> .\CreateFoldersAndCollections.ps1 .\Install.XML  
> I found inspiration here but this work only with sccm 2007 but not in sccm 2012 +  
> [http://www.jbmurphy.com/2012/05/10/powe … d-queries/](http://www.jbmurphy.com/2012/05/10/powershell-script-to-create-a-sccm-packageprogram-and-queries/)  
> I wont same results for Package(make package,make program,make qurey  
> 'I found som information on this page   
> [http://www.powershell.nu/2010/10/07/pow … -packages/](http://www.powershell.nu/2010/10/07/powershell-sccm-packages/)  
> gwmi -computer sccm13 -namespace root\sms\site\_P01 -class sms\_package -filter ‘name like"%office%"’  
> gwmi -computer sccm13 -namespace root\sms\site\_P01 -class sms\_package -filter ‘name like"%"’|gm  
> $pkgoffice =gwmi -computer sccm13 -namespace root\sms\site\_P01 -class sms\_package -filter ‘name like"%office%"’  
> $pkgoffice | Select-Object -Property Name, Description, Version | Format-Table -AutoSize  
> $pkgoffice.Description = "PowerShell Rocks"  
> $pkgoffice.Put()  
> I would like use powershell script to read information from xml files and create package,qurey,dp,programs.  
> I hope someone will help me.

by medodk at 2012-12-19 13:35:13

> I run script   
> Set-ExecutionPolicy RemoteSigned  
> .\CreateFoldersAndCollections.ps1 .\Install.XML  
> I found inspiration here but this work only with sccm 2007 but not in sccm 2012 +  
> [http://www.jbmurphy.com/2012/05/10/powe … d-queries/](http://www.jbmurphy.com/2012/05/10/powershell-script-to-create-a-sccm-packageprogram-and-queries/)  
> I wont same results for Package(make package,make program,make qurey  
> 'I found som information on this page   
> [http://www.powershell.nu/2010/10/07/pow … -packages/](http://www.powershell.nu/2010/10/07/powershell-sccm-packages/)  
>   
> [/powershell]  
>   
> gwmi -computer sccm13 -namespace root\sms\site\_P01 -class sms\_package -filter ‘name like"%office%"’  
> gwmi -computer sccm13 -namespace root\sms\site\_P01 -class sms\_package -filter ‘name like"%"’|gm  
> $pkgoffice =gwmi -computer sccm13 -namespace root\sms\site\_P01 -class sms\_package -filter ‘name like"%office%"’  
> $pkgoffice | Select-Object -Property Name, Description, Version | Format-Table -AutoSize  
> $pkgoffice.Description = "PowerShell Rocks"  
> $pkgoffice.Put()  
>   
> ` would like use powershell script to read information from xml files and create package,qurey,dp,programs.I hope someone will help me.`

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 9:03pm UTC](https://forums.powershell.org/t/create-function-new-sccmpackage-sccm-2012/1624/2 "2024-05-16T21:03:40Z")

</div>


