Skip to content

Commit 23e353d

Browse files
committed
Updated Links and Formatting
Updated links and adapted a new formatting style
1 parent 337ae69 commit 23e353d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1118
-1441
lines changed

Add-ADNewContact.ps1

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
11
<#
2-
.Synopsis
3-
Add-ADNewContact is a cmdlet that is used adding a new contact into Active Directory and adding them into a distribution group.
4-
In order for this to work you will need to add the Contact OU location in Active Directory. This can be found on the Domain Controllers ADSI Edit MMC.
5-
You will also need to define the location of the admin account you use to access Active Directory. This is done at line 77
2+
.SYNOPSIS
3+
Add-ADNewContact is a cmdlet that is used adding a new contact into Active Directory and adding them into a distribution group.
4+
In order for this to work you will need to add the Contact OU location in Active Directory. This can be found on the Domain Controllers ADSI Edit MMC.
5+
You will also need to define the location of the admin account you use to access Active Directory. This is done at line 77
66
77
.DESCRIPTION
8-
Create a new Active Directory Contact and adds them to a distribution group(s).
9-
In order for this to work you will need to add the Contact OU location in Active Directory. This can be found on the Domain Controllers ADSI Edit MMC.
10-
You will also need to define the location of the admin account you use to access Active Directory. This is done at line 77
8+
Create a new Active Directory Contact and adds them to a distribution group(s).
9+
In order for this to work you will need to add the Contact OU location in Active Directory. This can be found on the Domain Controllers ADSI Edit MMC.
10+
You will also need to define the location of the admin account you use to access Active Directory. This is done at line 77
11+
12+
CONFIGURE LINE 77 ManagementUserAccount Variable
1113
12-
CONFIGURE LINE 77 ManagementUserAccount Variable
1314
1415
.NOTES
15-
Author: Rob Osborne
16-
Alias: tobor
17-
18-
https://osbornepro.com
16+
Author: Robert H. Osborne
17+
Alias: tobor
18+
19+
20+
21+
.LINK
22+
https://osbornepro.com
23+
https://writeups.osbornepro.com
24+
https://btpssecpack.osbornepro.com
25+
https://github.com/tobor88
26+
https://gitlab.com/tobor88
27+
https://www.powershellgallery.com/profiles/tobor
28+
https://www.linkedin.com/in/roberthosborne/
29+
https://www.credly.com/users/roberthosborne/badges
30+
https://www.hackthebox.eu/profile/52286
31+
1932
2033
.EXAMPLE
21-
Add-ADNewContact -ContactName $ContactName -ContactEmail $ContactEmail -GroupName "Group1", "Group2"
34+
Add-ADNewContact -ContactName $ContactName -ContactEmail $ContactEmail -GroupName "Group1", "Group2"
2235
2336
.EXAMPLE
24-
Add-ADNewContact -ContactName $ContactName -ContactEmail $ContactEmail -GroupName $GroupName -Verbose
37+
Add-ADNewContact -ContactName $ContactName -ContactEmail $ContactEmail -GroupName $GroupName -Verbose
2538
#>
2639

2740
Function Add-ADNewContact {
@@ -33,7 +46,7 @@ Function Add-ADNewContact {
3346
ValueFromPipelineByPropertyName=$True,
3447
HelpMessage="New Contacts Name. `n Example: Dixie Normus `n`n If you see this message, you will need to enter the new contacts name.")] # End Parameter
3548
[ValidateNotNullorEmpty()]
36-
[string[]]$ContactName, #
49+
[string[]]$ContactName,
3750

