Skip to content

Commit 1e2011c

Browse files
davidsmatlaksdwheeler
authored andcommitted
issue 4834, 4835, 4836 (#4846)
1 parent 6ba8f28 commit 1e2011c

File tree

5 files changed

+368
-324
lines changed

5 files changed

+368
-324
lines changed

reference/5.1/Microsoft.PowerShell.Core/About/about_Logging.md

Lines changed: 62 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,31 @@ title: about_Logging
88

99
# About Logging
1010

11-
## Short Description
11+
## Short description
1212

1313
PowerShell logs internal operations from the engine, providers, and cmdlets.
1414

15-
## Long Description
15+
## Long description
1616

17-
PowerShell logs details of PowerShell operations, such as starting and
18-
stopping the engine and starting and stopping providers. It will also log
19-
details about PowerShell commands.
17+
PowerShell logs details about PowerShell operations, such as starting and
18+
stopping the engine and providers, and executing PowerShell commands.
19+
20+
> [!NOTE]
21+
> Windows PowerShell versions 3.0, 4.0, 5.0, and 5.1 include **EventLog**
22+
> cmdlets for the Windows event logs. In those versions, to display the list of
23+
> **EventLog** cmdlets type: `Get-Command -Noun EventLog`. For more
24+
> information, see the cmdlet documentation and about_EventLogs for your
25+
> version of Windows PowerShell.
2026
2127
## Viewing the PowerShell event log entries on Windows
2228

23-
PowerShell logs can be viewed using the Event Viewer. The event log is located
24-
in the Application and Services Logs group and is named
29+
PowerShell logs can be viewed using the Windows Event Viewer. The event log is
30+
located in the Application and Services Logs group and is named
2531
`Microsoft-Windows-PowerShell`. The associated ETW provider `GUID` is
2632
`{A0C1853B-5C40-4B15-8766-3CF1C58F985A}`.
2733

28-
When script block logging is enabled, PowerShell will log the following events
29-
to the `Microsoft-Windows-PowerShell/Operational` log:
34+
When Script Block Logging is enabled, PowerShell logs the following events to
35+
the `Microsoft-Windows-PowerShell/Operational` log:
3036

3137
|Field| Value|
3238
|-|-|
@@ -39,18 +45,21 @@ to the `Microsoft-Windows-PowerShell/Operational` log:
3945

4046
## Enabling Script Block Logging
4147

42-
Any new PowerShell session will pick up the new setting after making one of the
43-
following changes.
48+
When you enable Script Block Logging, PowerShell records the content of all
49+
script blocks that it processes. Once enabled, any new PowerShell session logs
50+
this information.
4451

4552
> [!NOTE]
46-
> It is recommended to enable Protected Event Logging (as described below) when
47-
> using Script Block logging for anything other than diagnostics purposes.
53+
> It's recommended to enable Protected Event Logging, as described below, when
54+
> using Script Block Logging for anything other than diagnostics purposes.
55+
56+
Script Block Logging can be enabled via Group Policy or a registry setting.
4857

4958
### Using Group Policy
5059

51-
To enable automatic transcription, enable the 'Turn on PowerShell Script Block
52-
Logging' feature in Group Policy through `Administrative Templates ->
53-
Windows Components -> Windows PowerShell`.
60+
To enable automatic transcription, enable the `Turn on PowerShell Script Block
61+
Logging` feature in Group Policy through `Administrative Templates -> Windows
62+
Components -> Windows PowerShell`.
5463

5564
### Using the Registry
5665

@@ -73,70 +82,67 @@ function Enable-PSScriptBlockLogging
7382

7483
## Protected Event Logging
7584

76-
One concern when increasing the amount of logging on a system is the danger
77-
that logged content may contain sensitive data. For example, if you log the
78-
content of every PowerShell script that was run, there is the possibility that
79-
a script may contain credentials or other sensitive data.
85+
Increasing the level of logging on a system increases the possibility that
86+
logged content may contain sensitive data. For example, with script logging
87+
enabled, credentials or other sensitive data used by a script can be written to
88+
the event log. When a machine that has logged sensitive data is compromised,
89+
the logs can provide an attacker with information needed to extend their reach.
8090

81-
If an attacker later compromises a machine that has logged this data, it may
82-
provide them with additional information with which to extend their reach.
83-
84-
To prevent this dilemma, Windows 10 introduces Protected Event Logging.
91+
To protect this information, Windows 10 introduces Protected Event Logging.
8592
Protected Event Logging lets participating applications encrypt sensitive data
86-
as they write it to the event log. You can then decrypt and process these logs
87-
once you've moved them to a more secure and centralized log collector.
88-
89-
Protected Event Logging protects event log content through the IETF
90-
Cryptographic Message Syntax (CMS) standard. The CMS encryption standard
91-
implements public key cryptography, where the keys used to encrypt content
92-
(the public key) and the keys used to decrypt content (the private key) are
93-
separate.
94-
95-
Your public key can be shared widely, and is not sensitive data. If any
96-
content is encrypted with this public key, only your private key can decrypt
97-
it. For more information about Public Key Cryptography, see
93+
written to the event log. Later, you can decrypt and process these logs on a
94+
more secure and centralized log collector.
95+
96+
Event log content is protected using the IETF Cryptographic Message Syntax
97+
(CMS) standard. CMS uses public key cryptography. The keys used to encrypt
98+
content and decrypt content are kept separate.
99+
100+
The public key can be shared widely and isn't sensitive data. Any content
101+
encrypted with this public key can only be decrypted by the private key. For
102+
more information about Public Key Cryptography, see
98103
[Wikipedia - Public Key Cryptography](https://en.wikipedia.org/wiki/Public-key_cryptography).
99104

100-
When you implement a protected event logging policy, you deploy a public key
101-
to all machines that have event log data you want to protect. You retain the
102-
corresponding private key to post-process the event logs at a more secure
103-
location such as a central event log collector,
104-
or [SIEM](https://en.wikipedia.org/wiki/Security_information_and_event_management) aggregator.
105+
To enable a Protected Event Logging policy, deploy a public key to all machines
106+
that have event log data to protect. The corresponding private key is used to
107+
post-process the event logs at a more secure location such as a central event
108+
log collector, or [SIEM](https://en.wikipedia.org/wiki/Security_information_and_event_management)
109+
aggregator.
105110

106111
### Enabling Protected Event Logging via Group Policy
107112

108113
To enable Protected Event Logging, enable the `Enable Protected Event Logging`
109-
feature in Group Policy through `Administrative Templates ->
110-
Windows Components -> Event Logging`. This setting requires an encryption certificate,
111-
which you can provide in one of several forms:
114+
feature in Group Policy through `Administrative Templates -> Windows Components
115+
-> Event Logging`. This setting requires an encryption certificate, which you
116+
can provide in one of several forms:
112117

113118
- The content of a base-64 encoded X.509 certificate (for example, as offered
114-
by the `Export` option in Certificate Manager)
119+
by the `Export` option in Certificate Manager).
115120
- The thumbprint of a certificate that can be found in the Local Machine
116-
certificate store (can be deployed by PKI infrastructure)
117-
- The full path to a certificate (can be local, or a remote share)
121+
certificate store (can be deployed by PKI infrastructure).
122+
- The full path to a certificate (can be local, or a remote share).
118123
- The path to a directory containing a certificate or certificates (can be
119-
local, or a remote share)
124+
local, or a remote share).
120125
- The subject name of a certificate that can be found in the Local Machine
121-
certificate store (can be deployed by PKI infrastructure)
126+
certificate store (can be deployed by PKI infrastructure).
122127

123128
The resulting certificate must have `Document Encryption` as an enhanced key
124-
usage (`1.3.6.1.4.1.311.80.1`), as well as either `Data Encipherment` or `Key
129+
usage (`1.3.6.1.4.1.311.80.1`), and either `Data Encipherment` or `Key
125130
Encipherment` key usages enabled.
126131

127132
> [!WARNING]
128-
> The private key should not be deployed to machines logging.
129-
> It should be kept in a secure location where you decrypt the messages.
133+
> The private key shouldn't be deployed to the machines logging events. It
134+
> should be kept in a secure location where you decrypt the messages.
130135
131-
### Decrypting Protected Event Log Messages
136+
### Decrypting Protected Event Logging messages
132137

133-
The following script will retrieve and decrypt (assuming you have the private key):
138+
The following script will retrieve and decrypt, assuming that you have the
139+
private key:
134140

135141
```powershell
136142
Get-WinEvent Microsoft-Windows-PowerShell/Operational |
137143
Where-Object Id -eq 4104 | Unprotect-CmsMessage
138144
```
139145

140-
## See Also
146+
## See also
141147

142-
[PowerShell the Blue Team](https://blogs.msdn.microsoft.com/powershell/2015/06/09/powershell-the-blue-team/)
148+
[PowerShell the Blue Team](https://devblogs.microsoft.com/powershell/powershell-the-blue-team/)

0 commit comments

Comments
 (0)