Copy-PSModuleToFolder

OSD 21.2.9.2+

Copy-PSModuleToFolder used to copy an installed PowerShell Module to separate destination directory. The destination directory will be created if it does not exist

PS C:\> Get-Help Copy-PSModuleToFolder -Full
NAME
Copy-PSModuleToFolder
SYNOPSIS
Get-Module and copy the ModuleBase to a new Destination\ModuleBase
SYNTAX
Copy-PSModuleToFolder [-Name] <String[]> [-Destination] <String> [-RemoveOldVersions] [<CommonParameters>]
DESCRIPTION
Get-Module and copy the ModuleBase to a new Destination\ModuleBase
PARAMETERS
-Name <String[]>
Name of the PowerShell Module to Copy
Required? true
Position? 1
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? true
-Destination <String>
Destination PSModule directory
Copied Module is a Child of Destination
Required? true
Position? 2
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false
-RemoveOldVersions [<SwitchParameter>]
Removes older Module Versions from the Destination
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
21.1.30.1 Initial Release
21.1.30.2 Added WinPE Parameter
21.1.30.3 Renamed PSModulePath Parameter to Destination, Added RemoveOldVersions
21.1.31.1 Removed WinPE Parameter
21.2.2.1 Renamed to Copy-ModuleToFolder so I don't mess with PowerShellGet
21.2.9.1 Renamed to Copy-PSModuleToFolder to standardize
RELATED LINKS
https://osd.osdeploy.com/module/functions/psmodule/copy-psmoduletofolder

-Name

#String
-Name PShot
#Array of Strings
-Name PShot,OSD,OSDBuilder
#Wildcard
-Name OSD*
#Position 0
Copy-Module PShot

-Destination

#Module will be copied to T:\Temp\PShot\<ModuleVersion>
Copy-Module -Name PShot -Destination T:\Temp
#Module will be copied to C:\Program Files\WindowsPowerShell\Modules\OSD\<ModuleVersion>
Copy-Module -Name OSD -Destination "C:\Program Files\WindowsPowerShell\Modules"

-RemoveOldVersions

-RemoveOldVersions [<SwitchParameter>]
Removes older Module Versions from the Destination
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
-RemoveOldVersions:$true

Versioning

If multiple versions of a Module exist, only the latest will be copied

Version Subfolders

Version Subfolders are retained by Copy-Module, unless the -WinPE or -RemoveOldVersionsparameters are used

-RemoveOldVersions:$false