The Find-Script cmdlet in PowerShell is designed to locate the scripts in the registered repositories, such as PSGallary. It allows users to search for available scripts using various parameters, including name
, version
, and repository
.
This command is available in the PowerShellGet module.
The Find-Script command without any parameters finds all available scripts in registered repositories.
Find-Script
In this article, we will cover the following topics:
- How to find all available scripts.
- How to find a script by name.
- How to locate a script by name, and version.
PowerShell Find-Script
The Find-Script cmdlet enables users to search for scripts across registered repositories. You can refine your search by using parameters such as:
- Name: Specify the script name.
- RequiredVersion: Specify the exact version of the script.
- MinimumVersion or MaximumVersion: Define a version range.
Script
Find-Script
[[-Name] <String[]>]
[-MinimumVersion <String>]
[-MaximumVersion <String>]
[-RequiredVersion <String>]
[-AllVersions]
[-IncludeDependencies]
[-Filter <String>]
[-Tag <String[]>]
[-Includes <String[]>]
[-Command <String[]>]
[-Proxy <Uri>]
[-ProxyCredential <PSCredential>]
[-Repository <String[]>]
[-Credential <PSCredential>]
[-AllowPrerelease]
[<CommonParameters>]
Let’s understand the Find-Script cmdlet with an example to search the script.
Find all Available Scripts
To list all available scripts in registered repositories, use the Find-Script cmdlet without any parameters.
Find-Script | Select-Object -First 10
In the above PowerShell script,
Find-Script
searches for all scripts in registered repositories and pipes the result to the Select-Object cmdlet. This Select-Object -First 10
limits the results to the first 10 scripts.
Output:
PS C:\> Find-Script | Select-Object -First 10
Version Name Repository Description
------- ---- ---------- -----------
3.5 Get-WindowsAutoPilotInfo PSGallery This script uses WMI to retrieve properties need...
1.1.2 Upload-WindowsAutopilotDeviceInfo PSGallery Gather device hash from local machine and automa...
1.7 New-OnPremiseHybridWorker PSGallery This Azure/OMS Automation runbook onboards a loc...
1.9 Install-VMInsights PSGallery This script installs or re-configures following ...
1.7 install-kubectl PSGallery This script is used during unsattended installs ...
1.0 Test-RPC PSGallery This script tests TCP network connectivity to no...
5.6 Get-AutopilotDiagnostics PSGallery This script displays diagnostics information fro...
1.1 blah PSGallery A handy function for creating a temporary array ...
1.0 SplitDbxContent PSGallery Splits a DBX update package into the new DBX var...
1.1.0.12 0004-New-AzureRmVmAvailabilitySe... PSGallery This script creates an availability set of 1-4 W...
PS C:\>
Find a Script by Name
To locate a specific script, use the Name parameter:
Find-Script -Name "SpeedTest"
In the above PowerShell script, Find-Script uses the Name
parameter for the script name “SpeedTest” and returns the script information as follows.
PS C:\> Find-Script -Name "SpeedTest"
Version Name Repository Description
------- ---- ---------- -----------
2.0 Speedtest PSGallery WAN speed test
PS C:\>
Find Script by Required Version and Name
To find a specific version of a script, combine the Name and RequiredVersion parameters:
Find-Script -Name "SpeedTest" -RequiredVersion 2.0 -Repository PSGallery
In the above PowerShell script, the Find-Script uses the Name
parameter to specify the script name as “SpeedTest“.
The RequiredVersion parameter limits the search to version 2.0 of the script. -Repository PSGallery
searches within the “PSGallery” repository.
The output of the above PowerShell script gets the script from the specified repository as given below.
PS C:\> Find-Script -Name "SpeedTest" -RequiredVersion 2.0 -Repository PSGallery
Version Name Repository Description
------- ---- ---------- -----------
2.0 Speedtest PSGallery WAN speed test
Conclusion
The Find-Script cmdlet is a powerful tool for locating scripts in registered repositories.
- Use Find-Script without parameters to list all scripts.
- Use the Name parameter to locate specific scripts.
- Combine Name and RequiredVersion for precise searches.
You can find more topics about Active Directory tools and PowerShell basics on the ActiveDirectoryTools home page.