-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jesse Russell
committed
Dec 31, 2017
0 parents
commit 26b0eec
Showing
33 changed files
with
2,572 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
file-watcher.ps1 | ||
clone-copy.ps1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
$reportPath = $PSScriptRoot + "\ActiveDirectoryComputers.html" | ||
|
||
$servers = Get-ADComputer -Filter * | ||
|
||
$serversHtml = $servers | Select-Object DNSHostName,Enabled,Name,ObjectClass,ObjectGUID,SamAccountName | ConvertTo-Html -Fragment -PreContent "<h2>Active Directory Computers</h2>" | ||
|
||
# Create HTML file | ||
$head = @" | ||
<title>AD Computer List</title> | ||
<style> | ||
body { | ||
background-color: #FFFFFF; | ||
font-family: sans-serif; | ||
} | ||
h1 { | ||
color: #1E87F0; | ||
} | ||
h2 { | ||
color: #1E87F0; | ||
} | ||
table { | ||
background-color: #1E87F0; | ||
} | ||
td { | ||
background-color: #FFFFFF; | ||
color: #666666; | ||
padding: 3px; | ||
} | ||
th { | ||
background-color: #1E87F0; | ||
color: #FFFFFF; | ||
text-align: left; | ||
padding: 3px; | ||
} | ||
</style> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | ||
<script> | ||
function filter(element) { | ||
var value = `$(element).val().toLowerCase(); | ||
`$("table > tr").hide().filter(function() { | ||
return `$(this).children('td:first-child').text().toLowerCase().indexOf(value) > -1; | ||
}).show(); | ||
} | ||
`$('#search').keyup(function() { | ||
filter(this); | ||
}); | ||
</script> | ||
"@ | ||
|
||
$searchbar = @" | ||
<input type='text' placeholder='Search by DNS Host Name...' id='search' /> | ||
"@ | ||
|
||
# Convert everything to HTML and output to file | ||
ConvertTo-Html -Head $head -Body "$searchbar$serversHtml" | Out-File $reportPath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# This script exports a csv with passwords expiring that week | ||
# Declare expiring soon group variable | ||
$expiring = @() | ||
# Grab AD Users that are enabled, and select the properties we need | ||
$users = Get-ADUser -Filter {Enabled -eq $true -and PasswordNeverExpires -eq $false} -Properties "DisplayName", "mail", "PasswordLastSet" | ||
# Get max password age | ||
$max = (Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge.Days | ||
# Loop through every user | ||
foreach ($user in $users) { | ||
# Get the current date | ||
$now = Get-Date | ||
# Create normal date out of msDS-UserPwasswordExpiryTimeComputed property | ||
$expiredate = $user.PasswordLastSet.AddDays($max) | ||
# Create a timespan from the expire date and today's date | ||
$diff = New-TimeSpan $now $expiredate | ||
# If the timespan is less than seven and greater than zero, add the user to the expiring list. | ||
if ($diff.Days -le 7 -and $diff.Days -ge 0) { | ||
$entry = [PSCustomObject]@{ | ||
Name = $user.DisplayName | ||
Email = $user.mail | ||
ExpireDate = $expiredate | ||
} | ||
$expiring += $entry | ||
} | ||
} | ||
# Export the list of expiring passwords to a csv | ||
$expiring | Export-Csv -Path "$PSScriptRoot\expiring_soon.csv" -NoTypeInformation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This script exports a csv with passwords expiring that week | ||
# Declare expiring soon group variable | ||
$expiring = @() | ||
# Grab AD Users that are enabled, and select the properties we need | ||
$users = Get-ADUser -Filter {Enabled -eq $true -and PasswordNeverExpires -eq $false} -Properties "DisplayName", "mail", "PasswordLastSet" | ||
# Get max password age | ||
$max = (Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge.Days | ||
# Loop through every user | ||
foreach ($user in $users) { | ||
# Get the current date | ||
$now = Get-Date | ||
# Create normal date out of msDS-UserPwasswordExpiryTimeComputed property | ||
$expiredate = $user.PasswordLastSet.AddDays($max) | ||
# Create a timespan from the expire date and today's date | ||
$diff = New-TimeSpan $now $expiredate | ||
# If the timespan is less than seven and greater than zero, add the user to the expiring list. | ||
if ($diff.Days -le 7 -and $diff.Days -ge 0) { | ||
$subject = "Your Password Is Expiring This Week" | ||
$from = "[email protected]" # Replace this with the desired from address | ||
$to = @($user.email) | ||
$cc = @() | ||
$bcc = @() | ||
$body = "<h3>Your password is expiring in $diff day(s). Please change it soon.</h3>" | ||
$priority = "Normal" | ||
$attachments = @() | ||
Send-Email($subject, $body, $from, $to, $cc, $bcc, $priority, $attachments) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
[void][System.Reflection.Assembly]::Load('System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') | ||
[void][System.Reflection.Assembly]::Load('System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') | ||
$MainForm = New-Object -TypeName System.Windows.Forms.Form | ||
[System.Windows.Forms.ListBox]$commandsList = $null | ||
[System.Windows.Forms.TextBox]$helpBox = $null | ||
[System.Windows.Forms.TabControl]$tabControl1 = $null | ||
[System.Windows.Forms.TabPage]$tabPage1 = $null | ||
[System.Windows.Forms.TabPage]$tabPage2 = $null | ||
[System.Windows.Forms.TextBox]$detailedHelp = $null | ||
[System.Windows.Forms.TabPage]$tabPage3 = $null | ||
[System.Windows.Forms.TextBox]$examplesBox = $null | ||
[System.Windows.Forms.Button]$button1 = $null | ||
function InitializeComponent | ||
{ | ||
$commandsList = (New-Object -TypeName System.Windows.Forms.ListBox) | ||
$helpBox = (New-Object -TypeName System.Windows.Forms.TextBox) | ||
$tabControl1 = (New-Object -TypeName System.Windows.Forms.TabControl) | ||
$tabPage1 = (New-Object -TypeName System.Windows.Forms.TabPage) | ||
$tabPage2 = (New-Object -TypeName System.Windows.Forms.TabPage) | ||
$detailedHelp = (New-Object -TypeName System.Windows.Forms.TextBox) | ||
$tabPage3 = (New-Object -TypeName System.Windows.Forms.TabPage) | ||
$examplesBox = (New-Object -TypeName System.Windows.Forms.TextBox) | ||
$tabControl1.SuspendLayout() | ||
$tabPage1.SuspendLayout() | ||
$tabPage2.SuspendLayout() | ||
$tabPage3.SuspendLayout() | ||
$MainForm.SuspendLayout() | ||
# | ||
#commandsList | ||
# | ||
$commandsList.FormattingEnabled = $true | ||
$commandsList.HorizontalScrollbar = $true | ||
$commandsList.Location = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]13,[System.Int32]13)) | ||
$commandsList.Name = 'commandsList' | ||
$commandsList.Size = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]201,[System.Int32]550)) | ||
$commandsList.TabIndex = [System.Int32]0 | ||
$commandsList.add_SelectedIndexChanged($commandsList_SelectedIndexChanged) | ||
# | ||
#helpBox | ||
# | ||
$helpBox.AcceptsReturn = $true | ||
$helpBox.AcceptsTab = $true | ||
$helpBox.BackColor = [System.Drawing.SystemColors]::Window | ||
$helpBox.Font = (New-Object -TypeName System.Drawing.Font -ArgumentList @('Lucida Console',[System.Single]8.25,[System.Drawing.FontStyle]::Regular,[System.Drawing.GraphicsUnit]::Point,([System.Byte][System.Byte]0))) | ||
$helpBox.Location = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]6,[System.Int32]6)) | ||
$helpBox.Multiline = $true | ||
$helpBox.Name = 'helpBox' | ||
$helpBox.ReadOnly = $true | ||
$helpBox.ScrollBars = [System.Windows.Forms.ScrollBars]::Both | ||
$helpBox.Size = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]876,[System.Int32]514)) | ||
$helpBox.TabIndex = [System.Int32]1 | ||
$helpBox.WordWrap = $false | ||
# | ||
#tabControl1 | ||
# | ||
$tabControl1.Controls.Add($tabPage1) | ||
$tabControl1.Controls.Add($tabPage2) | ||
$tabControl1.Controls.Add($tabPage3) | ||
$tabControl1.Location = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]221,[System.Int32]13)) | ||
$tabControl1.Name = 'tabControl1' | ||
$tabControl1.SelectedIndex = [System.Int32]0 | ||
$tabControl1.Size = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]893,[System.Int32]549)) | ||
$tabControl1.TabIndex = [System.Int32]2 | ||
# | ||
#tabPage1 | ||
# | ||
$tabPage1.Controls.Add($helpBox) | ||
$tabPage1.Location = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]4,[System.Int32]22)) | ||
$tabPage1.Name = 'tabPage1' | ||
$tabPage1.Size = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]885,[System.Int32]523)) | ||
$tabPage1.TabIndex = [System.Int32]0 | ||
$tabPage1.Text = 'Main' | ||
$tabPage1.UseVisualStyleBackColor = $true | ||
# | ||
#tabPage2 | ||
# | ||
$tabPage2.Controls.Add($detailedHelp) | ||
$tabPage2.Location = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]4,[System.Int32]22)) | ||
$tabPage2.Name = 'tabPage2' | ||
$tabPage2.Size = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]885,[System.Int32]523)) | ||
$tabPage2.TabIndex = [System.Int32]1 | ||
$tabPage2.Text = 'Detailed' | ||
$tabPage2.UseVisualStyleBackColor = $true | ||
# | ||
#detailedHelp | ||
# | ||
$detailedHelp.BackColor = [System.Drawing.SystemColors]::Window | ||
$detailedHelp.Font = (New-Object -TypeName System.Drawing.Font -ArgumentList @('Lucida Console',[System.Single]8.25,[System.Drawing.FontStyle]::Regular,[System.Drawing.GraphicsUnit]::Point,([System.Byte][System.Byte]0))) | ||
$detailedHelp.Location = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]7,[System.Int32]7)) | ||
$detailedHelp.Multiline = $true | ||
$detailedHelp.Name = 'detailedHelp' | ||
$detailedHelp.ReadOnly = $true | ||
$detailedHelp.ScrollBars = [System.Windows.Forms.ScrollBars]::Both | ||
$detailedHelp.Size = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]875,[System.Int32]513)) | ||
$detailedHelp.TabIndex = [System.Int32]0 | ||
$detailedHelp.WordWrap = $false | ||
# | ||
#tabPage3 | ||
# | ||
$tabPage3.Controls.Add($examplesBox) | ||
$tabPage3.Location = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]4,[System.Int32]22)) | ||
$tabPage3.Name = 'tabPage3' | ||
$tabPage3.Size = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]885,[System.Int32]523)) | ||
$tabPage3.TabIndex = [System.Int32]2 | ||
$tabPage3.Text = 'Examples' | ||
$tabPage3.UseVisualStyleBackColor = $true | ||
# | ||
#examplesBox | ||
# | ||
$examplesBox.BackColor = [System.Drawing.SystemColors]::Window | ||
$examplesBox.Font = (New-Object -TypeName System.Drawing.Font -ArgumentList @('Lucida Console',[System.Single]8.25,[System.Drawing.FontStyle]::Regular,[System.Drawing.GraphicsUnit]::Point,([System.Byte][System.Byte]0))) | ||
$examplesBox.Location = (New-Object -TypeName System.Drawing.Point -ArgumentList @([System.Int32]4,[System.Int32]4)) | ||
$examplesBox.Multiline = $true | ||
$examplesBox.Name = 'examplesBox' | ||
$examplesBox.ReadOnly = $true | ||
$examplesBox.ScrollBars = [System.Windows.Forms.ScrollBars]::Both | ||
$examplesBox.Size = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]878,[System.Int32]516)) | ||
$examplesBox.TabIndex = [System.Int32]0 | ||
$examplesBox.WordWrap = $false | ||
# | ||
#MainForm | ||
# | ||
$MainForm.ClientSize = (New-Object -TypeName System.Drawing.Size -ArgumentList @([System.Int32]1126,[System.Int32]574)) | ||
$MainForm.Controls.Add($tabControl1) | ||
$MainForm.Controls.Add($commandsList) | ||
$MainForm.Name = 'MainForm' | ||
$MainForm.Text = 'Powershell Help' | ||
$MainForm.add_Load($MainForm_Load) | ||
$tabControl1.ResumeLayout($false) | ||
$tabPage1.ResumeLayout($false) | ||
$tabPage1.PerformLayout() | ||
$tabPage2.ResumeLayout($false) | ||
$tabPage2.PerformLayout() | ||
$tabPage3.ResumeLayout($false) | ||
$tabPage3.PerformLayout() | ||
$MainForm.ResumeLayout($false) | ||
Add-Member -InputObject $MainForm -Name base -Value $base -MemberType NoteProperty | ||
Add-Member -InputObject $MainForm -Name commandsList -Value $commandsList -MemberType NoteProperty | ||
Add-Member -InputObject $MainForm -Name helpBox -Value $helpBox -MemberType NoteProperty | ||
Add-Member -InputObject $MainForm -Name tabControl1 -Value $tabControl1 -MemberType NoteProperty | ||
Add-Member -InputObject $MainForm -Name tabPage1 -Value $tabPage1 -MemberType NoteProperty | ||
Add-Member -InputObject $MainForm -Name tabPage2 -Value $tabPage2 -MemberType NoteProperty | ||
Add-Member -InputObject $MainForm -Name detailedHelp -Value $detailedHelp -MemberType NoteProperty | ||
Add-Member -InputObject $MainForm -Name tabPage3 -Value $tabPage3 -MemberType NoteProperty | ||
Add-Member -InputObject $MainForm -Name examplesBox -Value $examplesBox -MemberType NoteProperty | ||
Add-Member -InputObject $MainForm -Name button1 -Value $button1 -MemberType NoteProperty | ||
} | ||
. InitializeComponent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
$commandsList_SelectedIndexChanged = { | ||
[System.Windows.Forms.Cursor]::Current = [System.Windows.Forms.Cursors]::WaitCursor | ||
$selected = $commandsList.SelectedIndex | ||
$cmd = $commandsList.Items[$selected].ToString() | ||
$helpBox.Text = Get-Help $cmd | Out-String | ||
$detailedHelp.Text = Get-Help $cmd -Detailed | Out-String | ||
$examplesBox.Text = Get-Help $cmd -Examples | Out-String | ||
[System.Windows.Forms.Cursor]::Current = [System.Windows.Forms.Cursors]::Default | ||
} | ||
|
||
$MainForm_Load = { | ||
|
||
[System.Windows.Forms.Cursor]::Current = [System.Windows.Forms.Cursors]::WaitCursor | ||
$commands = Get-Command | Sort-Object Name | ||
foreach ($command in $commands) { | ||
$commandsList.Items.Add($command) | ||
} | ||
[System.Windows.Forms.Cursor]::Current = [System.Windows.Forms.Cursors]::Default | ||
$searchBox_TextChanged = { | ||
$commandsList.Items.Clear() | ||
foreach ($item in $commands) { | ||
if ($searchBox.Text -match $item) { | ||
$commandsList.Items.Add($item) | ||
} | ||
} | ||
} | ||
} | ||
|
||
. (Join-Path $PSScriptRoot 'PowershellHelp.designer.ps1') | ||
|
||
$MainForm.ShowDialog() |
Oops, something went wrong.