The PowerShell Gallery serves as a central hub housing a vast collection of PowerShell content, containing scripts, modules, and DSC resources crafted by both Microsoft and the thriving PowerShell community. You can use the PowerShellGet module to discover, install, update, and publish packages from the PowerShell Gallery.
Prerequisites For Downloading the Packages from PowerShell Gallery
Before you can download packages from the PowerShell Gallery for inspection, you need to have the following prerequisites:
A Windows computer with PowerShell 5.0 or higher, or a Linux or macOS computer with PowerShell Core 6.0 or higher. You can check the version of your PowerShellGet module by running:
If you need to update your PowerShellGet module, you can run:
How to Download Packages from PowerShell Gallery
The Save-Module and Save-Script cmdlets download and save a package from the PowerShell Gallery to a specified path on your computer without installing it. Here is the syntax for the command to find the respective module in PowerShell Gallery:
Now once you have found the respective module in the PowerShell gallery then to download it follow the below given syntax:
For example, if you want to download and inspect a module called PSWindowsUpdate, which allows you to manage Windows updates from PowerShell. First find the PSWindowsUpdate module in the PowerShell Gallery and for that execute:
Now download and save the PSWindowsUpdate module from the PowerShell Gallery to a local folder
Now you can verify that the module is saved in the given directory by navigating to that directory through Windows explorer:
Similarly, if you want to download and inspect a script called Get-WindowsAutoPilotInfo, which retrieves information about Windows updates on your computer, find the Get-WindowsAutoPilotInfo script in the PowerShell Gallery using:
Now download and save the Get-WindowsAutoPilotInfo script from the PowerShell Gallery to a local folder using:
Now you can verify that the script is saved in the given directory by navigating to that directory and executing the ls command:
Conclusion
To download packages from the PowerShell Gallery for inspection use the PowerShellGet module. Use the cmdlets like Save-Script or Save-Module, depending on the package type, to download a package from the gallery for inspection. This will save the package locally without installing it, so you can inspect the package contents.