Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions FileAudit/AuditFileSystem.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
#import stuff :P
import csv, sys, argparse, os, textwrap, subprocess
from prettytable import PrettyTable
import logging

#Default variable starts for later
scan_things = False
output_csv = False
output_html = False
output_cli = False

#Make logger and do stuff
logger=logging.getLogger(__name__)
logger.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler = logging.StreamHandler(sys.stderr)
handler.setFormatter(formatter)
logger.addHandler(handler)
handler = logging.StreamHandler(sys.stderr)
handler.setFormatter(formatter)
logger.addHandler(handler)
del handler

#Setup argparse stuff
parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -46,7 +58,7 @@ def scan_path_ps1():
subprocess.call('powershell.exe -command Set-ExecutionPolicy RemoteSigned', shell=True)
subprocess.call('powershell.exe .\GenerateFileAudit.ps1', shell=True)
os.remove(".\GenerateFileAudit.ps1")
print(f"Scan is now finished and raw csv outputted to {args.csvoutput}")
logger.info(f"Scan is now finished and raw csv outputted to {args.csvoutput}")

def write_ps1_file():
f = open("GenerateFileAudit.ps1", "a")
Expand Down Expand Up @@ -197,7 +209,7 @@ def html_formatter():
f1.close()
f2.close()

print(f"HTML Output has been sent to: {args.outfile}")
logger.info(f"HTML Output has been sent to: {args.outfile}")

def cli_table_display():
table = PrettyTable()
Expand All @@ -212,19 +224,20 @@ def cli_table_display():
display_count += 1
line_count += 1
table.sortby = "User Group"
# Not switching to logger.info because this seems that it's meant to prettyprint, not log anything
print(table)
print()
print(f'Inheritance Flag filter is active by default. Displaying {display_count} out of {line_count} entries.')

##############################
#Check for args and set bools#
if args.infile is None and args.scanpath is None:
print("Please enter an infile or a scanpath argument.")
sys.exit()
logger.error("Please enter an infile or a scanpath argument.")
sys.exit(1)

if args.infile is not None and args.scanpath is not None:
print("Choose infile or scanpath. Not both.")
sys.exit()
logger.error("Choose infile or scanpath, not both")
sys.exit(1)

if args.scanpath is not None:
scan_things = True
Expand All @@ -235,7 +248,7 @@ def cli_table_display():
elif ".html" in args.outfile:
output_html = True
else:
Print("Outfile is not specified or not .csv/.html. Outputting to CLI.")
logger.warn("Outfile is not specified or not .csv/.html. Outputting to CLI.")
output_cli = True

##############################
Expand All @@ -244,7 +257,7 @@ def cli_table_display():
scan_path_ps1()

if output_csv == True:
Print("CSV Output not set up!! Displaying CLI Output.")
logger.warn("CSV Output not set up!! Displaying CLI Output.")
cli_table_display()
elif output_html == True:
html_formatter()
Expand All @@ -253,4 +266,4 @@ def cli_table_display():

if args.generate is True:
write_ps1_file()
print("GenerateFileAudit.ps1 has been created.")
logger.info("GenerateFileAudit.ps1 has been created.")
36 changes: 24 additions & 12 deletions MassCommand/MassCommand.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
import sys, argparse, os, textwrap, subprocess, shutil, glob
import sys, argparse, os, textwrap, subprocess, shutil, glob, logger

#Make logger and do stuff
logger=logging.getLogger(__name__)
logger.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler = logging.StreamHandler(sys.stderr)
handler.setFormatter(formatter)
logger.addHandler(handler)
handler = logging.StreamHandler(sys.stderr)
handler.setFormatter(formatter)
logger.addHandler(handler)
del handler

#Setup argparse stuff
parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -40,7 +52,7 @@ def log_cleaning():
try:
os.remove(filePath)
except:
print("Error while deleting file : ", filePath)
logger.error("Error while deleting file : ", filePath)

def log_control():
outfilename = ".\\output.log"
Expand Down Expand Up @@ -68,7 +80,7 @@ def run_command():
f.write("\n")

#Put stuff in the interpreter
print(f"Running {args.run} on {line}")
logger.info(f"Running {args.run} on {line}")
f.write(f"Running psexec \\\\{line} {args.run}")
f.write("\n")
f.close()
Expand Down Expand Up @@ -98,11 +110,11 @@ def push_copies():
f.write("\n")
f.close()
#Put stuff in the interpreter
print(f"Sending {args.copy} to {final_destination}")
logger.info(f"Sending {args.copy} to {final_destination}")

