This file contains hidden or 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
# this located in /storage/.config/autostart.sh on a CoreELEC box, run chmod +x to make it executable | |
# use nohup to run the script in the backgroud | |
# nohup /storage/freemyip/updateDynDNS.sh & | |
# use this to run once off tasks | |
( | |
# pause few seconds to wait for network & time services to start | |
sleep 5 | |
DT=$(date +"%m-%d-%Y, %r") | |
echo "Box rebooted on $DT, running tasks in autostart.sh" >> /storage/freemyip/DynDNSUpdate.log |
This file contains hidden or 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
#!/bin/sh | |
# It calls an external python script sendmail.py to email the new IP out | |
# This should work on both bash and sh shells e.g. LibreELEC/CoreELEC | |
# DYNU Dynamic IP Updater | |
# https://wiki.libreelec.tv/useful_shell_scripts#dynu_dynamic_ip_updater | |
# Modified to update Freemyip DYNDNS | |
# Modify These for DYNU or other DynDNS services e.g. Freemyip, DuckDNS, etc. | |
DYNU_USERNAME="username" |
This file contains hidden or 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
::This script can be used to Upgrade, Downgrade, Remove or Deploy an application | |
::It extracts software GUID, then use the GUID to search it's related keys/values pairs | |
::This is the FASTEST Way to find out Name, Version & UninstallString | |
::Get DisplayName & DisplayVersion from 32bit (or 64bit) "Java 8 Update 172" or any software Uninstall GUID, | |
::End script (or you can use this to downgrade your version of Java), if both Name and Version found and matched. | |
::If Name found but version doesn't match, get the UninstallString, uninstall ALL 32bit (or 64bit) Java then install the one defined in script silently. | |
::If Name NOT found, then end script or you can install it | |
@echo off | |
setlocal ENABLEDELAYEDEXPANSION |
This file contains hidden or 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
##### Simple Way, return an array or string (if 1 item is returned) ####### | |
$Date = @(Invoke-Sqlcmd -query "Select Convert(Varchar(11),Date,106) as Date From ValuationDate" -Server DBSERVER -Database DBNAME) | Select-Object -Expand Date | |
#####[ Another way to query MS SQL, it returns a Dataset Object ]##### | |
$SQLServer = "DBSERVER_NAME" #use Server\Instance for named SQL instances! | |
$SQLDBName = "DATABASE_NAME" | |
$SqlQuery = "Select something From A_TABLE" | |
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection |
This file contains hidden or 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
' Created this for monthly compliance purpose, it collects Local Admin Users and AV on a machine | |
' Get software list from Registry Key. It can only list software installed by installer (*.exe & *.msi) | |
' Won't work with Preinstalled, Portable apps | |
' NOTE: I collected codes from few websites and didn't take a note of them. Please let me know | |
' if you found some portion of the code belongs to you. I will add a credit asap. | |
' REF: https://gallery.technet.microsoft.com/scriptcenter/8035d5a9-dc92-436d-a60c-67d381da15a3 | |
If WScript.Arguments.Count <> 0 then | |
' assign parameter to strComputerName | |
strComputerName = WScript.Arguments(0) |
This file contains hidden or 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
Param($eventFilePath) | |
# Get the first/latest event from "Forwarded Events" event log and | |
# Replace the field value and field name with meaningful value e.g. convert SID to proper user name and Full Name | |
$Event = Get-WinEvent -FilterHashtable @{Logname='ForwardedEvents'; Id=8004} -MaxEvents 1 | |
If($Event.UserId.Value -eq $null) | |
{ | |
return | |
} else { | |
$objSID = New-Object System.Security.Principal.SecurityIdentifier($Event.UserId.Value) |
This file contains hidden or 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
# PDF Files Check Script (created by beancurd1, please distribute the code with this session, thanks) | |
# It uses itextsharp.dll (downloaded from SourceForge) to parse PDF files, extract the first date it found | |
# compare it against a predefined Date. Email the PDF file names to people if they doesn't match the predefined date | |
Add-Type -Path .\itextsharp.dll | |
$validDate = "11 Dec 2015" | |
$day = ([datetime]$validDate).ToString('dd') ; $day = $day -replace "^0", "" | |
#Define valid Month+Year format here, this will combine with $day in the search | |
$validMYArray = @(([datetime]$validDate).ToString(' MMM yyyy')) |
This file contains hidden or 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
### [datetime] ALWAYS assumes MDY format irrespective of your culture when the following format is being converted | |
### therefore, it requires to use ParseExact in order correct this | |
[datetime]::ParseExact('9/11/2015','d/MM/yyyy', $null).ToString('dd MMM yyyy') | |
([datetime]'9 Dec 2015').ToString('dd MMMM yyyy') | |
Get-Date -Format 'dd MMM yyyy' | |
### Different ways of calculating TimeSpan | |
$StartDate = (GET-DATE) | |
$EndDate = [datetime]::ParseExact('22/12/2015','d/MM/yyyy', $null) | |
NEW-TIMESPAN –Start $StartDate –End $EndDate |
This file contains hidden or 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
# Created by beancurd1 (please distribute the code with this session, thanks) | |
# https://gist.github.com/beancurd1 | |
# A useful script to manage GFS retention in a single folder which contains backup files | |
# such as "backup_ddMMyyy.7z". It looks for backups done within a year, then put them | |
# into Monthly, Weekly & Daily.groups | |
Clear | |
# Create a String array to store end of month dates for X months (e.g. 31DEC15 to 31JAN15) | |
# define how many years of data to retain (it will search files created in that year, split them into Monthly, Weekly and Daily) | |
$year=1 |