New-FileSource

Creates new File source that can be added to a Sitecore package.

Syntax

New-FileSource [-Name] <String> [-Root] <DirectoryInfo> [[-IncludeFilter] <String>] [[-ExcludeFilter] <String>] [-InstallMode <String>]

Detailed Description

Creates new File source that can be added to a Sitecore package. Folder provided as Root will be added as well as all of its content provided it matches the filters.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

Parameters

-Name <String>

Name of the file source.

Aliases

Required?

true

Position?

1

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Root <DirectoryInfo>

Root folder to include in the package

Aliases

Required?

true

Position?

2

Default Value

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-IncludeFilter <String>

Filter that defines which files will be included.

Aliases

Required?

false

Position?

3

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ExcludeFilter <String>

Filter that defines which files will NOT be included.

Aliases

Required?

false

Position?

4

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-InstallMode <String>

Aliases

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Sitecore.Install.Files.FileSource

Notes

Help Author: Adam Najmanowicz, Michael West

Examples

EXAMPLE

Following example creates a new package, adds content of the Console folder under the site folder saves it in the Sitecore Package folder + gives you an option to download the saved package.

# Create package
$package = New-Package "Packing in Powerful Ways";

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

$package.Metadata.Author = "Adam Najmanowicz, Michael West";
$package.Metadata.Publisher = "Powerful Ways";
$package.Metadata.Version = "1.0";
$package.Metadata.Readme = 'This text will be visible to people installing your package'

# Add content of the Console folder in the site folder to the package
$source = New-FileSource -Name "Console Assets" -Root "$AppPath\Console"
$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"

Last updated