You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit dcc15df
Browse filesBrowse the repository at this point in the historyBrowse files
Create a JSON file containing module found in $pshome and their corresponding exported commands
4
-
5
-
.EXAMPLE
6
-
C:\PS> ./New-CommandDataFile.ps1
7
-
8
-
Suppose this file is run on the following version of PowerShell: PSVersion = 6.1.0, PSEdition = Core, and Windows 10 operating system. Then this script will create a file named core-6.1.0-windows.json that contains a JSON object of the following form:
9
-
{
10
-
"Modules" : [
11
-
"Module1" : {
12
-
"Name" : "Module1"
13
-
.
14
-
.
15
-
"ExportedCommands" : {...}
16
-
}
17
-
.
18
-
.
19
-
.
20
-
]
21
-
"JsonVersion" : "0.0.1"
22
-
}
1
+
[OutputType([System.IO.FileInfo])]
2
+
[CmdletBinding()]
3
+
param(
4
+
[string]$OutputPath='./'# Default is current directory
5
+
)
23
6
24
-
.INPUTS
25
-
None
7
+
functionNew-CommandDataFile {
8
+
<#
9
+
.SYNOPSIS
10
+
Create a JSON file containing modules found in $PSHOME and their corresponding exported
11
+
commands and aliases.
26
12
27
-
.OUTPUTS
28
-
None
13
+
.DESCRIPTION
14
+
This script creates a JSON file containing modules found in $PSHOME and their corresponding
15
+
exported commands and aliases. The JSON file is created in the current directory by default.
16
+
Be sure to run this script in a clean PowerShell session to avoid picking up any aliases
17
+
that may have been added by the user's profile script.
29
18
30
-
#>
19
+
.PARAMETEROutputPath
20
+
The path where the JSON file is created. If not specified, the file is created in the
21
+
current directory.
31
22
32
-
$jsonVersion="0.0.1"
33
-
$builtinModulePath=Join-Path$pshome'Modules'
34
-
if (-not (Test-Path$builtinModulePath))
35
-
{
36
-
throw new "$builtinModulePath does not exist! Cannot create command data file."
0 commit comments