Repository navigation
Expand file tree
/
Copy pathStart-MSADPT.ps1
More file actions
62 lines (49 loc) · 1.65 KB
/
Copy pathStart-MSADPT.ps1
File metadata and controls
62 lines (49 loc) · 1.65 KB
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
<#
.SYNOPSIS
Starts a read-only MSADPT Active Directory assessment engagement.
.DESCRIPTION
Imports the MSADPT controller and starts a new read-only assessment. By default,
Active Directory queries use the current Windows identity. Supply -Credential only
when an explicitly authorized alternate credential is required.
.VERSION
0.2.0
#>
[CmdletBinding()]
param(
[Parameter()]
[PSCredential]$Credential,
[Parameter()]
[string]$DomainFQDN,
[Parameter()]
[string]$AdServer,
[Parameter()]
[ValidateNotNullOrEmpty()]
[string]$EngagementName = 'MSADPT-ReadOnly-Assessment',
[Parameter()]
[ValidateNotNullOrEmpty()]
[string]$OutputRoot = (Join-Path -Path $PSScriptRoot -ChildPath 'Engagements'),
[Parameter()]
[switch]$SkipAdminCheck
)
Set-StrictMode -Version 2.0
$ErrorActionPreference = 'Stop'
$ControllerPath = Join-Path -Path $PSScriptRoot -ChildPath 'Controller\MSADPT.Controller.psm1'
if (-not (Test-Path -LiteralPath $ControllerPath -PathType Leaf)) {
throw "Required controller module not found: $ControllerPath"
}
Import-Module $ControllerPath -Force -ErrorAction Stop
$AssessmentParameters = @{
EngagementName = $EngagementName
OutputRoot = $OutputRoot
SkipAdminCheck = $SkipAdminCheck
}
if ($PSBoundParameters.ContainsKey('Credential') -and $null -ne $Credential) {
$AssessmentParameters.Credential = $Credential
}
if (-not [string]::IsNullOrWhiteSpace($DomainFQDN)) {
$AssessmentParameters.DomainFQDN = $DomainFQDN
}
if (-not [string]::IsNullOrWhiteSpace($AdServer)) {
$AssessmentParameters.AdServer = $AdServer
}
Invoke-MSADPTAssessment @AssessmentParameters