Public/Functions/PSModule/Copy-PSModuleToWim.ps1
function Copy-PSModuleToWim { [CmdletBinding()] param ( [Parameter(ValueFromPipelineByPropertyName = $true)] [ValidateSet('Restricted','AllSigned','RemoteSigned','Unrestricted','Bypass','Undefined')] [string]$ExecutionPolicy, [Parameter(Mandatory = $true,ValueFromPipelineByPropertyName)] [string[]]$ImagePath, [Parameter(ValueFromPipelineByPropertyName)] [UInt32]$Index = 1, [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)] [SupportsWildcards()] [String[]]$Name ) begin { #================================================= # Blocks #================================================= Block-WinPE Block-StandardUser #================================================= } process { foreach ($Input in $ImagePath) { #================================================= # Mount-MyWindowsImage #================================================= $MountMyWindowsImage = Mount-MyWindowsImage -ImagePath $Input -Index $Index #================================================= # Copy-PSModuleToFolder #================================================= Copy-PSModuleToFolder -Name $Name -Destination "$($MountMyWindowsImage.Path)\Program Files\WindowsPowerShell\Modules" -RemoveOldVersions #================================================= # Set-WindowsImageExecutionPolicy #================================================= if ($ExecutionPolicy) { Set-WindowsImageExecutionPolicy -ExecutionPolicy $ExecutionPolicy -Path $MountMyWindowsImage.Path } #================================================= # Dismount-MyWindowsImage #================================================= $MountMyWindowsImage | Dismount-MyWindowsImage -Save #================================================= } } end {} } |