To export the list of PowerShell modules installed on your Windows Server 2012 R2 machine, you can use the Get-Module
cmdlet with the -ListAvailable
parameter to retrieve a list of all installed modules. You can then export this list to a text file for reference.
Run the following command to retrieve a list of installed PowerShell modules:
Get-Module -ListAvailable | Select-Object Name, Version | Export-Csv -Path C:\Path\To\Export\Modules.csv -NoTypeInformation
Copy the exported Modules.csv
file to your new Windows Server 2019 VM.
On your new VM running Windows Server 2019, open PowerShell as an administrator.
Run the following command to install the PowerShell modules listed in the Modules.csv
file:
$modules = Import-Csv -Path C:\Path\To\Export\Modules.csv
foreach ($module in $modules) {
Install-Module -Name $module.Name -Scope AllUsers -Force
}
You can bypass the dxecution policy by using the -ExecutionPolicy Bypass
parameter with the powershell.exe
command in your Task Scheduler action.
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin