How to create a Sitecore Package using Sitecore Powershell Extension

# Create package
 $package = new-package "Sitecore Test Package";

# Set package metadata
 $package.Sources.Clear();

$package.Metadata.Author = "Mohd Tarique - Workstation Machine";
 $package.Metadata.Publisher = "AIE Enterprise Inc";
 $package.Metadata.Version = "2.19";
 $package.Metadata.Readme = 'This text will be visible to people installing your package'

$allItems = Get-ChildItem -Path 'master://sitecore/content/Terminix' -Recurse

ForEach ($item in $allItems) {

#Write-Host $item.FullPath
 $formattedItemPath = "master:" + $item.FullPath.Replace("/","\").Replace("/sitecore","")
 #Write-Host $formattedItemPath
 $source = [Sitecore.Context]::ContentDatabase.GetItem($item.ID) | New-ExplicitItemSource -Name 'Content' -InstallMode Merge -MergeMode Merge
 $package.Sources.Add($source);
}


# Save package
 Export-Package -Project $package -Path "$($package.Name)-$($package.Metadata.Version).zip" -Zip

# Offer the user to download the package
 Download-File "$SitecorePackageFolder\$($package.Name)-$($package.Metadata.Version).zip"

 

 

8470cookie-checkHow to create a Sitecore Package using Sitecore Powershell Extension

Add a Comment

Your email address will not be published. Required fields are marked *