Skip to content

Instantly share code, notes, and snippets.

View quonic's full-sized avatar

Spyingwind quonic

  • Dallas
View GitHub Profile
function New-ATFilter {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = "EqualsSet")]
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = "NotEqualSet")]
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = "GreaterThanSet")]
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = "LessThanSet")]
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = "GreaterThanorEqualsSet")]
[Parameter(Mandatory = $true, Position = 0, ParameterSetName = "LessThanOrEqualsSet")]
@quonic
quonic / QueryXml.ps1
Last active November 29, 2017 16:39
Added fix from reddit post.
enum Operator {
Equals
NotEqual
GreaterThan
LessThan
GreaterThanorEquals
LessThanOrEquals
BeginsWith
EndsWith
Contains
@quonic
quonic / GPIO.ps1
Created December 27, 2017 17:50
Talk GPIO via Powershell Core
function Open-GPIOPin ([int]$Pin,[ValidateSet('in','out')][string]$Mode) {
[string]$Pin | Out-File -FilePath "/sys/class/gpio/export" -NoNewline
$Mode | Out-File -FilePath "/sys/class/gpio/gpio$Pin/direction" -NoNewline
}
function Send-GPIOBit ([int]$Pin,[ValidateRange(0,1)][int]$Bit) {
$Bit | Out-File -FilePath "/sys/class/gpio/gpio$Pin/value" -NoNewline
}
function Receive-GPIOBit ([int]$Pin) {
<#
.SYNOPSIS
Collects service account information from servers in a domain to a central file.
.DESCRIPTION
Service Account Scrobbler Script v.1.0.1
Date: Jan 2017
https://bytemech.com
.NOTES
Requirements:
1. Windows 2008 or higher Active Directory Powershell Module installed on local machine (script checks for this)
# Run this script to see connected hard disk status with nifty bar graph!
$myDisk = Get-WmiObject -class win32_logicaldisk
$myDisk | ForEach-Object {
$free = ($_.freespace)
$total = ($_.size)
$used = $total - $free
$perUsed = ($used / $total) * 100
$perFree = ($free / $total) * 100
$t = [math]::Round($total / 1gb)
$f = [math]::Round($free / 1gb)
@quonic
quonic / Install RT 4.4.2 depends.sh
Created April 15, 2018 02:09
This should install most of the perl depdends on Debian 9 for RT
apt install libcgi-emulate-psgi-perl libapache-session-perl libcrypt-eksblowfish-perl libconvert-color-perl libcgi-psgi-perl libcss-minifier-xs-perl libcss-squish-perl libdata-guid-perl libdata-ical-perl libbusiness-hours-perl libdate-manip-perl libdatetime-format-natural-perl libdatetime-locale-perl libdatetime-perl libdata-page-pageset-perl libdate-extract-perl libdbi-perl libdbix-searchbuilder-perl libdevel-globaldestruction-perl libdevel-stacktrace-perl libemail-address-list-perl libemail-address-perl libcrypt-ssleay-perl libdbd-mysql-perl libcrypt-x509-perl libfcgi-perl libfile-sharedir-perl libfile-which-perl libgd-graph-perl libgd-perl libgd-text-perl libgnupg-interface-perl libgraphviz-perl libhtml-formattext-withlinks-andtables-perl libhtml-formattext-withlinks-perl libhtml-mason-perl libhtml-mason-psgihandler-perl libhtml-quoted-perl libhtml-rewriteattributes-perl libhtml-scrubber-perl libhttp-message-perl libipc-run3-perl libipc-run-perl libjavascript-minifier-xs-perl libjson-perl liblocale-maketex
@quonic
quonic / Show-Calendar.ps1
Created April 23, 2018 18:10
Show-Calendar cmdlet
# From https://communary.net/2014/12/21/show-calendar-cal-for-powershell/
function Show-Calendar {
<#
.SYNOPSIS
Show calendar.
.DESCRIPTION
This function is a PowerShell version of the *NIX cal command and will show a
calendar of the chosen month(s). The current day will be marked with a '*'.
For best results, use together with the FormatPx module by Kirk Munro.
@quonic
quonic / AssignGroups.ps1
Last active April 24, 2018 18:46
AD Group assigner
$Users = Get-ADUser
$GroupData = Import-Clixml -Path ".\Groups.clixml"
$GroupsToAdd = $Users | ForEach-Object {
$User = $_
$Company = $GroupData.Companies | Where-Object {$_.Name -eq $User.Company}
$Departments = $Company.Departments | Where-Object {$_.Name -eq $User.Department}
$Departments.Groups
}
@quonic
quonic / Out-Audio.ps1
Created May 11, 2018 20:51
A nicer way to play audio files from a string.
# Get the asterisk-extra-sounds-en-wav-current.tar.gz file or the one for your language
# Extract to a folder, example C:\Temp\asterisk-extra-sounds-en-wav-1.5\
$AsteriskAudioFolder = "C:\Temp\asterisk-extra-sounds-en-wav-1.5\"
function Out-Audio {
[CmdletBinding()]
param (
[string[]]
$FilePath
)
@quonic
quonic / CredStore.ps1
Last active May 17, 2018 00:11
Store creds in a secure manner
function Get-ConfigData {
Param(
$Path = "$env:TEMP\MyScriptDefaultCredStore.config.clixml"
)
if (Test-Path -Path $Path) {
# Open Config file if exists
$ConfigData = Import-Clixml $Path
}
else {
# Create Config file if does not exists