-
-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathExport-RevertScript.ps1
81 lines (69 loc) · 2.39 KB
/
Export-RevertScript.ps1
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
function Export-RevertScript {
<#
.SYNOPSIS
Creates a script that reverts the changes performed by Locksmith.
.DESCRIPTION
This script is used to revert changes performed by Locksmith.
It takes in various arrays of objects representing auditing issues and ESC misconfirugrations.
It creates a new script called 'Invoke-RevertLocksmith.ps1' and adds the necessary commands
to revert the changes made by Locksmith.
.PARAMETER AuditingIssues
An array of auditing issues to be reverted.
.PARAMETER ESC1
An array of ESC1 changes to be reverted.
.PARAMETER ESC2
An array of ESC2 changes to be reverted.
.PARAMETER ESC3
An array of ESC3 changes to be reverted.
.PARAMETER ESC4
An array of ESC4 changes to be reverted.
.PARAMETER ESC5
An array of ESC5 changes to be reverted.
.PARAMETER ESC6
An array of ESC6 changes to be reverted.
.PARAMETER ESC11
An array of ESC11 changes to be reverted.
.PARAMETER ESC13
An array of ESC13 changes to be reverted.
.EXAMPLE
$params = @{
AuditingIssues = $AuditingIssues
ESC1 = $ESC1
ESC2 = $ESC2
ESC3 = $ESC3
ESC4 = $ESC4
ESC5 = $ESC5
ESC6 = $ESC6
ESC11 = $ESC11
ESC13 = $ESC13
}
Export-RevertScript @params
Reverts the changes performed by Locksmith using the specified arrays of objects.
#>
[CmdletBinding()]
param(
[array]$AuditingIssues,
[array]$ESC1,
[array]$ESC2,
[array]$ESC3,
[array]$ESC4,
[array]$ESC5,
[array]$ESC6,
[array]$ESC11,
[array]$ESC13
)
begin {
$Output = 'Invoke-RevertLocksmith.ps1'
$RevertScript = [System.Text.StringBuilder]::New()
[void]$RevertScript.Append("<#`nScript to revert changes performed by Locksmith`nCreated $(Get-Date)`n#>`n")
$Objects = $AuditingIssues + $ESC1 + $ESC2 + $ESC3 + $ESC4 + $ESC5 + $ESC6 + $ESC11 + $ESC13
}
process {
if ($Objects) {
$Objects | ForEach-Object {
[void]$RevertScript.Append("$($_.Revert)`n")
}
$RevertScript.ToString() | Out-File -FilePath $Output
}
}
}