Skip to content

Commit 9d9e50e

Browse files
sdwheelerDCtheGeek
authored andcommitted
Improve discussion of scopes (#4773)
* update toc for samples * cleanup build warning related to jea * fix descriptions of multipliers * initial edit * edit 1 * edit 2 * Improve discussion of scopes * editorial feedback
1 parent 52129e3 commit 9d9e50e

File tree

25 files changed

+1333
-1020
lines changed

25 files changed

+1333
-1020
lines changed

reference/3.0/Microsoft.PowerShell.Core/About/about_Modules.md

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
ms.date: 11/29/2017
2+
ms.date: 09/09/2019
33
schema: 2.0.0
44
locale: en-us
55
keywords: powershell,cmdlet
@@ -8,7 +8,6 @@ title: about_Modules
88
# About Modules
99

1010
## Short Description
11-
1211
Explains how to install, import, and use PowerShell modules.
1312

1413
## Long Description
@@ -32,34 +31,35 @@ are added by a module or a snap-in.
3231

3332
## Module Auto-Loading
3433

35-
Beginning in PowerShell 3.0, PowerShell imports modules automatically the
36-
first time that you run any command in an installed module. You can now use
37-
the commands in a module without any set-up or profile configuration, so
38-
there's no need to manage modules after you install them on your computer.
34+
Beginning in PowerShell 3.0, PowerShell imports modules automatically the first
35+
time that you run any command in an installed module. You can now use the
36+
commands in a module without any set-up or profile configuration, so there's no
37+
need to manage modules after you install them on your computer.
3938

4039
The commands in a module are also easier to find. The `Get-Command` cmdlet now
4140
gets all commands in all installed modules, even if they are not yet in the
4241
session, so you can find a command and use it without importing.
4342

44-
Any of the following commands will import a module into your session.
43+
Each of the following examples cause the module containing `Get-Mailbox` to be
44+
imported into your session.
4545

46-
### Run the Command
46+
- Run the Command
4747

48-
```powershell
49-
Get-Mailbox -Identity Chris
50-
```
48+
```powershell
49+
Get-Mailbox -Identity Chris
50+
```
5151

52-
### Get the Command
52+
- Get the Command
5353

54-
```powershell
55-
Get-Command Get-Mailbox
56-
```
54+
```powershell
55+
Get-Command Get-Mailbox
56+
```
5757

58-
### Get Help for the Command
58+
- Get Help for the Command
5959

60-
```powershell
61-
Get-Help Get-Mailbox
62-
```
60+
```powershell
61+
Get-Help Get-Mailbox
62+
```
6363

6464
`Get-Command` commands that include a wildcard character (*) are considered
6565
to be for discovery, not use, and do not import any modules.
@@ -74,9 +74,9 @@ as the `Get-PSSessionConfiguration` cmdlet, you might need to run the
7474
`Import-Module` cmdlet to import the **Microsoft.WSMan.Management** module that
7575
includes the `WSMan:` drive.
7676

77-
You can still run the `Import-Module` command to import a module and
78-
use the `$PSModuleAutoloadingPreference` variable to enable, disable and
79-
configure automatic importing of modules. For more information, see
77+
You can still run the `Import-Module` command to import a module and use the
78+
`$PSModuleAutoloadingPreference` variable to enable, disable and configure
79+
automatic importing of modules. For more information, see
8080
[about_Preference_Variables](about_Preference_Variables.md).
8181

8282
## How to Use a Module
@@ -99,13 +99,13 @@ Most modules are installed for you. PowerShell comes with several preinstalled
9999
modules, sometimes called the "core" modules. On Windows-based computers, if
100100
features that are included with the operating system have cmdlets to manage
101101
them, those modules are preinstalled. When you install a Windows feature, by
102-
using, for example, the Add Roles and Features Wizard in Server Manager, or
103-
the Turn Windows features on or off dialog box in Control Panel, any
104-
PowerShell modules that are part of the feature are installed. Many other
105-
modules come in an installer or Setup program that installs the module.
102+
using, for example, the Add Roles and Features Wizard in Server Manager, or the
103+
Turn Windows features on or off dialog box in Control Panel, any PowerShell
104+
modules that are part of the feature are installed. Many other modules come in
105+
an installer or Setup program that installs the module.
106106

107-
Create a Modules directory for the current user if one does not exist. To
108-
create a Modules directory, type:
107+
Use the following command to create a **Modules** directory for the current
108+
user:
109109

110110
```powershell
111111
New-Item -Type Directory -Path $HOME\Documents\WindowsPowerShell\Modules
@@ -122,21 +122,22 @@ Copy-Item -Path C:\ps-test\MyModule -Destination `
122122
```
123123

124124
You can install a module in any location, but installing your modules in a
125-
default module location makes them easier to manage. For more information
126-
about the default module locations, see the "Module and DSC Resource
127-
Locations, and PSModulePath" section.
125+
default module location makes them easier to manage. For more information about
126+
the default module locations, see the
127+
[Module and DSC Resource Locations, and PSModulePath](#module-and-dsc-resource-locations-and-psmodulepath)
128+
section.
128129

129130
## How to Find Installed Modules
130131

131-
To find modules that are installed in a default module location,
132-
but not yet imported into your session, type:
132+
To find modules that are installed in a default module location, but not yet
133+
imported into your session, type:
133134

134135
```powershell
135136
Get-Module -ListAvailable
136137
```
137138

138-
To find the modules that have already been imported into your session,
139-
at the PowerShell prompt, type:
139+
To find the modules that have already been imported into your session, at the
140+
PowerShell prompt, type:
140141

141142
```powershell
142143
Get-Module
@@ -169,8 +170,8 @@ For more information about the `Get-Command` cmdlet, see
169170
## How to Get Help for the Commands in a Module
170171

171172
If the module contains Help files for the commands that it exports, the
172-
`Get-Help` cmdlet will display the Help topics. Use the same `Get-Help`
173-
command format that you would use to get help for any command in PowerShell.
173+
`Get-Help` cmdlet will display the Help topics. Use the same `Get-Help` command
174+
format that you would use to get help for any command in PowerShell.
174175

175176
Beginning in PowerShell 3.0, you can download Help files for a module and
176177
download updates to the Help files so they are never obsolete.
@@ -226,21 +227,21 @@ into the current session.
226227
Import-Module BitsTransfer
227228
```
228229

229-
To import a module that is not in a default module location, use
230-
the fully qualified path to the module folder in the command.
230+
To import a module that is not in a default module location, use the fully
231+
qualified path to the module folder in the command.
231232

232-
For example, to add the TestCmdlets module in the C:\ps-test directory
233-
to your session, type:
233+
For example, to add the TestCmdlets module in the `C:\ps-test` directory to your
234+
session, type:
234235

235236
```powershell
236237
Import-Module C:\ps-test\TestCmdlets
237238
```
238239

239-
To import a module file that is not contained in a module folder, use
240-
the fully qualified path to the module file in the command.
240+
To import a module file that is not contained in a module folder, use the fully
241+
qualified path to the module file in the command.
241242

242-
For example, to add the TestCmdlets.dll module in the C:\ps-test directory
243-
to your session, type:
243+
For example, to add the TestCmdlets.dll module in the `C:\ps-test` directory to
244+
your session, type:
244245

245246
```powershell
246247
Import-Module C:\ps-test\TestCmdlets.dll
@@ -251,12 +252,9 @@ For more information about adding modules to your session, see
251252

252253
## How to Import a Module into Every Session
253254

254-
The `Import-Module` command imports modules into your current Windows
255-
PowerShell session. This command affects only the current session.
256-
257-
To import a module into every PowerShell session that you
258-
start, add the `Import-Module` command to your PowerShell
259-
profile.
255+
The `Import-Module` command imports modules into your current PowerShell
256+
session. To import a module into every PowerShell session that you start, add
257+
the `Import-Module` command to your PowerShell profile.
260258

261259
For more information about profiles, see [about_Profiles](about_Profiles.md).
262260

@@ -280,32 +278,33 @@ Remove-Module BitsTransfer
280278
```
281279

282280
Removing a module reverses the operation of importing a module. Removing
283-
a module does not uninstall the module. For more information about the
284-
`Remove-Module` cmdlet, see [Remove-Module](../Remove-Module.md).
281+
a module does not uninstall the module. For more information, see
282+
[Remove-Module](../Remove-Module.md).
285283

286284
## Module and DSC Resource Locations, and PSModulePath
287285

288286
The following are default locations for PowerShell modules. Starting in
289287
PowerShell 4.0, with the introduction of DSC, a new default module and DSC
290288
resource folder was introduced. For more information about DSC, see
291-
about_DesiredStateConfiguration.
289+
[about_DesiredStateConfiguration](/powershell/module/Microsoft.PowerShell.Core/About/about_DesiredStateConfiguration).
292290

293-
- System: `$pshome\Modules` or
291+
- System: `$PSHOME\Modules` or
294292
(`$env:windir\System32\WindowsPowerShell\v1.0\Modules`)
295293
System modules are those that ship with Windows and PowerShell.
296294

297295
Starting in PowerShell 4.0, when PowerShell Desired State Configuration
298296
(DSC) was introduced, DSC resources that are included with PowerShell are
299297
also stored in `$PSHOME\Modules`, in the
300-
`$pshome\Modules\PSDesiredStateConfiguration\DSCResources` folder.
298+
`$PSHOME\Modules\PSDesiredStateConfiguration\DSCResources` folder.
301299

302-
- Current user: `$home\Documents\WindowsPowerShell\Modules`
300+
- Current user: `$HOME\Documents\WindowsPowerShell\Modules`
303301
(`$env:UserProfile\Documents\WindowsPowerShell\Modules`)
304302

305303
or
306304

307-
`$home\My Documents\WindowsPowerShell\Modules`
305+
`$HOME\My Documents\WindowsPowerShell\Modules`
308306
(`$env:UserProfile\My Documents\WindowsPowerShell\Modules`)
307+
309308
This is the location for user-added modules prior to PowerShell 4.0.
310309

311310
In PowerShell 4.0 and later releases of PowerShell, user-added modules and DSC
@@ -352,16 +351,16 @@ $Env:PSModulePath + ";C:\ps-test\Modules"
352351
When you add a path to **PSModulePath**, `Get-Module` and `Import-Module`
353352
commands include modules in that path.
354353

355-
The value that you set affects only the current session. To make the
356-
change persistent, add the command to your PowerShell profile
357-
or use System in Control Panel to change the value of the **PSModulePath**
358-
environment variable in the registry.
354+
The value that you set affects only the current session. To make the change
355+
persistent, add the command to your PowerShell profile or use System in Control
356+
Panel to change the value of the **PSModulePath** environment variable in the
357+
registry.
359358

360359
Also, to make the change persistent, you can also use the
361360
**SetEnvironmentVariable** method of the **System.Environment** class to add a
362361
Path to the **PSModulePath** environment variable.
363362

364-
For more information about the PSModulePath variable, see
363+
For more information about the **PSModulePath** variable, see
365364
[about_Environment_Variables](about_Environment_Variables.md).
366365

367366
## Modules and Name Conflicts
@@ -406,10 +405,10 @@ parameters of `Import-Module` to select only the commands that you want to
406405
import, and you can exclude commands that cause name conflicts in your
407406
session.
408407

409-
Module authors can prevent name conflicts by using the DefaultCommandPrefix
408+
Module authors can prevent name conflicts by using the **DefaultCommandPrefix**
410409
property of the module manifest to add a default prefix to all command names.
411-
The value of the Prefix parameter takes precedence over the value of
412-
DefaultCommandPrefix.
410+
The value of the **Prefix** parameter takes precedence over the value of
411+
**DefaultCommandPrefix**.
413412

414413
Even if a command is hidden, you can run it by qualifying the command name
415414
with the name of the module or snap-in in which it originated.
@@ -446,7 +445,7 @@ Get-Command <cmdlet-name> | Format-List -Property verb,noun,pssnapin,module
446445
For example, to find the source of the `Get-Date` cmdlet, type:
447446

448447
```powershell
449-
Get-Command Get-Date | Format-List -Property verb,noun,pssnapin,module
448+
Get-Command Get-Date | Format-List -Property verb,noun,module
450449
```
451450

452451
For more information about PowerShell snap-ins, see
@@ -459,9 +458,9 @@ rules. If the module that you import exports cmdlets or functions that have
459458
unapproved verbs in their names, the `Import-Module` cmdlet displays the
460459
following warning message.
461460

462-
WARNING: Some imported command names include unapproved verbs which might make
463-
them less discoverable. Use the Verbose parameter for more detail or type
464-
`Get-Verb` to see the list of approved verbs.
461+
> WARNING: Some imported command names include unapproved verbs which might
462+
> make them less discoverable. Use the Verbose parameter for more detail or
463+
> type Get-Verb to see the list of approved verbs.
465464
466465
This message is only a warning. The complete module is still imported,
467466
including the non-conforming commands. Although the message is displayed to
@@ -472,18 +471,19 @@ the `Import-Module` cmdlet.
472471

473472
## Built-in Modules and Snap-ins
474473

475-
In PowerShell 2.0 and in older-style host programs in PowerShell 3.0 and
476-
later, the core commands that are installed with PowerShell are packaged in
477-
snap-ins that are added automatically to every PowerShell session.
474+
In PowerShell 2.0 and in older-style host programs in PowerShell 3.0 and later,
475+
the core commands that are installed with PowerShell are packaged in snap-ins
476+
that are added automatically to every PowerShell session.
478477

479478
Beginning in PowerShell 3.0, for host programs that implement the
480479
`InitialSessionState.CreateDefault2` initial session state API the
481-
Microsoft.PowerShell.Core snap-in is added to every session by default.
482-
Modules are loaded automatically on first-use.
480+
Microsoft.PowerShell.Core snap-in is added to every session by default. Modules
481+
are loaded automatically on first-use.
483482

484-
NOTE: Remote sessions, including sessions that are started by using the
485-
`New-PSSession` cmdlet, are older-style sessions in which the built-in
486-
commands are packaged in snap-ins.
483+
> [!NOTE]
484+
> Remote sessions, including sessions that are started by using the
485+
> `New-PSSession` cmdlet, are older-style sessions in which the built-in
486+
> commands are packaged in snap-ins.
487487
488488
The following modules (or snap-ins) are installed with PowerShell.
489489
- Microsoft.PowerShell.Core

0 commit comments

Comments
 (0)