#Setup, then run the commands, dumping contents to its own logfile
final_command = f'xcopy "{args.copy}" "{final_destination}" /Y /E /H /C /I ^>^> .\\logs\\{line}.log'
print(final_command)
logger.info(final_command)
subprocess.Popen(f"start cmd.exe /k {final_command}", shell=True)
print("--------------------------------------------")
line = fp.readline()
Expand All @@ -114,13 +126,13 @@ def push_copies():

if os.path.isfile(args.targets) == False:
print()
print("File does not exist: " + args.targets)
sys.exit()
logger.error("File does not exist: " + args.targets)
sys.exit(1)

if args.copy is None and args.run is None:
print()
print("Please specify copy, run, or both.")
sys.exit()
logger.error("Please specify copy, run, or both.")
sys.exit(1)

#Zhu-Li, do the thing.
if args.copy is not None and args.run is not None:
Expand All @@ -130,18 +142,18 @@ def push_copies():
run_command()
input("Once all commands have ran, press Enter to compile logs and close...")
log_control()
sys.exit()
sys.exit(0)

if args.copy is not None:
log_cleaning()
push_copies()
input("Once all copies have been pushed (All windows closed), press Enter to compile logs and close...")
log_control()
sys.exit()
sys.exit(0)

if args.run is not None:
log_cleaning()
run_command()
input("Once all commands have ran (All windows closed), press Enter to compile logs and close...")
log_control()
sys.exit()
sys.exit(0)
17 changes: 17 additions & 0 deletions PowerApps/Notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Dynamic Widths
Full
If(App.Width > 640, Parent.Width / 2, Parent.Width)
Half
If(App.Width > 640, Parent.Width / 4, Parent.Width /2)
Var based
OnStart
Set(FullWidthDivisor, 2);
Set(HalfWidthDivisor, 4);
Set(ScreenSplitWidth, 640);
Full w var
If(App.Width > ScreenSplitWidth, Parent.Width / FullWidthDivisor, Parent.Width)
Half w var
If(App.Width > ScreenSplitWidth, Parent.Width / HalfWidthDivisor, Parent.Width / 2)

