Skip to content

Commit b6ac570

Browse files
committed
Here is the initial import of these scripts into Git
Some of these are useful, some are not. Some I haven't used in a very long time. Some are not included (yet?). Signed-off-by: Elliot Voris <[email protected]>
1 parent 831e3fb commit b6ac570

20 files changed

+762
-0
lines changed

Bash/send-report.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
# Grab some stats from my script and send an email to myself
4+
5+
SUBJECT="Larryboy Status Report"
6+
7+
8+
MESSAGE="`echo $HOME`/tmp/report-message.txt"
9+
10+
# Record a title, and the date/time
11+
echo -e "Larryboy Status Report\n`date`" >> $MESSAGE
12+
13+
# Get the pertinent information from 'top'
14+
echo -e "\nCurrent Server Load\n" >> $MESSAGE
15+
top -n 1 -b | head -n 5 >> $MESSAGE
16+
17+
# Get the pertinent information from 'df'
18+
echo -e "\nFree Disk Space\n" >> $MESSAGE
19+
df -h >> $MESSAGE
20+
21+
# Send off the report
22+
mail -s "$SUBJECT" -r $FROM $TO <<EOF
23+
`cat $MESSAGE`
24+
EOF
25+
26+
# Get rid of the message so that we're ready for the next run
27+
rm $MESSAGE

Batch/ping_google.bat

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@echo off
2+
echo Local date is %date% %time%
3+
4+
ping www.google.com
5+
PAUSE

Powershell/CreateADfromCSV.ps1

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Take my file as a parameter
2+
Param(
3+
[string]$Userfile
4+
)
5+
6+
# Adds cmdlet to Powershell
7+
Import-Module ActiveDirectory
8+
9+
# Import the CSV information provided into an array
10+
$List = Import-Csv $Userfile
11+
12+
#Start Logging
13+
$dt = Get-Date -format "yyyyMMdd"
14+
$log = "ADlogfile_$dt.log"
15+
$file = "logs\" + $log
16+
Start-Transcript $file
17+
18+
# Go through EACH item in the list (Header row is treated as variable names by default)
19+
Foreach ($User in $List) {
20+
21+
$Firstname = $User.First
22+
$Lastname = $User.Last
23+
$Username = $User.Username
24+
$Email = $User.Email
25+
$Password = ConvertTo-SecureString -AsPlainText $User.Password -Force
26+
27+
$domain='@example.com'
28+
$DomainStudents = 'Domain Students'
29+
$StudentOU = 'OU=Students,DC=example,DC=com'
30+
31+
$Alias = "$Firstname $Lastname"
32+
$UPN = $Username+$domain
33+
$DisplayName = $Firstname+" "+$Lastname
34+
35+
# SAM userid cannot be greater than 20 characters - Legacy
36+
$Sam = $Username
37+
$Sam = (($Sam + ' ').Substring(0,20)).Trimend()
38+
39+
#Display Student Name for log file
40+
Write-Host "`r`n$DisplayName`r`n"
41+
42+
# Create actual user account
43+
New-ADUser -Name $Displayname -SamAccountName $Sam -GivenName $Firstname -Surname $Lastname -DisplayName $Displayname -Path $StudentOU -UserPrincipalName $UPN -AccountPassword $Password -ChangePasswordAtLogon $false -Enabled $true
44+
45+
# Add the newly create user to the 'Domain Students' group
46+
Add-ADGroupMember -Identity $DomainStudents -Members "CN=$DisplayName,$StudentOU"
47+
}
48+
49+
#Stop logging and disconnect from DC
50+
Stop-Transcript

Powershell/EmployeeNumber.ps1

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Set the AD "EmployeeNumber" attribute to the student's id card barcode
2+
3+
Param(
4+
[string]$userfile
5+
)
6+
7+
Import-Module ActiveDirectory
8+
$data = import-csv $userfile
9+
foreach($row in $data) {
10+
$username = $row.usrname
11+
$barcode = $row.barcode
12+
if (dsquery user -samid $username) {
13+
Set-ADUser -Identity $username -EmployeeNumber $barcode
14+
} else {
15+
echo "User Not Found $username"
16+
}
17+
}

Powershell/changeWLID.ps1

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Param(
2+
[string]$Userfile
3+
)
4+
5+
$data = Import-CSV $Userfile
6+
7+
ForEach($row in $data) {
8+
Set-Mailbox -Identity $row.Name -WindowsLiveID $row.WindowsLiveID
9+
}

