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
@techthoughts2
techthoughts2 / ps_lambda
Last active June 27, 2023 16:11
Some basic code snips for PowerShell Lambda Stuff
#Download the .NET Core 2.1 SDK from https://www.microsoft.com/net/download
Install-Module AWSPowerShell.NetCore
Install-Module AWSLambdaPSCore
Import-Module AWSPowerShell.NetCore
Import-Module AWSLambdaPSCore
Get-Command -Module AWSLambdaPSCore
New-Item PSLambda -ItemType Directory
@techthoughts2
techthoughts2 / winrm
Last active December 3, 2018 05:19
A collection of WinRM stuff
#------------------------------------------------------
#ENABLE WINRM
#https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/enable-psremoting?view=powershell-6
#according to documentation this runs Set-WSManQuickConfig which basically does all the same stuff as the quickconfig
Enable-PSRemoting
#alternatively use this - but documentation indicates it's not as thorough
winrm quickconfig
#to turn back off:
Disable-PSRemoting
#------------------------------------------------------
@techthoughts2
techthoughts2 / quickJSON
Last active November 13, 2018 22:40
Simple method for rapidly creating a JSON structure using PowerShell syntax. ClipboardText helps to get it into the clipboard.
#install-module ClipboardText
#super fast PS way to create quick JSON
ConvertTo-Json -Compress -InputObject @{
JsonItem1 = "I Am Item1 content"
JsonItem2 = "I Am Item2 content"
JsonItem3 = "I Am Item3 content"
} | Set-ClipboardText
@techthoughts2
techthoughts2 / Get-ServerLogs
Last active November 11, 2018 17:49
Establishes a remote connection to specified device and queries server logs based on user specified criteria. (Log name, Log Level, Start and End times). If user does not provide log search criteria, a set of defaults are set: [System, Application with Critical, Errors, and Warnings for the last 24 hours]. If no logs are found that match the cri…
<#
.SYNOPSIS
Retrieves specified logs from remote host for time period specified
.DESCRIPTION
Establishes a remote connection to specified device and queries server logs based on user specified criteria. (Log name, Log Level, Start and End times). If user does not provide log search criteria, a set of defaults are set: [System, Application with Critical, Errors, and Warnings for the last 24 hours]. If no logs are found that match the criteria a result is returned to the user to easily place in a ticket or other correspondence.
.EXAMPLE
$creds = Get-Credential;Get-ServerLogs -HostName Server01 -Credential $creds
Retrieves server logs with all defaults: System & Application will be queried for Warning, Error, Critical, for the last 24 hours. User will be prompted to supply creds.
.EXAMPLE
@techthoughts2
techthoughts2 / pscore_winModules
Created November 7, 2018 02:06
Use Windows PowerShell modulels in PowerShell Core by appending the Windows PowerShell PSModulePath to your PowerShell Core PSModulePath
<#
Most of the modules that ship as part of Windows (for example, DnsClient, Hyper-V, NetTCPIP, Storage, etc.) and other Microsoft products including Azure and Office have not been explicitly ported to .NET Core yet.
By installing the WindowsPSModulePath module, you can use Windows PowerShell modules by appending the Windows PowerShell PSModulePath to your PowerShell Core PSModulePath.
#>
# Add `-Scope CurrentUser` if you're installing as non-admin
Install-Module WindowsPSModulePath -Force
# Add this line to your profile if you always want Windows PowerShell PSModulePath
Add-WindowsPSModulePath
#C:\Program Files\PowerShell\Modules
#C:\Program Files\WindowsPowerShell\Modules
$a = Get-Module powershellget -ListAvailable
$a.Path
Get-Module -ListAvailable $module | Remove-Module -Force;Install-Module $module -Repository PSGallery -Force -AllowClobber
@techthoughts2
techthoughts2 / powershell.json
Last active April 11, 2021 19:55
Collection of PowerShell Snippets for VSCode
"Help": {
"prefix": "help",
"body": [
"<#",
".SYNOPSIS",
"\tShort description",
".DESCRIPTION",
"\tLong description",
".EXAMPLE",
"\tC:\\PS>",
@techthoughts2
techthoughts2 / Win10_1809_RSAT
Last active October 5, 2018 19:44
You may have issues installing RSAT on Windows 10 1809 if you are using WSUS. The following block of code will address that by setting the WSUS key temporarily, installing RSAT, and then setting the key back to original
# Set variables
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\"
$name = "UseWUServer"
$value = "0"
$service = "wuauserv"
# Reset variables
$resetValue = Get-ItemPropertyValue -Name $name -Path $registryPath
# Set reg value and restart service
@techthoughts2
techthoughts2 / vs_code_extensions
Last active December 2, 2022 17:59
List of Visual Studio Code extensions that I am currently using. Heavy focus with PowerShell development and AWS CloudFormation.
<#
CoenraadS.bracket-pair-colorizer-2
DanielThielking.aws-cloudformation-yaml
DavidAnson.vscode-markdownlint
DotJoshJohnson.xml
PKief.material-icon-theme
SirTori.indenticator
Tyriar.shell-launcher
aaron-bond.better-comments
almenon.arepl
@techthoughts2
techthoughts2 / settings.json
Last active December 14, 2024 06:24
Visual Studio Code User Settings that I currently use. Heavy focus on PowerShell, Python, AWS, and Azure.
{
//USEFUL INFORMATION
//https://code.visualstudio.com/docs/editor/settings-sync
//https://github.com/tonsky/FiraCode/wiki/VS-Code-Instructions
//https://github.com/microsoft/cascadia-code/blob/master/README.md
//https://github.com/adam7/delugia-code/releases
// @installed
// @category:"themes"
// @popular
//SYNC SETTINGS