New Submission - Hide unless option is chose
DataCardValue8.Selected.Value="Yes"
1 change: 1 addition & 0 deletions Queries/AD/ComputerQuery.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<QUERY><NAME>All Computers</NAME><DESCRIPTION></DESCRIPTION><DN></DN><FILTERLASTLOGON>-1</FILTERLASTLOGON><LDAPQUERY>(&amp;(objectCategory=computer)(name=*))</LDAPQUERY><ONELEVEL>FALSE</ONELEVEL><COLUMNID>{44170AFE-E5E7-4842-8FC4-69E3C5935D33}</COLUMNID><DSQUERYUIDATA>050000000c00000043006f006d006d006f006e00510075006500720079000000020000000308000000480061006e0064006c00650072000000100000005ee6238ac231d011891c00a024ab2dbb030500000046006f0072006d00000010000000cbe7168cc2172947a6698474d6712b81080000004400730051007500650072007900000002000000010900000056006900650077004d006f0064006500000004130000010d00000045006e00610062006c006500460069006c007400650072000000000000002a00000028006f0062006a00650063007400430061007400650067006f00720079003d0070006500720073006f006e00290028006f0062006a0065006300740043006c006100730073003d0075007300650072002900000005000000010a0000004e0061006d00650043006f006d0062006f00000000000000010a000000440065007300630043006f006d0062006f00000000000000010d000000440069007300610062006c00650043006800650063006b00000000000000010f0000004e006f006e0045007800700050007700640043006800650063006b00000000000000010f0000004c006100730074004c006f0067006f006e0043006f006d0062006f000000000000001a00000028006f0062006a00650063007400430061007400650067006f00720079003d0063006f006d00700075007400650072002900000003000000010a0000004e0061006d00650043006f006d0062006f0000000c200000010a000000440065007300630043006f006d0062006f00000000000000010d000000440069007300610062006c00650043006800650063006b000000000000001700000028006f0062006a00650063007400430061007400650067006f00720079003d00670072006f00750070002900000002000000010a0000004e0061006d00650043006f006d0062006f00000000000000010a000000440065007300630043006f006d0062006f00000000000000</DSQUERYUIDATA></QUERY>
1 change: 1 addition & 0 deletions Queries/AD/GroupQuery.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<QUERY><NAME>All Groups</NAME><DESCRIPTION></DESCRIPTION><DN></DN><FILTERLASTLOGON>-1</FILTERLASTLOGON><LDAPQUERY>(&amp;(objectCategory=group)(name=*))</LDAPQUERY><ONELEVEL>FALSE</ONELEVEL><COLUMNID>{065F0E25-75CB-44B7-BE21-AD75AB48E30A}</COLUMNID><DSQUERYUIDATA>050000000c00000043006f006d006d006f006e00510075006500720079000000020000000308000000480061006e0064006c00650072000000100000005ee6238ac231d011891c00a024ab2dbb030500000046006f0072006d00000010000000cbe7168cc2172947a6698474d6712b81080000004400730051007500650072007900000002000000010900000056006900650077004d006f0064006500000004130000010d00000045006e00610062006c006500460069006c007400650072000000000000002a00000028006f0062006a00650063007400430061007400650067006f00720079003d0070006500720073006f006e00290028006f0062006a0065006300740043006c006100730073003d0075007300650072002900000005000000010a0000004e0061006d00650043006f006d0062006f00000000000000010a000000440065007300630043006f006d0062006f00000000000000010d000000440069007300610062006c00650043006800650063006b00000000000000010f0000004e006f006e0045007800700050007700640043006800650063006b00000000000000010f0000004c006100730074004c006f0067006f006e0043006f006d0062006f000000000000001a00000028006f0062006a00650063007400430061007400650067006f00720079003d0063006f006d00700075007400650072002900000003000000010a0000004e0061006d00650043006f006d0062006f00000000000000010a000000440065007300630043006f006d0062006f00000000000000010d000000440069007300610062006c00650043006800650063006b000000000000001700000028006f0062006a00650063007400430061007400650067006f00720079003d00670072006f00750070002900000002000000010a0000004e0061006d00650043006f006d0062006f0000000c200000010a000000440065007300630043006f006d0062006f00000000000000</DSQUERYUIDATA></QUERY>
1 change: 1 addition & 0 deletions Queries/AD/UserQuery.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<QUERY><NAME>All Users</NAME><DESCRIPTION></DESCRIPTION><DN></DN><FILTERLASTLOGON>-1</FILTERLASTLOGON><LDAPQUERY>(&amp;(objectCategory=person)(objectClass=user)(name=*))</LDAPQUERY><ONELEVEL>FALSE</ONELEVEL><COLUMNID>{998FE675-1E9E-4A50-8BF6-A806C5045B53}</COLUMNID><DSQUERYUIDATA>050000000c00000043006f006d006d006f006e00510075006500720079000000020000000308000000480061006e0064006c00650072000000100000005ee6238ac231d011891c00a024ab2dbb030500000046006f0072006d00000010000000cbe7168cc2172947a6698474d6712b81080000004400730051007500650072007900000002000000010900000056006900650077004d006f0064006500000004130000010d00000045006e00610062006c006500460069006c007400650072000000000000002a00000028006f0062006a00650063007400430061007400650067006f00720079003d0070006500720073006f006e00290028006f0062006a0065006300740043006c006100730073003d0075007300650072002900000005000000010a0000004e0061006d00650043006f006d0062006f0000000c200000010a000000440065007300630043006f006d0062006f00000000000000010d000000440069007300610062006c00650043006800650063006b00000000000000010f0000004e006f006e0045007800700050007700640043006800650063006b00000000000000010f0000004c006100730074004c006f0067006f006e0043006f006d0062006f000000000000001a00000028006f0062006a00650063007400430061007400650067006f00720079003d0063006f006d00700075007400650072002900000003000000010a0000004e0061006d00650043006f006d0062006f00000000000000010a000000440065007300630043006f006d0062006f00000000000000010d000000440069007300610062006c00650043006800650063006b000000000000001700000028006f0062006a00650063007400430061007400650067006f00720079003d00670072006f00750070002900000002000000010a0000004e0061006d00650043006f006d0062006f00000000000000010a000000440065007300630043006f006d0062006f00000000000000</DSQUERYUIDATA></QUERY>
8 changes: 8 additions & 0 deletions SmallUtilities/All-In-One start.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Run following on the backup restore page from console command replacing FILENAME.wpress with the target backup

var filename = 'FILENAME.wpress';
var importer = new Ai1wm.Import();
var storage = Ai1wm.Util.random(12);
var options = Ai1wm.Util.form('#ai1wm-backups-form').concat({name: 'storage', value: storage}).concat({name: 'archive', value: filename});
importer.setParams(options);
importer.start();
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,16 @@ function Get-CiscoPhoneStreams
return ConvertFrom-Csv $results
}

Write-Output "To run this script, dot-source the file using . .\Get-CiscoPhoneStreams.ps1 then run Get-Help Get-CiscoPhoneStreams"

if ($(Split-Path $MyInvocation.InvocationName -Leaf) -eq $MyInvocation.MyCommand) {
try {
# If so, run the Get-CiscoPhoneStreams function
Get-CiscoPhoneStreams @args

}
catch {
Write-Output "This script can be dot-sourced using using . .\Get-CiscoPhoneStreams.ps1 then run Get-Help Get-CiscoPhoneStreams for more details."
}
}