Powershell/common_admin.ps1

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Script to accomplish some of the common PowerShell tasks to administer Live@edu domains
2+
3+
########## FUNCTION DEFINITIONS ##########
4+
##########################################
5+
# Give the user a list of tasks he/she may wish to accomplish
6+
function ListActions
7+
{
8+
Write-Host "What would you like to do?"
9+
Write-Host "1. Change a user's password"
10+
Write-Host "2. Change a WindowsLiveID"
11+
Write-Host "3. Change a Primary Email Address"
12+
Write-Host "4. Create a new User Account"
13+
Write-Host "5. Quit"
14+
}
15+
16+
function ChangePassword
17+
{
18+
# Script to change a user's password
19+
$PasswordUser = Read-Host -prompt "Enter the user's WindowsLiveID: "
20+
$NewPassword = Read-Host -prompt "Enter the usere's new password: " -AsSecureString
21+
Set-Mailbox $PasswordUser -Password $NewPassword
22+
}
23+
24+
function ChangeWLID
25+
{
26+
# Script to change a WindowsLiveID
27+
$WLIDUser = Read-Host -prompt "Enter the user's current WindowsLiveID: "
28+
$NewWLID = Read-Host -prompt "Enter the user's new WindowsLiveID: "
29+
Set-Mailbox $WLIDUser -WindowsLiveID $NewWLID
30+
}
31+
32+
function ChangeEmail
33+
{
34+
# Script to change a primary email address
35+
$WLIDUser = Read-Host -prompt "Enter the user's WindowsLiveID: "
36+
$NewEmail = Read-Host -prompt "Enter the user's new Primary Email Address: "
37+
Set-Mailbox $WLIDUser -EmailAddresses SMTP:$NewEmail,$WLIDUser
38+
}
39+
40+
function CreateNew
41+
{
42+
# Script to create a new user account
43+
$FullName = Read-Host -prompt "Enter the full name: "
44+
$NewPassword = Read-Host -prompt "Enter the new Password: " -AsSecureString
45+
$NewWLID = Read-Host -prompt "Enter the new WindowsLiveID: "
46+
$FirstName = Read-Host -prompt "Enter the first name: "
47+
$LastName = Read-Host -prompt "Enter the last name: "
48+
New-Mailbox -Name "$FullName" -Password $NewPassword -WindowsLiveID $NewWLID -ResetPasswordOnNextLogon $false -FirstName $FirstName -LastName $LastName -DisplayName "$FullName"
49+
}
50+
51+
function Quit
52+
{
53+
# Remove the cloud-based session from the client-side session
54+
Remove-PSSession $session
55+
}
56+
57+
########## INTERACTIVE PORTION ##########
58+
# Prompt the user for their Live@edu administrative WindowsLiveID & Password
59+
$LiveCredential = Get-Credential
60+
61+
# Create a new cloud-based session using the credentials the user just provided
62+
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCredential -Authentication Basic -AllowRedirection
63+
64+
# Import cloud-based $session into the client-side session
65+
Import-PSSession $Session
66+
67+
# List all the available script actions, and get the user's choice
68+
while ( $UserTask -ne 5 )
69+
{
70+
ListActions
71+
$UserTask = Read-Host
72+
if ( $UserTask -eq 1 ){ ChangePassword }
73+
if ( $UserTask -eq 2 ){ ChangeWLID }
74+
if ( $UserTask -eq 3 ){ ChangeEmail }
75+
if ( $UserTask -eq 4 ){ CreateNew }
76+
else { Write-Host "Please enter a number, 1-5" }
77+
}
78+
if ( $UserTask = 5 ){ Quit }
+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Create Office 365 accounts from our local active directory domain
2+
Param(
3+
[string]$Userfile
4+
)
5+
6+
$LocalDomain = "@example.local"
7+
$EmailDomain = "@example.com"
8+
# Import-Module ActiveDirectory
9+
10+
# Prompt for Admin email/password
11+
$LiveCredential = Get-Credential
12+
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCredential -Authentication Basic -AllowRedirection
13+
Import-PSSession $Session
14+
15+
$ADUsers = Get-ADUser -Filter * -SearchBase "OU=Students,DC=example,DC=local"
16+
$CSVUsers = Import-CSV $Userfile
17+
18+
# Foreach ($User in $CSVUsers) {
19+
# if (Get-ADUser -Identity $User.username) {
20+
# echo "Account Found, changing password`r`n"
21+
# $pass = ConvertTo-SecureString -AsPlainText $User.password -Force
22+
# Set-ADAccountPassword -Identity $User.username -NewPassword $pass
23+
# }
24+
# else {
25+
# echo "Account NOT Found`r`n"
26+
# }
27+
# }
28+
29+
# Foreach($User in $ADUsers) {
30+
# if ($Mailbox = Get-Mailbox -Identity $User.name) {
31+
# $good_email = $User.SamAccountName + $EmailDomain
32+
# if ($Mailbox.WindowsLiveID -eq $good_email ) {
33+
# Write-Host $User.SamAccountName "MSOLID OK"
34+
# if ($Mailbox.PrimarySmtpAddress -eq $good_email) {
35+
# Write-Host $User.SamAccountName "SMTP Address OK"
36+
# Write-Host "CHANGING Password"
37+
# }
38+
# else {
39+
# Write-Host "CHANGING SMTP Address"
40+
# Set-Mailbox $User.name -PrimarySmtpAddress $good_email
41+
# }
42+
# }
43+
# else {
44+
# Write-Host $User.SamAccountName "CHANGING MSOLID"
45+
# Set-Mailbox $User.name -MicrosoftOnlineServicesID $good_email
46+
# Set-Mailbox $User.name -PrimarySmtpAddress $good_email
47+
# }
48+
# }
49+
# else {
50+
# Write-Host $User.name ":: NOT FOUND"
51+
# }
52+
# }
53+
54+
Foreach ($User in $CSVUsers) {
55+
if ($Mailbox = Get-Mailbox -Identity $User.full) {
56+
echo "Found Mailbox" $Mailbox.MicrosoftOnlineServicesID
57+
Set-Mailbox $User.full -CustomAttribute1 "AIM"
58+
if ($Mailbox.MicrosoftOnlineServicesID = $User.email) {
59+
echo "Mailboxes Match, Changing Password"
60+
Set-MsolUserPassword -UserPrincipalName $User.email -NewPassword $User.password -ForceChangePassword $false
61+
echo `r`n
62+
}
63+
else {
64+
echo "Mailboxes Don't Match - FIX IT`r`n"
65+
}
66+
}
67+
else {
68+
echo "NOT FOUND"
69+
}
70+
}
71+
#Set-MsolUserPassword -UserPrincipalName [email protected] -NewPassword "fancynewpassword"

