# The PowerShell Gallery

The **PowerShell Gallery** is the central public repository for PowerShell modules, scripts, and other resources. It’s a hub where developers, IT professionals, and enthusiasts share their work, making it easier for others to find and use pre-built solutions. The gallery is sponsored and funded by Microsoft, ensuring its reliability and accessibility.

***

#### **What is the PowerShell Gallery?**

The PowerShell Gallery is a repository that hosts:

* **Modules**: Collections of cmdlets, functions, and other resources.
* **Scripts**: Standalone PowerShell scripts for specific tasks.
* **DSC Resources**: Desired State Configuration resources for automating system configurations.

It includes contributions from Microsoft, third-party companies, and the PowerShell community. Many projects on the gallery originate from **GitHub**, where they are developed as open-source projects.

***

#### **Accessing the PowerShell Gallery**

You can access the PowerShell Gallery in two ways:

1. **Via the Website**: Visit [www.PowerShellGallery.com](https://www.powershellgallery.com/) to browse and search for modules and scripts.
2. **Via PowerShell**: Use PowerShell cmdlets to search, download, and install modules and scripts directly from the gallery.

***

#### **Searching the PowerShell Gallery**

**Using the Website**

The website allows you to filter and search for modules and scripts using keywords. It’s user-friendly and provides detailed information about each item, including version history, dependencies, and installation instructions.

**Using PowerShell**

You can search the gallery directly from PowerShell using the following cmdlets:

* **Find-Module**: Searches for modules.
* **Find-Script**: Searches for scripts.

For example:

<pre><code>Find-<a data-footnote-ref href="#user-content-fn-1">Module </a>-Name "Azure"
</code></pre>

This command searches for modules related to Azure.

***

#### **Downloading and Installing Modules/Scripts**

**Saving Modules/Scripts**

To download a module or script without installing it, use:

```
Save-Module -Name SomeModule -Path C:\SomeLocalFolder
Save-Script -Name SomeScript -Path C:\SomeLocalFolder
```

This saves the module or script to the specified folder for testing or offline use.

**Installing Modules/Scripts**

To install a module or script for use in PowerShell, use:

* **For Current User** (does not require admin rights):

  ```
  Install-Module -Scope CurrentUser -Name SomeModule
  Install-Script -Scope CurrentUser -Name SomeScript
  ```
* **For All Users** (requires admin rights):

  ```
  Install-Module -Scope AllUsers -Name SomeModule
  Install-Script -Scope AllUsers -Name SomeScript
  ```

**Default Installation Paths**

* **Modules**:
  * Current User: `$env:USERPROFILE\Documents\WindowsPowerShell\Modules`
  * All Users: `$env:ProgramFiles\WindowsPowerShell\Modules`
* **Scripts**:
  * Current User: `$env:USERPROFILE\Documents\WindowsPowerShell\Scripts`
  * All Users: `$env:ProgramFiles\WindowsPowerShell\Scripts`

***

#### **Managing Installed Modules/Scripts**

**Listing Installed Modules/Scripts**

To see which modules and scripts are installed from the gallery:

```
Get-InstalledModule
Get-InstalledScript
```

**Updating Modules/Scripts**

To update all installed modules and scripts:

```
Update-Module
Update-Script
```

To update a specific module or script:

```
Update-Module -Name SomeModule
Update-Script -Name SomeScript
```

**Uninstalling Modules/Scripts**

To remove a module or script:

```
Uninstall-Module -Name SomeModule
Uninstall-Script -Name SomeScript
```

***

#### **Overlapping Names**

If two modules contain functions or cmdlets with the same name, the last module loaded takes precedence. To avoid conflicts, you can explicitly call a function or cmdlet from a specific module using the module name as a namespace:

```
Module1\Ping
Module2\Ping
```

***

#### **PowerShellGet and PackageManagement**

The **PowerShellGet** module provides cmdlets for interacting with the PowerShell Gallery. Under the hood, it relies on the **PackageManagement** module, which handles package providers and sources.

**Package Providers**

A **package provider** is a DLL that allows PowerShell to work with specific package formats (e.g., NuGet, MSI). To see installed providers:

```
Get-PackageProvider
```

**Package Sources**

A **package source** is a repository (like the PowerShell Gallery or NuGet) that hosts packages. To see available sources:

```
Get-PackageSource
```

***

#### **NuGet and Other Repositories**

**NuGet** is a popular package manager for .NET developers. It’s also integrated with PowerShell, allowing you to search and install NuGet packages:

```
Find-Package -Source nuget.org -Name "*Numerics*"
Install-Package -Source nuget.org -Name "MathNet.Numerics" -Destination C:\SomeFolder
```

***

#### **Snap-Ins (Deprecated)**

Before modules, PowerShell used **snap-ins** to extend functionality. Snap-ins are compiled DLLs that require installation and registry modifications. While still supported, they are deprecated in favor of modules.

**Listing Snap-Ins**

To see loaded snap-ins:

```
Get-PSSnapin
```

**Loading Snap-Ins**

To load a snap-in:

```
Add-PSSnapin Quest.ActiveRoles.ADManagement
```

[^1]:


---

# 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://mohab-yehia.gitbook.io/sec505/welcome-to-securing-windows-with-powershell-a-deep-dive-into-sec505/sec-505.1/the-powershell-gallery.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.
