Skip to content

Instantly share code, notes, and snippets.

@JustinGrote
JustinGrote / PowerAltoPlus.psm1
Last active February 26, 2024 17:16
An extension of the PowerAlto module to enable running "ssh" commands via RPC-XML thru panorama to managed devices without having direct line of sight to the managed firewalls. A sample report dump of the Arp/Route/Interface/VPN is included
#requires -module PowerAlto, ImportExcel
$ErrorActionPreference = 'Stop'
if (-not $MacVendorCache) {
Write-Warning 'MacVendorCache not found, downloading from maclookup.app. This is common on the first run.'
$SCRIPT:MacVendorCache = @{}
foreach ($entry in $(ConvertFrom-Csv (Invoke-RestMethod 'https://maclookup.app/downloads/csv-database/get-db'))) {
$MacVendorCache[$entry.'Mac Prefix'] = $entry.'Vendor Name'
}
}
@fearthecowboy
fearthecowboy / sample.cmd
Last active March 3, 2021 22:48
This file is a legal .cmd script and a legal powershell script.
@(echo off) > $null
set null( New-Module -ScriptBlock { function goto { }; function :{ } } )#=
: # This file is both a .cmd script and a powershell script. if you save it as
: # sample.cmd and run it it from cmd.exe it will run the same as if you
: # saved it as sample.ps1 and run it.
: # well, in this case, I added some echos on the cmd side...
goto :CMDSTART
@vexx32
vexx32 / PowershellLoopBehavior.md
Last active November 15, 2024 18:59 — forked from JustinGrote/PowershellLoopBehavior.md
Reference Table for Loop Behavior in Powershell
Loop Return Continue Break
Normal Expectation Exit Scope Next Item Exit Loop
.foreach{} Next Item Break Scopes / Next Item of Parent Loop Break Scopes / Exit Parent Loop
foreach ($y in $x) Exit Scope Next Item Exit Loop
for ($i;$i -lt 5;$i++) Exit Scope Next Item Exit Loop
Foreach-Object -InputObject @() Next Item Break Scopes / Next Item of Parent Loop Break Scopes / Exit Parent Loop
Switch Exit Scope Next Item Exit Switch
While
@jermdavis
jermdavis / Extract-TarGz.ps1
Created May 9, 2019 14:14
A PowerShell script that can extract .tar.gz files on Windows - with minimal dependencies to make it easy to use on servers.
[cmdletbinding(SupportsShouldProcess=$True)]
param(
# What .tar.gz file should be extracted? Must exist.
[Parameter(Mandatory=$True)]
[string]$FileToExtract,
# What folder should the files be extracted into? Does not need to exist
[Parameter(Mandatory=$True)]
[string]$TargetFolder,
# Tail Sitecore log files, even when using rolling log files
# ==========================================================
# 1) Copy this file into your App_Data folder or set the logFolder parameter to point to the Sitecore logs folder.
# 2) Run it in Powershell
# 3) View the log messages as they appear (even if the worker process recycles)
param (
[string]$logFolder = ".\\logs\\",
[string]$filter = "log.*",
[int]$tailAmount = 20
)
@xfixic
xfixic / Windows10RSATFeaturesEnable.ps1
Created March 5, 2019 12:46
Enable RSAT Features on Windows 10 1809 Using PowerShell
$currentWU = Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "UseWUServer" | select -ExpandProperty UseWUServer
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "UseWUServer" -Value 0
Restart-Service wuauserv
Get-WindowsCapability -Name RSAT* -Online | Remove-WindowsCapability –Online
Add-WindowsCapability –online –Name “Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0”
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "UseWUServer" -Value $currentWU
Restart-Service wuauserv
@asmorger
asmorger / new_system_install.ps1
Last active March 5, 2019 18:01
.Net Core Developer New System Setup Script
$packages = @(
#dev tools
"jetbrains-rider",
"dotcover",
"dotpeek",
"dotmemory",
"dottrace",
"vscode",
"gitkraken",
@wictorwilen
wictorwilen / flow-bot-azure-function.js
Last active June 2, 2021 04:10
Microsoft Teams Outgoing Webhook Proxy for Microsoft Flow
const crypto = require('crypto');
const request = require('request');
const bufSecret = Buffer('OUTGOING-WEBHOOK-SECRET', "base64");
const flowWebhook = 'MICROSOFT-FLOW-URL';
module.exports = function (context, req) {
var auth = req.headers['authorization'];
// HMAC security validation
function ConvertTo-ChocoPackage {
<#
.SYNOPSIS
Convert a PowerShell module into a chocolatey package.
.DESCRIPTION
Convert a PowerShell module into a chocolatey package.
.EXAMPLE
Find-Module pester | ConvertTo-ChocoPackage
Find the module pester on a PS repository and convert the module to a chocolatey package.
@pythoninthegrass
pythoninthegrass / profile.ps1
Created January 17, 2018 00:22
PowerShell Profile
<#
# ┌ ┐
# sources
# └ ┘
https://gist.github.com/cloudRoutine/87c17655405cd8b1eac7
https://gist.github.com/furzeface (not sure where profile.ps1 URL disappeared to)
#>
# If this script is throwing an error near a Unicode symbol try resaving the file as UTF-8 with BOM
$psmodules = ";~\Documents\WindowsPowerShell\Modules"