# Copy-PSModuleToFolder

**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
```

![](/files/-MSJHq_-KJ2qTo4IIvfg)

![](/files/-MSJIBXzuO7T-Hl-kSTu)

## -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](/files/-MSH_1po4HWcYzoJDbRk)

## Versioning

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

![](/files/-MSHFHiKVARHfJo2YjDZ)

## Version Subfolders

Version Subfolders are retained by Copy-Module, unless the **`-WinPE`** or **`-RemoveOldVersions`**&#x70;arameters are used

![-RemoveOldVersions:$false](/files/-MSHK5XWrtcnJFWtrFXi)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://osd.osdeploy.com/docs/trash/psmodule/copy-psmoduletofolder.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
