Skip to content

Instantly share code, notes, and snippets.

@zaskem
zaskem / ExportEmailToPDF.gs
Last active Jan 18, 2021
A basic Google Apps Script that, when triggered from a Google Sheet, will export Gmail messages by label to PDF in the drive folder specified and log the basic information to she calling spreadsheet.
View ExportEmailToPDF.gs
function exportEmailToPDF() {
// Script Variables to Set
  var drivePath = DriveApp.getFolderById("LongStringOfTheDestinationFolderIdentifier");
  var plaintextPath = DriveApp.getFolderById("LongStringOfTheIntermediateFolderIdentifier");
  var label = GmailApp.getUserLabelByName("YourLabelNameGoesHere");
// End of Script Variables to Set
  var sheet = SpreadsheetApp.getActiveSpreadsheet();
  //Logger.log(label.getName()); // Write to log the name of the label (can help identify label typos)
  var threads = label.getThreads();
@zaskem
zaskem / certbot-multi-superdomain.sh
Created Oct 4, 2020
Basic Certbot bash automation script to bolt together key commands in manually-requesting a certificate for multiple variations (TLDs) of a domain, as outlined in https://mzonline.com/blog/2020-10/improving-manual-certbot-domain-validation
View certbot-multi-superdomain.sh
#!/bin/bash
certbot certonly --manual --manual-public-ip-logging-ok -d superdomain.net -d www.superdomain.net
read -n1 -r -s -p "Press any key to load certificate...`echo $'\r\n\r\n'`"
more /etc/letsencrypt/live/superdomain.net/cert.pem
read -n1 -r -s -p "Press any key to load private key...`echo $'\r\n\r\n'`"
more /etc/letsencrypt/live/superdomain.net/privkey.pem
read -n1 -r -s -p "Press any key to begin renewal process for superdomain.com...`echo $'\r\n\r\n'`"
certbot certonly --manual --manual-public-ip-logging-ok -d superdomain.com -d www.superdomain.com
read -n1 -r -s -p "Press any key to load certificate...`echo $'\r\n\r\n'`"
more /etc/letsencrypt/live/superdomain.com/cert.pem
@zaskem
zaskem / certbot-superdomain.sh
Created Oct 4, 2020
Basic Certbot bash automation script to bolt together key commands in manually-requesting a certificate, as outlined in https://mzonline.com/blog/2020-10/improving-manual-certbot-domain-validation
View certbot-superdomain.sh
#!/bin/bash
certbot certonly --manual --manual-public-ip-logging-ok -d superdomain.net -d www.superdomain.net
read -n1 -r -s -p "Press any key to load certificate...`echo $'\r\n\r\n'`"
more /etc/letsencrypt/live/superdomain.net/cert.pem
read -n1 -r -s -p "Press any key to load private key...`echo $'\r\n\r\n'`"
more /etc/letsencrypt/live/superdomain.net/privkey.pem
read -n1 -r -s -p "Press any key to end certificate renewal process...`echo $'\r\n\r\n'`"
@zaskem
zaskem / Certbot-Ubuntu-Quickstart.sh
Last active Oct 4, 2020
Companion/Quickstart bash script to manually install and use Certbot with key command steps as outlined in the post https://mzonline.com/blog/2020-10/moving-certbot-lets-encrypt
View Certbot-Ubuntu-Quickstart.sh
# Update Ubuntu and obtain/install/update Certbot
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
# Make a manual certificate request
sudo certbot certonly --manual -d superdomain.net
View CSVDataWithEmbeddedFormulas.csv
Column A Column B Column C Formula
1 2 5 =SUM(A2:C2)
5 3 10 =A3*C3+B3
2 2 4 =COUNTIF(A:C,2)
0 0 No =IF(and(A5=0,B5=0,C5="Yes"),1,0)
0 0 Yes =IF(and(A6=0,B6=0,C6="Yes"),1,0)
1 0 1 =IF(AND(A7=1,B7=0),"UPDATE",IF(AND(A7=0,B7=1),"CHECK","No Change"))
0 1 1 =IF(AND(A8=1,B8=0),"UPDATE",IF(AND(A8=0,B8=1),"CHECK","No Change"))
0 0 0 =IF(AND(A9=1,B9=0),"UPDATE",IF(AND(A9=0,B9=1),"CHECK","No Change"))
@zaskem
zaskem / Certbot-ManualMode.sh
Created Jul 5, 2020
Invoke certbot (new issue or renewal) in manual mode for two variations of a domain name
View Certbot-ManualMode.sh
sudo certbot certonly --manual --manual-public-ip-logging-ok -d domainnamehere.com -d www.domainnamenere.com
View Get-ADGroupsSortedByName.ps1
$groups = Get-ADGroup -Filter 'Name -like "PATTERNGOESHERE*"' | Select-Object Name, SamAccountName;
"There are "+ $groups.Count +" matching groups.";
$groupDetails = ForEach ($grp in $groups) {
New-Object PSObject -Property @{'Group Name'=$grp.Name;Count=(Get-ADGroupMember $grp.SamAccountName -Recursive).Count};
}
$groupDetails | Sort-Object -Property Count -Descending | Select-Object 'Group Name', Count;
View ExportMachinesByOU.ps1
Get-AdComputer -Filter * -Property * -SearchBase 'OU=PhysicalSpace,OU=LabMachines,OU=Computers,OU=Unit,DC=fabrikam,DC=com' | Select-Object Name, IPv4Address | Export-CSV .\PhysicalSpace-ADComputers.csv -NoTypeInformation -Encoding UTF8
@zaskem
zaskem / QueryMachines.ps1
Created Jan 12, 2020
Query Workstations in AD by Name Prefix
View QueryMachines.ps1
Get-ADComputer -Filter 'Name -like "MNS*"' -Property * | Select-Object Name, Description, DistinguishedName, OperatingSystem, OperatingSystemVersion, @{n='LastLogonTimeStamp';e={[DateTime]::FromFileTime($_.LastLogonTimeStamp)}}, WhenCreated, IPv4Address | Export-CSV .\WorkstationsLikeMNS.csv -NoTypeInformation -Encoding UTF8