Powershell/outlook_login.ps1

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
$livecred = Get-Credential
2+
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $livecred -Authentication Basic -AllowRedirection
3+
Import-PSSession $Session

Powershell/test_credentials.ps1

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
##########
2+
#
3+
# Bulk AD Credential Testing Script
4+
# Elliot Voris | http://elliot.voris.me
5+
# Function by CosmosKey, via StackOverflow (http://go.voris.me/ij0cm)
6+
#
7+
# Used to parse a CSV of username/password combinations
8+
# and check those for validity against Active Directory
9+
#
10+
##########
11+
12+
#param($user_file)
13+
14+
Function Test-ADAuthentication {
15+
param($username,$password)
16+
(new-object directoryservices.directoryentry "",$username,$password).psbase.name -ne $null
17+
}
18+
19+
$domain = "example.com"
20+
$data = import-csv $user_file
21+
22+
foreach($row in $data) {
23+
if (Test-ADAuthentication "$domain\$username" "$password") {
24+
write-host "$username :: credentials valid"
25+
} else {
26+
write-host "$username :: credentials invalid" -foregroundcolor "red"
27+
}
28+
}

SQL/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Online Application #
2+
3+
A long while ago, I was going to re-write our online application for the college website - [the old
4+
website, that is](http://legacy.stlchristian.edu).
5+
6+
This was my start at setting up the database. The structure is all here, if I remember correctly.
7+
8+
This particular application was doomed to fizzle in the light of other pressing matters. We ended up
9+
redesigning our website along the way, and someday (pie in the sky) we'll have this running through
10+
our SIS anyway.
11+
12+
So, this particular custom application went the way of the dinosaur, but maybe it will help you one
13+
day.

SQL/athletics.sql

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Create a table for athletics, extra insert to populate it
2+
# elliot.voris.me
3+
4+
create table tbl_athletic
5+
(
6+
athletic_id smallint unsigned not null auto_increment comment 'PK: Unique Athletic ID',
7+
athletic_name varchar(15) not null comment 'Sport name with first letter capital',
8+
9+
primary key (athletic_id)
10+
)
11+
;
12+
13+
insert into tbl_athletic
14+
values
15+
(NULL, 'Basketball'),
16+
(NULL, 'Baseball'),
17+
(NULL, 'Volleyball'),
18+
(NULL, 'Soccer'),
19+
(NULL, 'Cross Country')
20+
;

SQL/degrees.sql

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Create a table for degrees, extra insert to populate it
2+
# elliot.voris.me
3+
4+
create table tbl_degree
5+
(
6+
degree_id smallint unsigned not null auto_increment comment 'PK: Unique Degree ID',
7+
degree_name varchar(56) not null comment 'Degree name with first letter capital',
8+
degree_abbr varchar(11) comment 'Optional degree abbreviation',
9+
10+
primary key (degree_id)
11+
)
12+
;
13+
14+
insert into tbl_degree
15+
values
16+
(NULL, 'Associate of Arts or Associate of Applied Science Degree', 'associate'),
17+
(NULL, 'Bachelor of Arts or Bachelor of Science Degree', 'bachelor'),
18+
(NULL, 'Certificate', 'certificate')
19+
;

SQL/enrollment.sql

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Create a table for enrollment status, extra insert to populate it
2+
# elliot.voris.me
3+
4+
create table tbl_enrollment
5+
(
6+
enrollment_id smallint unsigned not null auto_increment comment 'PK: Unique enrollment ID',
7+
enrollment_name varchar(18) not null comment 'Enrollment name with first letters capital',
8+
9+
primary key (enrollment_id)
10+
)
11+
;
12+
13+
insert into tbl_enrollment
14+
values
15+
(NULL, 'Non-Degree Seeking'),
16+
(NULL, '2 + 2 Program'),
17+
(NULL, 'Associate Degree'),
18+
(NULL, 'Bachelor Degree'),
19+
(NULL, 'Audit')
20+
;

0 commit comments

Comments
 (0)