-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathClear-AllPsHistory.psm1
52 lines (36 loc) · 1.24 KB
/
Clear-AllPsHistory.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<#
.SYNOPSIS
Clear-AllPsHistory is used to clear the contents of a computers PowerShell command history file and the shell's current command history.DESCRIPTION
.DESCRIPTION
Clears the contents of PowerShell's history file and the shell history.
.INPUTS
Does not accept any pipeline input.
.OUTPUTS
No Output. This clears PowerShell command history.
.NOTES
Author: Robert H. Osborne
Alias: tobor
Contact: [email protected]
.LINK
https://osbornepro.com
https://writeups.osbornepro.com
https://btpssecpack.osbornepro.com
https://github.com/tobor88
https://gitlab.com/tobor88
https://www.powershellgallery.com/profiles/tobor
https://www.linkedin.com/in/roberthosborne/
https://www.credly.com/users/roberthosborne/badges
https://www.hackthebox.eu/profile/52286
.EXAMPLE
-------------------------- EXAMPLE 1 --------------------------
C:\PS> Clear-AllPsHistory -Verbose
This command clears all PowerShell command history and shows the steps verbosely.
#>
Function Clear-AllPsHistory {
$History = Get-PSReadlineOption
$HistoryFile = $History.HistorySavePath
Write-Verbose 'Clearing Console history...'
Clear-History
Write-Verbose "Emptying contents of $HistoryFile"
Clear-Content -Path $HistoryFile -Force
} # End Function