Skip to content

Instantly share code, notes, and snippets.

Avatar
🕵️‍♂️
Investigating a better artifact workflow

Jake Morrison techthoughts2

🕵️‍♂️
Investigating a better artifact workflow
View GitHub Profile
@techthoughts2
techthoughts2 / Send-TelegramTextMessage
Last active Jun 18, 2021
This PowerShell function will send a Telegram message via the Telegram Bot API. Specify your Bot token and chat ID and send text messages to the specified Telegram chat via PowerShell.
View Send-TelegramTextMessage
<#
.Synopsis
Sends Telegram text message via Bot API
.DESCRIPTION
Uses Telegram Bot API to send text message to specified Telegram chat. Several options can be specified to adjust message parameters.
.EXAMPLE
$bot = "#########:xxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxx"
$chat = "-#########"
Send-TelegramTextMessage -BotToken $bot -ChatID $chat -Message "Hello"
.EXAMPLE
@techthoughts2
techthoughts2 / CustomPSObject
Last active Jun 16, 2021
Several examples of creating and working with custom PowerShell objects and hash tables. Examples include creating customer Powershell objects that contain multiple values.
View CustomPSObject
#Jake Morrison - @jakemorrison - http://techthoughts.info
$results = [PSCustomObject]@{
HypTotal = $hyptotal
MgmtVMTotal = $mgmtVMTotal
UniqueCustomerCount = $customerTotal
TotalComputerObjects = $allCompsTotal
TotalUserObjects = $userTotal
}
View powershell_array
#------------------------------------------------------------------------------
# adding stuff to emtpy array objects quickly
$myarray = [System.Collections.ArrayList]::new()
[void]$myArray.Add('Value')
#------------------------------------------------------------------------------
@techthoughts2
techthoughts2 / settings.json
Last active May 17, 2021
Visual Studio Code User Settings that I currently use. Heavy focus on PowerShell, Python, AWS, and Azure.
View settings.json
{
//SETTINGS CHANGES
"breadcrumbs.enabled": false,
"explorer.confirmDragAndDrop": false,
"omnisharp.projectLoadTimeout": 120,
"workbench.settings.editor": "json",
"workbench.tree.indent": 15,
"workbench.editor.titleScrollbarSizing": "large",
//LOOK AND FEEL CHANGES
//editor
@techthoughts2
techthoughts2 / ws_setup.ps1
Last active May 13, 2021
This PowerShell script will setup a fresh workstation with everything needed to sucessfully work and be a DevOps Master day-to-day.
View ws_setup.ps1
#region installs
# basic choco installs
$script:chocoInstalls = @(
# 'ytmdesktop' #https://github.com/ytmdesktop/ytmdesktop/issues/563
'vscode' # visual studio code
'powershell-core' # powershell 7+
'python' # python
'cacher' # code snippet organizer
'winscp' # Open source free SFTP client, SCP client, FTPS client and FTP client
View autoCompletion.ps1
$GetVM={Get-VM | Select-Object -ExpandProperty Name}
$AutoCompleteVM = @{
CommandName = 'New-Foo'
ParameterName = 'VMName'
ScriptBlock = $GetVM
}
Register-ArgumentCompleter @AutoCompleteVM
View sort_ips.ps1
[string[]]('222.1.3.4','1.2.3.4' | % {[Version]$PSItem} | sort)
View cpu_stress
$NumberOfLogicalProcessors = Get-CimInstance win32_processor | Select-Object -ExpandProperty NumberOfLogicalProcessors
ForEach ($core in 1..$NumberOfLogicalProcessors) {
start-job -ScriptBlock {
$result = 1;
foreach ($loopnumber in 1..2147483647) {
$result = 1;
foreach ($loopnumber1 in 1..2147483647) {
$result = 1;
View profile.ps1
#region functions
<#
.SYNOPSIS
Returns weather report information.
.DESCRIPTION
Console-oriented weather forecast that returns weather information for specified parameters.
.EXAMPLE
Get-Weather
Returns full weather information based on the location of your IP with all defaults.
@techthoughts2
techthoughts2 / powershell.json
Last active Apr 11, 2021
Collection of PowerShell Snippets for VSCode
View powershell.json
"Help": {
"prefix": "help",
"body": [
"<#",
".SYNOPSIS",
"\tShort description",
".DESCRIPTION",
"\tLong description",
".EXAMPLE",
"\tC:\\PS>",