3851
[Parameter(Mandatory=$True,
3952
Position=1,
@@ -60,14 +73,12 @@ Function Add-ADNewContact {
6073
PROCESS {
6174

6275
$Username = $env:USERNAME
63-
6476
$Path = "ou=CONTACTS,dc=OSBORNEPRO,dc=COM"
6577

6678
Write-Verbose "New contact will be added to the below OU`n$Path`n"
6779

6880
$NameCount = $ContactName.Split(' ').Count
69-
70-
if ($NameCount -eq 2) {
81+
If ($NameCount -eq 2) {
7182

7283
$FirstName,$LastName = $ContactName.Split(' ')
7384

@@ -76,38 +87,31 @@ Function Add-ADNewContact {
7687
ForEach ($GName in $GroupName) {
7788

7889
$ManagementUserAccount = [adsi] "LDAP://usav-dcp:389/cn=$Username,cn=Users,dc=OSBORNEPRO,dc=COM"
79-
8090
$NewContact = "LDAP://usav-dcp:389/cn=$Gname,$Path"
81-
8291
$ManagementUserAccount.Add($NewContact)
8392

8493
} # End ForEach
8594

8695
} # End If
8796

88-
elseif ($NameCount -eq 3) {
97+
ElseIf ($NameCount -eq 3) {
8998

9099
$FirstName,$MiddleName,$LastName = $ContactName.Split(' ')
91-
92100
New-ADObject -Type Contact -Name $ContactName -Path $Path -OtherAttributes @{'GivenName'="$FirstName";'SN'="$LastName";'Mail'=$ContactEmail;'ProxyAddresses'="SMTP:"+$ContactEmail;'targetAddress'="SMTP:"+$ContactEmail}
93101

94102
ForEach ($GName in $GroupName) {
95103

96104
$ManagementUserAccount = [adsi] "LDAP://usav-dcp:389/cn=$Username,cn=Users,dc=OSBORNEPRO,dc=COM"
97-
98105
$NewContact = "LDAP://usav-dcp:389/cn=$Gname,$Path"
99-
100106
$ManagementUserAccount.Add($NewContact)
101107

102108
} # End ForEach
103109

104110
} # End Elseif
105111

106-
elseif ($NameCount -ge 4 ) {
107-
108-
Write-Warning "Too many names for this cmdlet to handle."
112+
ElseIf ($NameCount -ge 4 ) {
109113

110-
break
114+
Throw "[x] Too many names for this cmdlet to handle."
111115

112116
} # End ElseIf
113117

Add-RdpPermission.ps1

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,36 @@
11
<#
2-
.Synopsis
3-
Add-RdpPermission is a cmdlet that is used for adding RDP permissions onto a remote computer for a Domain user.
2+
.SYNOPSIS
3+
Add-RdpPermission is a cmdlet that is used for adding RDP permissions onto a remote computer for a Domain user.
4+
45
56
.DESCRIPTION
6-
Adds RDP access on a computer for a defined Domain user.
7+
Adds RDP access on a computer for a defined Domain user.
8+
79
810
.NOTES
9-
Author: Rob Osborne
10-
Alias: tobor
11-
12-
https://osbornepro.com
11+
Author: Robert H. Osborne
12+
Alias: tobor
13+
14+
15+
16+
.LINK
17+
https://osbornepro.com
18+
https://writeups.osbornepro.com
19+
https://btpssecpack.osbornepro.com
20+
https://github.com/tobor88
21+
https://gitlab.com/tobor88
22+
https://www.powershellgallery.com/profiles/tobor
23+
https://www.linkedin.com/in/roberthosborne/
24+
https://www.credly.com/users/roberthosborne/badges
25+
https://www.hackthebox.eu/profile/52286
26+
1327
1428
.EXAMPLE
15-
Add-RdpPermission -ComputerName $ComputerName -AdUser $SamAccountUserName
29+
Add-RdpPermission -ComputerName $ComputerName -AdUser $SamAccountUserName
1630
1731
.EXAMPLE
18-
Add-RdpPermission -ComputerName $ComputerName -AdUser $SamAccountUserName -Verbose
32+
Add-RdpPermission -ComputerName $ComputerName -AdUser $SamAccountUserName -Verbose
1933
#>
20-
2134
Function Add-RdpPermission {
2235
[CmdletBinding()]
2336
param(
@@ -27,26 +40,24 @@ Function Add-RdpPermission {
2740
ValueFromPipelineByPropertyName=$True,
2841
HelpMessage="The Remote Computer's Hostname. `n Example: Desktop01 `n`n If you see this message, you will need to enter the remote computers name you want to add RDP permissions too.")] # End Parameter
2942
[ValidateNotNullorEmpty()]
30-
[string[]]$ComputerName, # End Paramater
43+
[String[]]$ComputerName, # End Paramater
3144

3245
[Parameter(Mandatory=$True,
3346
Position=1,
3447
ValueFromPipeline=$True,
3548
ValueFromPipelineByPropertyName=$True,
3649
HelpMessage="The Active Directory User's SamAccountName. `n Example: firstname.lastname `n`n If you see this message, you will need to enter the domain users SamAccountName you want to add RDP permissions too.")] # End Parameter
3750
[ValidateNotNullorEmpty()]
38-
[string[]]$AdUser # End Parameter
51+
[String[]]$AdUser # End Parameter
3952

4053
) # End param
4154

4255
Invoke-Command -ComputerName $ComputerName -ScriptBlock {
4356

4457
net LOCALGROUP "Remote Desktop Users" /ADD "$AdUser"
45-
4658
net LOCALGROUP "Remote Desktop Users"
4759

4860
Write-Host "If you have received an error message you either will need to run the command as an adminstrator or the user is already a member of allowed RDP users."
49-
5061
Read-Host "Press Enter to Exit"
5162

5263
} # End Invoke-Command

Add-SharedEmailPermission.psm1

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,45 @@
11
<#
22
.SYNOPSIS
3-
Add-SharedEmailPermission is a cmdlet created to add a user to a shared mailbox in Office365
3+
Add-SharedEmailPermission is a cmdlet created to add a user to a shared mailbox in Office365
44
55
.DESCRIPTION
6-
Add-SharedEmailPermission is a cmdlet used to add a user(s) to a shared email in Office365.
7-
This cmdlet will allow piping of a username but does not accept more than one username.
6+
Add-SharedEmailPermission is a cmdlet used to add a user(s) to a shared email in Office365.
7+
This cmdlet will allow piping of a username but does not accept more than one username.
88
99
.NOTES
10-
Author: Rob Osborne
11-
Alias: tobor
12-
13-
https://osbornepro.com
10+
Author: Robert H. Osborne
11+
Alias: tobor
12+
13+
14+
15+
.LINK
16+
https://osbornepro.com
17+
https://writeups.osbornepro.com
18+
https://btpssecpack.osbornepro.com
19+
https://github.com/tobor88
20+
https://gitlab.com/tobor88
21+
https://www.powershellgallery.com/profiles/tobor
22+
https://www.linkedin.com/in/roberthosborne/
23+
https://www.credly.com/users/roberthosborne/badges
24+
https://www.hackthebox.eu/profile/52286
25+
1426
1527
.EXAMPLE
16-
Add-SharedEmailPermission -Identity <string[] UserPrincipalName> -Mailbox <string[] Shared Email Address> [-SendAs] [-FullAccess] [-Verbose]
28+
Add-SharedEmailPermission -Identity <string[] UserPrincipalName> -Mailbox <string[] Shared Email Address> [-SendAs] [-FullAccess] [-Verbose]
1729
1830
.EXAMPLE
19-
Add-SharedEmailPermission -Identity '[email protected]' -Mailbox '[email protected]' -FullAccess -Verbose
20-
This example adds [email protected] to have full access rights on shared mailbox [email protected]
31+
Add-SharedEmailPermission -Identity '[email protected]' -Mailbox '[email protected]' -FullAccess -Verbose
32+
This example adds [email protected] to have full access rights on shared mailbox [email protected]
2133
2234
.EXAMPLE
23-
Add-SharedEmailPermission -Identity '[email protected]' -Mailbox '[email protected]' -SendAs -FullAccess -Verbose
24-
This example adds [email protected] to have full access and SendAs rights on shared mailbox [email protected]
35+
Add-SharedEmailPermission -Identity '[email protected]' -Mailbox '[email protected]' -SendAs -FullAccess -Verbose
36+
This example adds [email protected] to have full access and SendAs rights on shared mailbox [email protected]
2537
2638
.EXAMPLE
27-
Add-SharedEmailPermission -Identity '[email protected]' -Mailbox '[email protected]' -FullAccess
28-
This example adds [email protected] to have full access rights on shared mailbox [email protected]
39+
Add-SharedEmailPermission -Identity '[email protected]' -Mailbox '[email protected]' -FullAccess
40+
This example adds [email protected] to have full access rights on shared mailbox [email protected]
2941
#>
30-
31-
Function Add-SharedEmailPermission
32-
{
42+
Function Add-SharedEmailPermission {
3343
[CmdletBinding()]
3444
param(
3545
[Parameter(Mandatory=$True,
@@ -52,42 +62,34 @@ Function Add-SharedEmailPermission
5262
[Parameter(Mandatory=$False)]
5363
[switch][bool]$FullAccess) # End param
5464

55-
If (!($SendAs.IsPresent -or $FullAccess.IsPresent))
56-
{
65+
If (!($SendAs.IsPresent -or $FullAccess.IsPresent)) {
5766

58-
throw 'Missing Switch Permission'
67+
Throw 'Missing Switch Permission'
5968

6069
} # End If
6170

62-
If ((Get-PsSession).ConfigurationName -notlike 'Microsoft.Exchange')
63-
{
71+
If ((Get-PsSession).ConfigurationName -notlike 'Microsoft.Exchange') {
6472

6573
$Session = New-PSSession -ConfigurationName "Microsoft.Exchange" -ConnectionUri "https://ps.outlook.com/PowerShell-LiveID?PSVersion=5.1.14393.2608" -Credential (Get-Credential -Message "Enter your global admin credentials for Office365. Example: [email protected]") -Authentication "Basic" -AllowRedirection
66-
6774
Import-PSSession -Session $Session -ErrorAction "SilentlyContinue" | Out-Null
6875

6976
} # End If
7077

71-
If ($SendAs.IsPresent)
72-
{
78+
If ($SendAs.IsPresent) {
7379

7480
Write-Verbose "Adding SendAs Permission to user $Identity for shared mailbox $Mailbox"
75-
7681
Add-RecipientPermission -Identity $Identity -Trustee $Mailbox -AccessRights 'SendAs'
7782

7883
} #End If
7984

80-
If ($FullAccess.IsPresent)
81-
{
85+
If ($FullAccess.IsPresent) {
8286

8387
Write-Verbose "Adding full permissions for $Identity to shared mailbox $Mailbox"
84-
8588
Add-MailboxPermission -Identity $Identity -User $Mailbox -AccessRights 'FullAccess' -InheritanceType 'All'
8689

8790
} # End If
8891

89-
If ((Get-PsSession).ConfigurationName -like 'Microsoft.Exchange')
90-
{
92+
If ((Get-PsSession).ConfigurationName -like 'Microsoft.Exchange') {
9193

9294
Get-PsSession | Where-Object -Property 'ConfigurationName' -like 'Microsoft.Exchange' | Remove-PsSession
9395

Clear-AllPsHistory.psm1

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,51 @@
22
.SYNOPSIS
33
Clear-AllPsHistory is used to clear the contents of a computers PowerShell command history file and the shell's current command history.DESCRIPTION
44
5-
.SNYTAX
6-
Clear-AllPsHistory [-Verbose]
75
86
.DESCRIPTION
9-
Clears the contents of PowerShell's history file and the shell history.
7+
Clears the contents of PowerShell's history file and the shell history.
8+
109
1110
.INPUTS
12-
Does not accept any pipeline input.
11+
Does not accept any pipeline input.
12+
1313
1414
.OUTPUTS
15-
No Output. This clears PowerShell command history.
15+
No Output. This clears PowerShell command history.
16+
17+
.NOTES
18+
Author: Robert H. Osborne
19+
Alias: tobor
20+
21+
22+
23+
.LINK
24+
https://osbornepro.com
25+
https://writeups.osbornepro.com
26+
https://btpssecpack.osbornepro.com
27+
https://github.com/tobor88
28+
https://gitlab.com/tobor88
29+
https://www.powershellgallery.com/profiles/tobor
30+
https://www.linkedin.com/in/roberthosborne/
31+
https://www.credly.com/users/roberthosborne/badges
32+
https://www.hackthebox.eu/profile/52286
33+
1634
1735
.EXAMPLE
18-
-------------------------- EXAMPLE 1 --------------------------
19-
C:\PS> Clear-AllPsHistory -Verbose
20-
This command clears all PowerShell command history and shows the steps verbosely.
36+
-------------------------- EXAMPLE 1 --------------------------
37+
C:\PS> Clear-AllPsHistory -Verbose
38+
This command clears all PowerShell command history and shows the steps verbosely.
2139
2240
#>
23-
Function Clear-AllPsHistory
24-
{
41+
Function Clear-AllPsHistory {
2542

2643
$History = Get-PSReadlineOption
27-
2844
$HistoryFile = $History.HistorySavePath
2945

3046
Write-Verbose 'Clearing Console history...'
31-
3247
Clear-History
3348

3449
Write-Verbose "Emptying contents of $HistoryFile"
35-
3650
Clear-Content -Path $HistoryFile -Force
3751

3852
} # End Function

0 commit comments

Comments
 (0)