PSScriptTools
:wrench: :hammer: A set of PowerShell functions you might use to enhance your own functions and scripts or to facilitate working in the console. Most should work in both Windows PowerShell and PowerShell 7, even cross-platform. Any operating system limitations should be handled on a per command basis. The Samples folder contains demonstration script files
Install / Use
/learn @jdhitsolutions/PSScriptToolsREADME
PSScriptTools Overview



Abstract
This module contains a collection of functions, variables, and format files that you can use to enhance your PowerShell scripting work or get more done from a PowerShell prompt with less typing. Most of the commands are designed to work cross-platform. Please post any questions, problems, or feedback in the Issues section of this module's GitHub repository. Feedback is greatly appreciated.
The contents of this file and other documentation can be viewed using the Open-PSScriptToolsHelp command. You can also use Get-PSScriptTools to see a summary of module commands.
Please note that code samples have been formatted to fit an *80-character width.* Some example code breaks lines without using line continuation characters. I'm trusting that you can figure out how to run the example.
Table of Contents
- Installation
- General Tools
- File Tools
- Editor Integrations
- Graphical Tools
- Hashtable Tools
- Select Functions
- Time Functions
- Console Utilities
- Format Functions
- Scripting Tools
- CIM Tools
- ANSI Tools
- Other Module Features
- Related Modules
- Compatibility
Installation
You can get the current release from this repository or install this from the PowerShell Gallery:
Install-Module PSScriptTools
or in PowerShell 7:
Install-Module PSScriptTools [-scope CurrentUser] [-force]
Starting in v2.2.0, the module was restructured to better support Desktop and Core editions. However, starting with v2.13.0, the module design has reverted. All module commands will be exported. Anything that is platform-specific should be handled on a per-command basis. It is assumed you will be running this module in Windows PowerShell 5.1 or PowerShell 7.
It is recommended to install this module from the PowerShell Gallery and not GitHub.
To remove the module from your system, you can easily uninstall it with common PowerShell commands.
Get-Module PSScriptTools | Remove-Module
Uninstall-Module PSScriptTools -AllVersions
General Tools
Get-MyCounter
Get-MyCounter is an enhanced version of the legacy Get-Counter cmdlet, which is available on Windows platforms to retrieve performance counter data. One of the challenges with using Get-Counter is how it formats results. The information may be easy to read on the screen, but it is cumbersome to use in a pipelined expression.
Get-MyCounter takes the same information and writes a custom object to the pipeline that is easier to work with. You can pipe counters from Get-Counter to Get-MyCounter.


One advantage of Get-MyCounter over Get-Counter is that the performance data is easier to work with.
Get-MyCounter '\IPv4\datagrams/sec' -MaxSamples 60 -SampleInterval 5 -computer SRV1 | Export-CSV c:\work\srv1_ipperf.csv -NoTypeInformation
In this example, the performance counter is sampled 60 times every 5 seconds and the data is exported to a CSV file which could easily be opened in Microsoft Excel. Here's a sample of the output object.
Computername : SRV1
Category : ipv4
Counter : datagrams/sec
Instance :
Value : 66.0818918347238
Timestamp : 11/4/2022 11:31:29 AM
Get-MyCounter writes a custom object to the pipeline which has an associated formatting file with custom views.

Get-DirectoryInfo
This command, which has an alias of dw, is designed to provide quick access to top-level directory information. The default behavior is to show the total number of files in the immediate directory. Although, the command will also capture the total file size in the immediate directory. You can use the Depth parameter to recurse through a specified number of levels. The default displays use ANSI escape sequences.

The command output will use a wide format by default. However, other wide views are available.

You can use the object in other ways.

Get-FormatView
PowerShell's formatting system includes several custom views that display objects in different ways. Unfortunately, this information is not readily available to a typical PowerShell user. This command displays the available views for a given object type.

This command has an alias of gfv.
Copy-PSFunction
This command is designed to solve the problem when you want to run a function loaded locally on a remote computer. Copy-PSFunction will copy a PowerShell function that is loaded in your current PowerShell session to a remote PowerShell session. The remote session must already be created. The copied function only exists remotely for the duration of the remote PowerShell session.
$s = New-PSSession -ComputerName win10 -cred $art
Copy-PSFunction Get-Status -Session $s
Once copied, you might use Invoke-Command to run it.
Invoke-Command { Get-Status -AsString } -session $s
If the function relies on external or additional files, you will have to copy them to the remote session separately.
Get-PSProfile
This command is designed for Windows systems and makes it easy to identify all possible PowerShell profile scripts. Including those for hosts such as VSCode or the PowerShell ISE. The command writes a custom object to the pipeline which has defined formatting. The default view is a table.
PS C:\> Get-PSProfile
Name: PowerShell
Scope Path Exists
----- ---- ------
AllUsersCurrentHost C:\Program Files\PowerShell\7\Microsoft.PowerShell_profile.ps1 False
AllUsersAllHosts C:\Program Files\PowerShell\7\profile.ps1 False
CurrentUserAllHosts C:\Users\Jeff\Documents\PowerShell\profile.ps1 True
CurrentUserCurrentHost C:\Users\Jeff\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 True
Name: Windows PowerShell
Scope Path Exists
----- ---- ------
AllUsersCurrentHost C:\WINDOWS\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell... True
AllUsersAllHosts C:\WINDOWS\System32\WindowsPowerShell\v1.0\profile.ps1 True
CurrentUserAllHosts C:\Users\Jeff\Documents\WindowsPowerShell\profile.ps1 True
CurrentUserCurrentHost C:\Users\Jeff\Documents\WindowsPowerShell\Microsoft.PowerShell_p... True
There is also a list view.
PS C:\> Get-PSProfile | Where-Object {$_.name -eq 'powershell'} | Format-List
Name: PowerShell
Scope : AllUsersCurrentHost
Path : C:\Program Files\PowerShell\7\Microsoft.PowerShell_profile.ps1
Exists : False
LastModified :
Scope : AllUsersAllHosts
Path : C:\Program Files\PowerShell\7\profile.ps1
Exists : False
LastModified :
Scope : CurrentUserAllHosts
Path : C:\Users\Jeff\Documents\PowerShell\profile.ps1
Exists : True
LastModified : 9/9/2024 2:35:45 PM
Scope : CurrentUserCurrentHost
Path : C:\Users\Jeff\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
Exists : True
LastModified : 9/9/2024 2:03:44 PM
Get-MyAlias
Often you might define aliases for functions and scripts you use all of the time. It may be difficult sometimes to remember them all or to find them in the default Get-Alias output. This command will list all currently defined aliases that are not part of the initial PowerShell state.

These are all aliases defined in the current session that aren't part of the initial session state. You can filter aliases to make it easier to find those that aren't defined in a module. These aliases should be ones created in your stand-alone scripts or PowerShell profile.

The PSScriptTools module also includes a custom formatting file for alias objects which you can use with Get-Alias or Get-MyAlias.
Get-Alias | Sort-Object Source | Format-Table -View source

This command has an alias of gma.
Get-ModuleCommand
This is an alternative to Get-Command to make it easier to see at a glance what commands are contained within a module and what they can do. By default, Get-ModuleCommand looks for loaded modules. Use -ListAvailable to see commands in the module not currently loaded. Note that if the help file is malformed or missing, you might get oddly formatted results.
PS C:\> Get-ModuleCommand PSCalendar -ListAvailable
ModuleName: PSCalendar [v2.9.0]
Name A
Related Skills
node-connect
337.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
337.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.2kCommit, push, and open a PR
