Skip to content

Commit 3f9fb8b

Browse files
author
ScriptRunner
authored
Merge pull request #13 from scriptrunner/master
Add use case AD user exipres
2 parents b40d750 + 7a68e3b commit 3f9fb8b

6 files changed

Lines changed: 407 additions & 1 deletion

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
5+
---
6+
7+
**Describe the bug**
8+
A clear and concise description of what the bug is.
9+
10+
**To Reproduce**
11+
Steps to reproduce the behavior:
12+
1. Go to '...'
13+
2. Click on '....'
14+
3. Scroll down to '....'
15+
4. See error
16+
17+
**Expected behavior**
18+
A clear and concise description of what you expected to happen.
19+
20+
**Screenshots**
21+
If applicable, add screenshots to help explain your problem.
22+
23+
**Desktop (please complete the following information):**
24+
- OS: [e.g. iOS]
25+
- Browser [e.g. chrome, safari]
26+
- Version [e.g. 22]
27+
28+
**Smartphone (please complete the following information):**
29+
- Device: [e.g. iPhone6]
30+
- OS: [e.g. iOS8.1]
31+
- Browser [e.g. stock browser, safari]
32+
- Version [e.g. 22]
33+
34+
**Additional context**
35+
Add any other context about the problem here.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
5+
---
6+
7+
**Is your feature request related to a problem? Please describe.**
8+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9+
10+
**Describe the solution you'd like**
11+
A clear and concise description of what you want to happen.
12+
13+
**Describe alternatives you've considered**
14+
A clear and concise description of any alternative solutions or features you've considered.
15+
16+
**Additional context**
17+
Add any other context or screenshots about the feature request here.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: Use Case Request
3+
about: Eine neue Aktion/Anwendungsfall zur Umsetzung mit ScriptRunner beauftragen.
4+
5+
---
6+
7+
**Primäre Anwendergruppe**
8+
An welche Anwendergruppe soll die Aktion delegiert werden?
9+
- [ ] Help Desk / Service Hotline / First-Level-Support
10+
- [ ] Second-Level-Support
11+
- [ ] Fachbereich
12+
- [ ] Endbenutzer
13+
- [ ] Administratoren
14+
15+
**Kurzbeschreibung**
16+
Eine kurze Erläuterung des gewünschten Anwendungsfalls.
17+
18+
**Skriptparameter**
19+
Eine Auflistung, der erforderlichen Skriptparameter inkl. Beschreibung und Typ.
20+
21+
**Zielsysteme und Credentials**
22+
Auf welchen Zielsystemen und mit welchen Credentials soll der Anwendungsfall ausgeführt werden?
23+
24+
**Voraussetzungen**
25+
Voraussetzungen auf dem Zielsystem / Credentials / Infrastruktur / etc.
26+
27+
**Screenshots**
28+
Screenshots, die helfen den Anwendungsfall genauer zu Beschreiben.
29+
30+
**Weitere Anmerkungen**
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
#Requires -Version 4.0
2+
#Requires -Modules ActiveDirectory
3+
4+
<#
5+
.SYNOPSIS
6+
Lists computers where disabled or inactive
7+
8+
.DESCRIPTION
9+
10+
.NOTES
11+
This PowerShell script was developed and optimized for ScriptRunner. The use of the scripts requires ScriptRunner.
12+
The customer or user is authorized to copy the script from the repository and use them in ScriptRunner.
13+
The terms of use for ScriptRunner do not apply to this script. In particular, AppSphere AG assumes no liability for the function,
14+
the use and the consequences of the use of this freely available script.
15+
PowerShell is a product of Microsoft Corporation. ScriptRunner is a product of AppSphere AG.
16+
© AppSphere AG
17+
18+
.COMPONENT
19+
Requires Module ActiveDirectory
20+
21+
.LINK
22+
https://github.com/scriptrunner/ActionPacks/tree/master/ActiveDirectory/Computers
23+
24+
.Parameter OUPath
25+
Specifies the AD path
26+
27+
.Parameter DomainAccount
28+
Active Directory Credential for remote execution on jumphost without CredSSP
29+
30+
.Parameter Disabled
31+
Shows the disabled computers
32+
33+
.Parameter InActive
34+
Shows the inactive computers
35+
36+
.Parameter DomainName
37+
Name of Active Directory Domain
38+
39+
.Parameter SearchScope
40+
Specifies the scope of an Active Directory search
41+
42+
.Parameter AuthType
43+
Specifies the authentication method to use
44+
#>
45+
46+
param(
47+
[Parameter(Mandatory = $true,ParameterSetName = "Local or Remote DC")]
48+
[Parameter(Mandatory = $true,ParameterSetName = "Remote Jumphost")]
49+
[string]$OUPath,
50+
[Parameter(ParameterSetName = "Local or Remote DC")]
51+
[Parameter(ParameterSetName = "Remote Jumphost")]
52+
[switch]$Disabled,
53+
[Parameter(ParameterSetName = "Local or Remote DC")]
54+
[Parameter(ParameterSetName = "Remote Jumphost")]
55+
[switch]$InActive,
56+
[Parameter(Mandatory = $true,ParameterSetName = "Remote Jumphost")]
57+
[PSCredential]$DomainAccount,
58+
[Parameter(ParameterSetName = "Local or Remote DC")]
59+
[Parameter(ParameterSetName = "Remote Jumphost")]
60+
[string]$DomainName,
61+
[Parameter(ParameterSetName = "Local or Remote DC")]
62+
[Parameter(ParameterSetName = "Remote Jumphost")]
63+
[ValidateSet('Base','OneLevel','SubTree')]
64+
[string]$SearchScope='SubTree',
65+
[Parameter(ParameterSetName = "Local or Remote DC")]
66+
[Parameter(ParameterSetName = "Remote Jumphost")]
67+
[ValidateSet('Basic', 'Negotiate')]
68+
[string]$AuthType="Negotiate"
69+
)
70+
71+
Import-Module ActiveDirectory
72+
73+
#Clear
74+
#$ErrorActionPreference='Stop'
75+
try{
76+
$resultMessage = @()
77+
if($PSCmdlet.ParameterSetName -eq "Remote Jumphost"){
78+
if([System.String]::IsNullOrWhiteSpace($DomainName)){
79+
$Domain = Get-ADDomain -Current LocalComputer -AuthType $AuthType -Credential $DomainAccount -ErrorAction Stop
80+
}
81+
else{
82+
$Domain = Get-ADDomain -Identity $DomainName -AuthType $AuthType -Credential $DomainAccount -ErrorAction Stop
83+
}
84+
if([System.String]::IsNullOrWhiteSpace($OUPath)){
85+
$OUPath = $Domain.DistinguishedName
86+
}
87+
if($Disabled -eq $true){
88+
$computers = Search-ADAccount -Credential $DomainAccount -Server $Domain.PDCEmulator -AuthType $AuthType -AccountDisabled -ComputersOnly `
89+
-SearchBase $OUPath -SearchScope $SearchScope | Select-Object DistinguishedName, SAMAccountName | Sort-Object -Property SAMAccountName
90+
if($computers){
91+
foreach($itm in $computers){
92+
$resultMessage = $resultMessage + ("Disabled: " + $itm.DistinguishedName + ';' +$itm.SamAccountName)
93+
}
94+
$resultMessage = $resultMessage + ''
95+
}
96+
}
97+
if($InActive -eq $true){
98+
$computers = Search-ADAccount -Credential $DomainAccount -Server $Domain.PDCEmulator -AuthType $AuthType -AccountInactive -ComputersOnly `
99+
-SearchBase $OUPath -SearchScope $SearchScope | Select-Object DistinguishedName, SAMAccountName | Sort-Object -Property SAMAccountName
100+
if($computers){
101+
foreach($itm in $computers){
102+
$resultMessage = $resultMessage + ("Inactive: " + $itm.DistinguishedName + ';' +$itm.SamAccountName)
103+
}
104+
}
105+
}
106+
}
107+
else{
108+
if([System.String]::IsNullOrWhiteSpace($DomainName)){
109+
$Domain = Get-ADDomain -Current LocalComputer -AuthType $AuthType -ErrorAction Stop
110+
}
111+
else{
112+
$Domain = Get-ADDomain -Identity $DomainName -AuthType $AuthType -ErrorAction Stop
113+
}
114+
if([System.String]::IsNullOrWhiteSpace($OUPath)){
115+
$OUPath = $Domain.DistinguishedName
116+
}
117+
if($Disabled -eq $true){
118+
$computers = Search-ADAccount -Server $Domain.PDCEmulator -AuthType $AuthType -AccountDisabled -ComputersOnly `
119+
-SearchBase $OUPath -SearchScope $SearchScope | Select-Object DistinguishedName, SAMAccountName | Sort-Object -Property SAMAccountName
120+
if($computers){
121+
foreach($itm in $computers){
122+
$resultMessage = $resultMessage + ("Disabled: " + $itm.DistinguishedName + ';' +$itm.SamAccountName)
123+
}
124+
$resultMessage = $resultMessage + ''
125+
}
126+
}
127+
if($InActive -eq $true){
128+
$computers = Search-ADAccount -Server $Domain.PDCEmulator -AuthType $AuthType -AccountInactive -ComputersOnly `
129+
-SearchBase $OUPath -SearchScope $SearchScope | Select-Object DistinguishedName, SAMAccountName | Sort-Object -Property SAMAccountName
130+
if($computers){
131+
foreach($itm in $computers){
132+
$resultMessage = $resultMessage + ("Inactive: " + $itm.DistinguishedName + ';' +$itm.SamAccountName)
133+
}
134+
}
135+
}
136+
}
137+
if($SRXEnv) {
138+
$SRXEnv.ResultMessage = $resultMessage
139+
}
140+
else{
141+
Write-Output $resultMessage
142+
}
143+
}
144+
catch{
145+
throw
146+
}
147+
finally{
148+
}

0 commit comments

Comments
 (0)