Skip to content

Instantly share code, notes, and snippets.

View techthoughts2's full-sized avatar
🕵️‍♂️
Investigating a better artifact workflow

Jake Morrison techthoughts2

🕵️‍♂️
Investigating a better artifact workflow
View GitHub Profile
{
"version": "2.0.0",
"tasks": [
{
"label": "CF Resource List",
"type": "process",
"command": "chrome.exe",
"windows": {
"command": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
},
@techthoughts2
techthoughts2 / install_python
Last active February 10, 2019 20:12
Chocolatey install of python on windows
#from admin console window
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install python
#now setup for cf-lint
python -m pip install --upgrade pip
pip install cfn-lint
function Get-FreeDriveLetter {
$regex = "[A-Z]:"
$netuseOutput = net use
$driveArray = @()
$providers = Get-PSDrive -PSProvider FileSystem
$psdriveDriveLetters = $providers.Name
$driveArray += $psdriveDriveLetters
$netuseDriveLetters = ($netuseOutput | Select-String -Pattern $regex).Matches.Value
$netuseDriveLetters = $netuseDriveLetters -replace ':', ""
$driveArray += $netuseDriveLetters
@techthoughts2
techthoughts2 / git_commands
Last active January 5, 2019 00:34
Collection of Git Commands
git clone https://repo_address.git
git add .
git add --all
git commit -m "Initial commit"
git push origin master
git pull origin master
git config user.name "Jake"
@techthoughts2
techthoughts2 / ps_suppress
Created January 3, 2019 21:45
Examples of PSScriptAnalyzer Suppressions
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "", Justification = "While it has start verb, it doesn't actually change the system state")]
@techthoughts2
techthoughts2 / ps_gpo
Last active January 3, 2019 01:06
PS GPO Stuff
#get RSOP from a server core device (can be run remotely)
Get-GPResultantSetOfPolicy -Computer Server1 -ReportType Html -Path C:\temp\Server1_SOP.html
@techthoughts2
techthoughts2 / PS_Redirects
Last active January 2, 2019 06:40
Various ways to handle redirects
<#
try {
$a = Invoke-WebRequest -Uri $uri -MaximumRedirection 0 -ErrorAction Stop
}#try_Invoke-WebRequest
catch {
#if($_.ErrorDetails.Message -like "*maximum redirection*"){
if($_.Exception.Message -like "*Moved*"){
Write-Verbose -Message 'Moved detected.'
#$result = $a.Headers.Location
$result = $a.Exception.Response.Headers.Location.AbsoluteUri
Get-InstalledModule | Select-Object Name, @{n='Installed';e={$_.Version}}, @{n='Available';e={(Find-Module -Name $_.Name).Version}} | Where-Object {$_.Available -gt $_.Installed}
################################################################################
# The "nice" way to reset the LCM...
if (-not(Test-Path -Path 'C:\Temp')) { $null = New-Item -Path 'C:\Temp' -ItemType 'Directory'}
[DscLocalConfigurationManager()]
Configuration ResetLCM {
Param (
[String[]]
$NodeName
)
Node $NodeName {
@techthoughts2
techthoughts2 / schedule_cron
Last active June 14, 2024 10:06
Scheduled cron expressions and examples of using cron to scheudle things in AWS
cron(Minutes | Hours | Day-of-month | Month | Day-of-week | Year)
cron(0 0/4 * * ? *) Every 4 hours
cron(0 10 * * ? *) 10:00AM UTC everyday
cron(15 12 * * ? *) 12:15PM UTC everyday
cron(0 18 ? * MON-FRI *) 6:00PM UTC every Mon-Fri
cron(0 8 1 * ? *) 8:00AM UTC every first day of the month
cron(0/10 * ? * MON-FRI *) Every 10 min Mon-Fri
cron(0/5 8-17 ? * MON-FRI *)Every 5 minutes Mon-Fri between 8:00AM - 5:55PM UTC
cron(0 9 ? * 2#1 *) 9:00AM UTC first Monday of each month