Skip to content

Instantly share code, notes, and snippets.

View hybridadmin's full-sized avatar

Tinashe Chikomo hybridadmin

View GitHub Profile
Function Get-PendingReboot
{
<#
.SYNOPSIS
Gets the pending reboot status on a local or remote computer.
.DESCRIPTION
This function will query the registry on a local or remote computer and determine if the
system is pending a reboot, from Microsoft updates, Configuration Manager Client SDK, Pending Computer
Rename, Domain Join or Pending File Rename Operations. For Windows 2008+ the function will query the
@hybridadmin
hybridadmin / Get-VM-Guest-Info.ps1
Created April 4, 2019 10:25 — forked from mikerodionov/Get-VM-Guest-Info.ps1
Function to get VM Guest Information from Hyper-V Server
# Source: http://www.yusufozturk.info/virtual-machine-manager/getting-virtual-machine-guest-information-from-hyper-v-server-2012r2.html
# Usage example: Get-VMGuestInfo -VMName TEST01 -HyperVHost VMHOSTT01
function Get-VMGuestInfo
{
<#
.SYNOPSIS
Gets virtual machine guest information
.EXAMPLE
$iniPath="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini"
$newText = ([System.IO.File]::ReadAllText($iniPath)).Replace("# enable-named-pipe", "enable-named-pipe")
[System.IO.File]::WriteAllText($iniPath, $newText)
Restart-Service MySQL57
<#
.SYNOPSIS
Performs a SQL query and returns an array of PSObjects.
.NOTES
Author: Jourdan Templeton - hello@jourdant.me
.LINK
https://blog.jourdant.me/post/simple-sql-in-powershell
#>
function Invoke-SqlCommand() {
[cmdletbinding(DefaultParameterSetName="integrated")]Param (
#!/usr/bin/env python3
import sys
from string import Template
import uuid
if (len(sys.argv) < 4):
print("Usage: generate.py {username} {password} {hostname}")
exit(0)
username = sys.argv[1]
@hybridadmin
hybridadmin / 00README.md
Created June 28, 2020 11:54 — forked from natefoo/00README.md
Linux Distribution Detection

Distribution Detection

I am working on adding support for building and distributing (via PyPI) Python Wheels with C Extensions to the Python wheel and pip packages. The discussion on Distutils-SIG continues, but I believe it is fairly certain that some effort to correctly identify Linux distributions will need to be made. I've begun efforts to add this support to wheel.

How you can help

If you have a Linux distribution or version of a listed distribution not in this gist, or one of the ones I have not directly verified, I could use the following:

  • The contents of /etc/os-release, if it exists
@hybridadmin
hybridadmin / valid_domain_name_regex
Created August 28, 2020 15:21 — forked from neu5ron/valid_domain_name_regex
Valid domain name regex including internationalized domain name
domain_regex = r'(([\da-zA-Z])([_\w-]{,62})\.){,127}(([\da-zA-Z])[_\w-]{,61})?([\da-zA-Z]\.((xn\-\-[a-zA-Z\d]+)|([a-zA-Z\d]{2,})))'
#Python
domain_regex = '{0}$'.format(domain_regex)
valid_domain_name_regex = re.compile(domain_regex, re.IGNORECASE)
self.domain_name = self.domain_name.lower().strip().encode('ascii')
if re.match(valid_domain_name_regex, self.domain_name ):
return True
else:
return False
@hybridadmin
hybridadmin / ansible-galaxy-find-role-id.sh
Created November 3, 2020 17:17 — forked from pavlov99/ansible-galaxy-find-role-id.sh
Find your role's id in ansible-galaxy
$ ansible-galaxy info YourUser.RoleName | grep -E 'id: [0-9]' | awk {'print $2'}
@hybridadmin
hybridadmin / gist:163adaf3dbce3ed4bdc1f5e76a9749c5
Last active June 4, 2021 12:46 — forked from rroemhild/gist:190970
simple shell script log function
# Vars for log()
LOGGER="/usr/bin/logger" # Path to logger
FACILITY="LOCAL2" # Syslog facility
PROG="´basename $0´" # Program name
SYSLOG="YES" # Write to Syslog? (YES/NO)
VERBOSE="YES" # Write to STDOUT? (YES/NO)
log(){
# Function: log()
# Usage: log priority "message"
@hybridadmin
hybridadmin / myscript
Created June 5, 2021 10:48 — forked from neatshell/myscript
simple bash template that handles mandatory and optional arguments
#!/bin/bash
script="myscript"
#Declare the number of mandatory args
margs=2
# Common functions - BEGIN
function example {
echo -e "example: $script -m0 VAL -m1 VAL -o1 -o2 VAL"
}