Wildcard characters allow you to select elements with similar names in your scripts. For instance, you can use PowerShell wildcards to copy all the objects (lists, subsites, term sets, etc.) that have a name that starts or ends with the same word or string of characters.
Index
Details
You can use wildcards with the -Name parameter. -Name is generally used with structural commands like Copy-Site, Copy-List, and Get-TermSet.
You can create a value that will bring all the site objects that start or end with a set of characters with the * symbol.
Type * at the beginning of your string of characters to bring all the objects with a name that ends with that set of characters.
Type * at the end of your string of characters to bring all the objects with a name that starts with that set of characters.
Note: Wildcard support is limited to commands that work with the -Name and -ID parameters. For example, you will find that -Name can be used with Copy-Site in the Parameters section of the Copy Site article.
Examples
Copy subsites with a name that starts with the same set of characters
$dstSite = Connect-Site -Url http://myfarm2010/sites/yoursite
$srcSite = Connect-Site -Url http://myfarm2013/sites/yoursite
Copy-Site -Name Product* -SourceSite $srcSite -DestinationSite $dstSite
In this example, you would be copying all the subsites of the yoursite site collection that start with the name Product.
For instance, subsites with names like Product A, Product B, and Product C would get migrated.
Copy lists with a name that ends with the same set of characters
$srcSite = Connect-Site -Url http://myfarm2010/sites/yoursite
$dstSite = Connect-Site -Url http://myfarm2013/sites/yoursite
Copy-List -SourceSite $srcSite -Name *Contracts -DestinationSite $dstSite
In this example, you would be copying all the lists of the yoursite site that ends with the name Contracts.
For instance, lists with names like Product A Contracts, Product B Contracts, and Product C Contracts would get migrated.