# # Notes: The following are the array ID of the Stream stat, the stream stat name, and the +1 in the array for that stat which should correspond to its value
# 1,Device logs,Streaming statistics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,15 @@ function Get-LoggedInUser
$out += $users
}
Write-Output $out
}

if ($(Split-Path $MyInvocation.InvocationName -Leaf) -eq $MyInvocation.MyCommand) {
try {
# If so, run the Get-LoggedInUser function
Get-LoggedInUser @args

}
catch {
Write-Output "This script can be dot-sourced using using . .\Get-LoggedInUser.ps1 then run Get-Help Get-LoggedInUser for more details."
}
}
58 changes: 58 additions & 0 deletions SmallUtilities/Dot-Sourceable/Get-NetSpeed.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
function Get-NetSpeed {
#SIZE OF SPECIFIED FILE IN MB (10 or 100)
$size = 100

#FILE TO DOWNLOAD
$downloadUrl = "http://ipv4.download.thinkbroadband.com/$($size)MB.zip"
$uploadUrl = "http://ipv4.download.thinkbroadband.com/$($size)MB.zip"

#WHERE TO STORE DOWNLOADED FILE
$localfile = "$($env:TEMP)/$($size)MB.zip"

Write-Output "$($size)MB test started at $(get-date -Format "HH:mm:ss MM/dd/yyyy")"

#RUN DOWNLOAD
$webclient = New-Object System.Net.WebClient
$webclient.Headers.Add("User-Agent: Other")
$downloadstart_time = Get-Date
$webclient.DownloadFile($downloadurl, $localfile)

#CALCULATE DOWNLOAD SPEED
$downloadtimetaken = $((Get-Date).Subtract($downloadstart_time).Seconds)
$downloadspeed = ($size / $downloadtimetaken)*8
Write-Output "Time taken: $downloadtimetaken second(s) | Download Speed: $downloadspeed mbps"

#RUN UPLOAD
$uploadstart_time = Get-Date
$webclient.UploadFile($UploadURL, $localfile) > $null;

#CALCULATE UPLOAD SPEED
$uploadtimetaken = $((Get-Date).Subtract($uploadstart_time).Seconds)
$uploadspeed = ($size / $uploadtimetaken) * 8
Write-Output "Upload currently broken. Need to find site to allow for upload testing"
Write-Output "Time taken: $uploadtimetaken second(s) | Upload Speed: $uploadspeed mbps"

#DELETE TEST DOWNLOAD FILE
Remove-Item –path $localfile

}

if ($(Split-Path $MyInvocation.InvocationName -Leaf) -eq $MyInvocation.MyCommand) {
try {
# If so, run the Get-NetSpeed function
Get-NetSpeed @args

}
catch {
Write-Output "This script can be dot-sourced using using . .\Get-NetSpeed.ps1 then run Get-Help Get-NetSpeed for more details."
Write-Output "Work In Process - Download works but upload is broken. Script runs clean."
}
}

# # Small download version
# function Get-NetworkSpeed {
# $a=Get-Date
# Invoke-WebRequest http://ipv4.download.thinkbroadband.com/10MB.zip|Out-Null
# $output = "$((10/((Get-Date)-$a).TotalSeconds)*8) Mbps Download"
# return $output
# }
45 changes: 45 additions & 0 deletions SmallUtilities/Dot-Sourceable/Get-ServiceUptime.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function Get-ServiceUptime
{
<#
.SYNOPSIS
Gets the uptime for a specific service on the machine

.DESCRIPTION
Uses Get-CimInstance to identify the process connected to a service. Then pulls the creation date and calculates uptimes of the service based on that.

.PARAMETER Name
Service name

.EXAMPLE
PS C:\> ServiceUptime -Name wuauserv
Shows the uptime for the wuauserv service
#>

[CmdletBinding()]
param(
[string]$Name
)

# Prepare name filter for WQL
$Name = $Name -replace "\\","\\" -replace "'","\'" -replace "\*","%"

# Fetch service instance
$Service = Get-CimInstance -ClassName Win32_Service -Filter "Name LIKE '$Name'"

# Use ProcessId to fetch corresponding process
$Process = Get-CimInstance -ClassName Win32_Process -Filter "ProcessId = $($Service.ProcessId)"

# Calculate uptime and return
return (Get-Date) - $Process.CreationDate
}

if ($(Split-Path $MyInvocation.InvocationName -Leaf) -eq $MyInvocation.MyCommand) {
try {
# If so, run the Get-ServiceUptime function
Get-ServiceUptime @args

}
catch {
Write-Output "This script can be dot-sourced using using . .\Get-ServiceUptime.ps1 then run Get-Help Get-ServiceUptime for more details."
}
}
Loading