Heh, I'm running a script right now that does the same thing. I run it
every day to keep my content up to date since we are sending out our hard
drives next week. Here is what this script does, it grabs the
app/package/whatever's name and ID and then comes up with a filename. It
checks if the file exists, if the file exists it compares the date created
time with the date modified time on the app/package/whatever and determines
if the app is newer. If it is, it deletes the old file and then pre-stages
the new.

The file name cannot be a UNC path, so I mapped the network location to
drive P. It stores Applications in the folder Applications, Packages in the
folder Packages, Driver Packages in DriverPkgs, Software Update Packages in
DeploymentPkgs, Boot Images in BootImages, and OS Images in OSImages.  My
driver loop actually stores all the drivers in one file to save storage
space.

This needs to be run from an x86 powershell prompt since it uses the CM2012
cmdlets.

The content needs to be distributed to the DP you specify in $DPName. I
went through and took out all of my companies server information. Let me
know if I took out too much and it's now erroring or something.




On Fri, Jul 19, 2013 at 1:07 PM, Richard Zuraff <[email protected]
> wrote:

>  Is there an easy way to create one Prestige content file for all your
> packages, drivers, updates, ect for SCCM 2012?  We need to preload all of
> our sites for our upgrade and need to send out the content file on a usb
> hard drive to about a 130 sites.  ****
>
> ** **
>
> I found a PowerShell script, but it only does a folder that you have your
> packages in and we would like to do all of our content.  ****
>
> ** **
>
> Thanks****
>
> ** **
>
> ** **
>
> ** **
>
> ** **
>
> ** **
>
> ** **
>
> ** **
>
> ** **
>
>



$SiteCode = "SITECODE"
$SitePath = "$SiteCode" + ":\"
Import-Module "C:\Program Files (x86)\Microsoft Configuration 
Manager\AdminConsole\bin\ConfigurationManager.psd1"
CD "$SitePath"
$2012Server = "SITESERVER"
$2012Namespace = "root\SMS\site_SITECODE"
$DPName = "DPNAME"
$StoreDrive = "P:"

Get-WmiObject -Query "Select * from SMS_Application where ISLatest='true'" 
-ComputerName $2012Server -Namespace $2012Namespace | ForEach-Object {
        $AppNames = $null
        $AppID = $_.CI_UniqueID
        $AppName = $_.LocalizedDisplayName
        $FileName = "P:\Applications\$AppName.pkgx"
        CD "C:\"
        $DoIt = $true
        if (Test-Path $FilePath) {
                $Date1 = (Get-Item $FilePath).CreationTime
                $Date2 = $_.ConvertToDateTime($_.DateLastModified)
                if ($Date1 -lt $Date2) {Remove-Item -Path $FilePath -Force}
                else {$DoIt = $false}
        }
        if ($DoIt -eq $true) {
                $Error.Clear()
                CD "$SitePath"
                Publish-CMPrestageContent -ApplicationName $AppNames 
-DisableExportAllDependencies -FileName $FilePath -DistributionPointName $DPName
        }
}

Get-WmiObject -Query "Select * from SMS_Package" -ComputerName $2012Server 
-Namespace $2012Namespace | ForEach-Object {
        $AppID = $_.CI_UniqueID
        $PackageName = $_.Name
        $FileName = "P:\Packages\$PackageName.pkgx"
        CD "C:\"
        $DoIt = $true
        if (Test-Path $FileName) {
                        $Date1 = (Get-Item $FileName).CreationTime
                        $Date2 = $_.ConvertToDateTime($_.SourceDate)
                        if ($Date1 -lt $Date2) {
                                Remove-Item -Path $FileName -Force
                        }
                        else {$DoIt = $false}
                }
        if ($DoIt -eq $true) {
                CD "$SitePath"
                Publish-CMPrestageContent -PackageName $PackageName -FileName 
$FileName -DistributionPointName $DPName
        }
}

Get-WmiObject -Query "Select * from SMS_DriverPackage" -ComputerName 
$2012Server -Namespace $2012Namespace | ForEach-Object {
        $PackageName = $_.Name
        $PackageID = $_.PackageID
        $PackageOnServer = $null
        $strQuery = "Select * from SMS_DPContentInfo where NALPath like 
'%$DPName" + "%' and PackageID='$PackageID'"
        $PackageOnServer = Get-WmiObject -Query $strQuery -Namespace 
$2012Namespace -ComputerName $2012Server
        if ($PackageID -ne $null) {$PackageNames += @("$PackageName")}
}
$FileName = "P:\DriverPkgs\Drivers.pkgx"
CD "$SitePath"
Publish-CMPrestageContent -DriverPackageName $PackageNames -FileName $FileName 
-DistributionPointName $DPName

Get-WmiObject -Query "SELECT * FROM SMS_SoftwareUpdatesPackage WHERE 
ActionInProgress!=3" -ComputerName $2012Server -Namespace $2012Namespace | 
ForEach-Object {
        $AppID = $_.CI_UniqueID
        $PackageName = $_.Name
        $FileName = "P:\DeploymentPkgs\$PackageName.pkgx"
        CD "C:\"
        $DoIt = $true
        if (Test-Path $FileName) {
                        $Date1 = (Get-Item $FileName).CreationTime
                        $Date2 = $_.ConvertToDateTime($_.SourceDate)
                        if ($Date1 -lt $Date2) {Remove-Item -Path $FileName 
-Force}
                        else {$DoIt = $false}
                }
        if ($DoIt -eq $true) {
                CD "$SitePath"
                Publish-CMPrestageContent -DeploymentPackageName $PackageName 
-FileName $FileName -DistributionPointName $DPName
        }
}

Get-WmiObject -Query "SELECT * FROM SMS_BootImagePackage WHERE 
ActionInProgress!=3" -ComputerName $2012Server -Namespace $2012Namespace | 
ForEach-Object {
        $AppID = $_.CI_UniqueID
        $PackageName = $_.Name
        $FileName = "P:\BootImages\$PackageName.pkgx"
        CD "C:\"
        $DoIt = $true
        if (Test-Path $FileName) {
                        $Date1 = (Get-Item $FileName).CreationTime
                        $Date2 = $_.ConvertToDateTime($_.SourceDate)
                        if ($Date1 -lt $Date2) {Remove-Item -Path $FileName 
-Force}
                        else {$DoIt = $false}
                }
        if ($DoIt -eq $true) {
                CD "$SitePath"
                Publish-CMPrestageContent -BootImageName $PackageName -FileName 
$FileName -DistributionPointName $DPName
        }
}

Get-WmiObject -Query "SELECT * FROM SMS_ImagePackage WHERE ActionInProgress!=3" 
-ComputerName $2012Server -Namespace $2012Namespace | ForEach-Object {
        $AppID = $_.CI_UniqueID
        $PackageName = $_.Name
        $FileName = "P:\OSImages\$PackageName.pkgx"
        CD "C:\"
        $DoIt = $true
        if (Test-Path $FileName) {
                        $Date1 = (Get-Item $FileName).CreationTime
                        $Date2 = $_.ConvertToDateTime($_.SourceDate)
                        if ($Date1 -lt $Date2) {Remove-Item -Path $FileName 
-Force}
                        else {$DoIt = $false}
                }
                if ($DoIt -eq $true) {
                CD "$SitePath"
                Publish-CMPrestageContent -OperatingSystemImageName 
$PackageName -FileName $FileName -DistributionPointName $DPName
        }
}

Reply via email to