Skip to content

Instantly share code, notes, and snippets.

View othtim's full-sized avatar

Tim Scott othtim

  • Edmonton, Alberta, Canada
View GitHub Profile
@othtim
othtim / gist:1a1378471d4ea377ff99711154161ede
Created October 30, 2017 15:13
ManageEngine Servicedesk request time spent by technicion
SELECT
CASE WHEN sdo.NAME IS NULL THEN sdo2.Name ELSE sdo.NAME END "Site",
COALESCE(wtk.WORKORDERID , wo.workorderid) "Ticket Number",
CASE WHEN to_timestamp(MAX(wo.createdtime)/1000)::DATE IS NULL THEN to_timestamp(MAX(wo2.createdtime)/1000)::DATE ELSE to_timestamp(MAX(wo.createdtime)/1000)::DATE END"Request Created Date",
to_timestamp(MAX(ct.createdtime)/1000)::TIMESTAMP "Time Spent Created Time",
rctd.FIRST_NAME "Time Spent Technician",
CAST(SUM(ct.TIMESPENT) AS FLOAT)/1000/3600 "Time Spent",
CASE WHEN MAX(tk.TASKID) IS NOT NULL THEN MAX(wo2.TITLE) ELSE MAX(wo.TITLE) END "Title",
ct.DESCRIPTION FROM ChargesTable ct
LEFT JOIN WorkOrderToCharge wotoc ON ct.CHARGEID=wotoc.CHARGEID
@othtim
othtim / gist:23cdcac8a2dd27d27b0c5aeaa0b2c0a7
Created September 7, 2017 18:34
reorganize wireshark
#time, sourceip, destinationip, packet length, sourceport, destinationport
while(<>){
s/\"//g;
@i = split(',');
$j = join(",",($i[1] , $i[2], $i[3], $i[5], $i[length(@i)-1], $i[length(@i)-2]));
next unless $j =~ m/^[0-9.]+,[0-9.]+,[0-9.]+,[0-9]+,[0-9]+,[0-9]+/;
print $j;
#print "\n";
}
# 14
$registryPath = "HKCU:\Software\Microsoft\Office\14.0\Common\MailSettings"
IF(Test-Path $registryPath){
New-ItemProperty -Path $registryPath -Name "NewSignature" -Value "medium" -PropertyType String -Force | Out-Null
}
# 15
$registryPath = "HKCU:\Software\Microsoft\Office\15.0\Common\MailSettings"
IF(Test-Path $registryPath){
New-ItemProperty -Path $registryPath -Name "NewSignature" -Value "medium" -PropertyType String -Force | Out-Null
# 14
$registryPath = "HKCU:\Software\Microsoft\Office\15.0\Common\MailSettings"
IF(Test-Path $registryPath){
New-ItemProperty -Path $registryPath -Name "NewSignature" -Value "medium" -PropertyType String -Force | Out-Null
}
# 15
$registryPath = "HKCU:\Software\Microsoft\Office\15.0\Common\MailSettings"
@othtim
othtim / gist:c55e1966248925842866b94b6b44e8b6
Created June 21, 2017 22:13
use: cat something.txt | perl parse.pl . then strip next down to one column. then cat result.txt | perl aggregate.pl > output.txt
parse.pl:
----
while (<>) {
$_ =~ s/\[\s+\d\]//g;
$_ =~ s/\s+/,/g ;
$_ =~ s/^,|,$//g;
print split(/\n/,$_);
print "\n";
}
$time = (Get-Date).Adddays(-(90))
Get-ADUser -SearchBase "ou=terminated users,dc=contoso,dc=ads" -Filter {LastLogonTimeStamp -lt $time -and enabled -eq $false} | foreach {Get-Mailbox $_.name} | foreach {New-MailboxExportRequest -Mailbox $_ -FilePath "\\SERVERINO\backup\$($_.Alias).pst"}
while (<>) {
$_ =~ s/\[\s+\d\]//g;
$_ =~ s/\s+/,/g ;
$_ =~ s/^,|,$//g;
print split(/\n/,$_);
print "\n";
}
@othtim
othtim / gist:345b0bc1e4a3c64dc8020c17d6658724
Last active April 28, 2017 21:12
SEP.cloud Logon script installer
try {
# check if SEP.cloud installed
$sym = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where {$_.DisplayName -eq "Symantec Endpoint Protection.cloud"}
# if SEP.cloud is not installed
if(! $sym){
## first elevate to admin. Benjamin Armstrong
# Get the ID and security principal of the current user account
@othtim
othtim / ipcheck.sql
Created April 2, 2014 19:33
analyze IIS log errors by ip address
----select * from a
------total requests by IP
----select f9, count(*) from a
----group by f9
----order by 2 desc
@othtim
othtim / useagestats.sql
Last active August 29, 2015 13:58
Useage stats.sql
create table #SIRSusers (iCount int, cName varchar(100))
create table #TLXEusers (iCount int, cName varchar(100))
create table #HLSusers (iCount int, cName varchar(100))
create table #HLCusers (iCount int, cName varchar(100))
create table #totals (iCount int, cName varchar(100))
--HLS users