Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nehemiahj/c46c9faf93543f079b01a682a39530d1 to your computer and use it in GitHub Desktop.
Save nehemiahj/c46c9faf93543f079b01a682a39530d1 to your computer and use it in GitHub Desktop.
This script creates Sitecore Package with all Users and Roles
# Reference: https://doc.sitecorepowershell.com/appendix/packaging/new-securitysource
$package = New-Package "Sitecore-UsersAndRoles";
#Set package metadata
$package.Sources.Clear();
$package.Metadata.Author = "Nehemiah";
$package.Metadata.Publisher = "Company";
$package.Metadata.Version = "1.0";
$package.Metadata.Readme = 'This package has all the users and roles of the Sitecore Instance'
# Create security source with all roles and users
$source = New-SecuritySource -Filter * -Name AllUsersAndRoles
$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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment