Skip to content

Instantly share code, notes, and snippets.

View joeypiccola's full-sized avatar
⛰️

Joey Piccola joeypiccola

⛰️
View GitHub Profile
@mdnmdn
mdnmdn / ConvertTo-JSON.ps1
Last active January 2, 2022 14:10
ConvertTo-JSON for Powershell 2.0
function Escape-JSONString($str){
if ($str -eq $null) {return ""}
$str = $str.ToString().Replace('"','\"').Replace('\','\\').Replace("`n",'\n').Replace("`r",'\r').Replace("`t",'\t')
return $str;
}
function ConvertTo-JSON($maxDepth = 4,$forceArray = $false) {
begin {
$data = @()
}
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active June 22, 2024 09:39
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@follower46
follower46 / ObjectStorageUploader.py
Last active November 20, 2017 15:30
Object Storage Uploader Script
# ================================================================================
# ObjectStorageUploader.py
# © Copyright IBM Corporation 2014.
# LICENSE: MIT (http://opensource.org/licenses/MIT)
# ================================================================================
import argparse
import os
import math
import http.client
@bklockwood
bklockwood / offlinewucheck.ps1
Last active March 3, 2022 04:05
Powershell offline WU check
<#
This script performs the 'search' phase of a Windows Update, using the standard WUA API.
It does not download or install updates.
Sole purpose of this script is to find out how long it takes to download the required cabfile,
then process it against a live system and return the list of updates available for that system.
#>
function DownloadFile {
param (
[Parameter(Mandatory=$true,Position=0)] $url,
[Parameter(Mandatory=$true,Position=1)] $file
@daks
daks / auto.luks
Last active May 24, 2022 15:56
Autofs script to automount LUKS encrypted disks. Based on http://msqr.us/m2/archives/2009/07/configuring-automount-for-luks.html
#!/bin/bash
# This file must be executable to work! chmod 755!
#
# The LUKS key must exist as a file at /etc/.keys/${device}.key
# Protect this directory: root as user/group, 400 as permissions
#
# Edit your autofs master file to include something like
# /mnt/crypt /etc/auto.luks --timeout=600
#
# Then you can access your LUKS encrypted disk with
rem windows2012R2スクリプト
rem icmp(ping)を通す設定(”profile=public|private|domain|any”で個別指定可能)
netsh advfirewall firewall add rule name="ICMPv4 ping許可" protocol=icmpv4:8,any dir=in action=allow
rem メモ帳のショートカットをデスクトップに作成【done】
powershell -Command "&{$WsShell = New-Object -ComObject WScript.Shell; $Shortcut = $WsShell.CreateShortcut('C:\Users\Administrator\Desktop\memo.lnk'); $Shortcut.TargetPath = 'C:\Windows\System32\notepad.exe'; $Shortcut.IconLocation = 'C:\Windows\System32\notepad.exe'; $Shortcut.Save()}
rem コマンドプロンプトのショートカットをデスクトップに作成【done】
powershell -Command "&{$WsShell = New-Object -ComObject WScript.Shell; $Shortcut = $WsShell.CreateShortcut('C:\Users\Administrator\Desktop\cmd.lnk'); $Shortcut.TargetPath = 'C:\Windows\System32\cmd.exe'; $Shortcut.IconLocation = 'C:\Windows\System32\cmd.exe'; $Shortcut.Save()}
$token = '<API_Token>'
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}
$body = @{
accountName="<Your_account>"
projectSlug="<Your_project_slug>"
@arebee
arebee / Search-FileIndex.ps1
Last active September 14, 2023 23:08
Use Windows Search from PowerShell
function Search-FileIndex {
<#
.PARAMETER Path
Absoloute or relative path. Has to be in the Search Index for results to be presented.
.PARAMETER Pattern
File name or pattern to search for. Defaults to *.*. Aliased to Filter to ergonomically match Get-ChildItem.
.PARAMETER Text
Free text to search for in the files defined by the pattern.
.PARAMETER Recurse
Add the parameter to perform a recursive search. Default is false.
@jessereynolds
jessereynolds / 0-puppet-node-purging-via-api.md
Last active March 21, 2022 09:42
Puppet - Node Purging via APIs

Puppet Node Purging via API

When you're decomissioning a machine that has been managed by Puppet you may want to programatically clean up the node. There are two parts to this:

  • revoking and deleting the certificate of the node in Puppet's CA
  • deactivating the node in PuppetDB

The following should work for Puppet 4.x and Puppet DB 4.x (including Puppet Enterprise 2016.4.x, 2017.1.x, 2017.2.x).

I've used certificate based auth, and the examples are being run from the puppet master so make use of existing certificates for authentication. When run remotely the cacert, certificate and corresponding private key for authentication will need to be present.

@TJM
TJM / README.md
Last active March 25, 2023 01:16
Puppet SCCM Client Install as a package

SCCM Install using Puppet "package"

This script was donated by a customer of ours. They have sent us a sanitized version of the script to share.

Please use this at your own risk, and fully understand what it is doing before using it!

The Problem:

SCCM Installation fires off in the background and you have no idea whether it worked or not. Also, if any other installs try to start while the SCCM setup is running, you will get an error.