Skip to content

Instantly share code, notes, and snippets.

@pkutzner
pkutzner / Get-EndpointInfo.ps1
Last active August 7, 2024 03:12
Get various bits of info from endpoints.
[CmdletBinding(SupportsShouldProcess,DefaultParameterSetName='[INSERT]')]
Param (
[Parameter(ParameterSetName='Devices')]
$Devices,
[string[]]$Items = 'All',
[uint16]$MaxThreads = 20,
[uint16]$SleepTimer = 500,
[uint16]$MaxWaitAtEnd = 600,
@pkutzner
pkutzner / Get-Functions.ps1
Created August 6, 2024 17:34
Get list of declared functions from script
[CmdletBinding(SupportsShouldProcess)]
param (
[string]$Path
)
if (Test-Path -Path $Path) {
$Tokens = [System.Management.Automation.PSParser]::Tokenize((Get-Content -Path $Path),[ref]$null)
}
$StartLines = $Tokens | Where-Object {$_.Type -eq 'Keyword' -and $_.Content -ilike 'function'} | Select -ExpandProperty StartLine
@pkutzner
pkutzner / ConfigureRemotingForAnsible.ps1
Created February 25, 2024 21:05
Script to configure PSRemoting for Ansible
#Requires -Version 3.0
# Configure a Windows host for remote management with Ansible
# -----------------------------------------------------------
#
# This script checks the current WinRM (PS Remoting) configuration and makes
# the necessary changes to allow Ansible to connect, authenticate and
# execute PowerShell commands.
#
# All events are logged to the Windows EventLog, useful for unattended runs.
ComputerName
OnlineStatus
WSManStatus (i.e. Powershell Remoting)
IPAddress
FQDN
PTR
SysInfo:
RAM
Manufacturer
Model
@pkutzner
pkutzner / color.pkla
Created August 21, 2023 22:19
Add to /etc/polkit-1/localauthority/50-local.d to remove the color device error when using xrdp
[Allow colord for all users]
Identity=unix-user:*
Action=org.freedesktop.color-manager.create-device;org.freedesktop.color-manager.create-profile;org.freedesktop.color-manager.delete-device;org.freedesktop.color-manager.delete-profile;org.freedesktop.color-manager.modify-device;org.freedesktop.color-manager.modify-profile;org.freedesktop.packagekit.system-sources-refresh
ResultAny=yes
ResultInactive=yes
ResultActive=yes
@pkutzner
pkutzner / README.md
Created November 20, 2021 15:30 — forked from zoilomora/README.md
How to disable cloud-init in Ubuntu

How to disable cloud-init in Ubuntu

Prevent start

  • Create an empty file to prevent the service from starting

      sudo touch /etc/cloud/cloud-init.disabled
    

Uninstall

#!/bin/sh -e
#
# 98-vpn - Automatically bring up VPN on listed WiFi UUIDs
#
# Copyright (c) 2019 Preston Kutzner <pkutzner at gmail dot com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License (GPL) as published
# by the Free Software Foundation (FSF), either version 3 of the License,
# or (at your option) any later version.
@pkutzner
pkutzner / get_google_ranges.sh
Last active November 24, 2019 16:29
Shell script to get public Google Cloud IP ranges
#!/usr/bin/env bash
#set -x
#trap read debug
URL="_cloud-netblocks.googleusercontent.com"
get_ranges() {
local includes=($(host -t TXT "$1"| egrep -o "include:_cloud-[^ ]*" | cut -d':' -f2))
local ranges=($(host -t TXT "$1" | egrep -o "ip4:((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?/([0-9]?[1-3][0-9]))" | cut -d':' -f2))
@pkutzner
pkutzner / shodan_ips.txt
Created March 11, 2019 20:32
shodan_ips
198.20.69.74
198.20.69.98
198.20.70.114
198.20.99.130
93.120.27.62
66.240.236.119
71.6.135.131
66.240.192.138
71.6.167.142
82.221.105.6
#!/bin/bash -
#===============================================================================
#
# FILE: csb_updated.sh
#
# USAGE: ./csb_updated.sh
#
# DESCRIPTION: Updated version of Client SQL Backup (csb) script.
#
# OPTIONS: ---