This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict" | |
const u_btoa = str => btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (_match, pl) => String.fromCharCode('0x' + pl))) | |
const u_atob = str => decodeURIComponent(atob(str).split('').map(c => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)).join('')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Set-ScriptSignature { | |
<# .SYNOPSIS | |
Wrapper function to sign and timestamp a script file #> | |
[Alias('SignScript')] | |
Param( | |
# The script file to sign | |
[Parameter(Mandatory)] | |
[String]$ScriptFile | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-RunningTasks() { | |
while ((Get-Task | Where-Object { $_.state -eq 'running' }).count -gt 0) { | |
Get-Task | Where-Object { $_.state -eq 'running' } | | |
Sort-Object name, percentcomplete | | |
Format-Table Name, State, PercentComplete, StartTime, | |
@{ L = 'Target'; E = { $_.ExtensionData.Info.EntityName } }, | |
@{ L = 'Initiator'; E = { $_.ExtensionData.Info.Reason.UserName } } | |
Start-Sleep 10 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Version 1 | |
$idleDays = 2 | |
$users = (((query user) -replace '^>', '') -replace '\s{2,}', ',').Trim() | | |
ForEach-Object { | |
if ($_.Split(',').Count -eq 5) { | |
Write-Output ($_ -replace '(^[^,]+)', '$1,') | |
} | |
else { | |
Write-Output $_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# Generates a bash script to recursively download a Google Drive folder | |
# Original: https://gist.github.com/immuntasir/73b8e8eef7e6c9066aaf2432bebf7db0 | |
import sys | |
from pydrive.auth import GoogleAuth | |
from pydrive.drive import GoogleDrive | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-ESXiSerials { | |
<# | |
.SYNOPSIS | |
Get the serial number and service tags for ESXi hosts | |
#> | |
Param( | |
# Full name of host or a regex | |
[Parameter(Mandatory = $false)] | |
[string]$HostSpec | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Write-ScriptEvent { | |
<# | |
.SYNOPSIS | |
Wrapper to write PowerShell transcripts to the event log. | |
#> | |
Param( | |
# Transcript file to read from | |
[Parameter(Mandatory = $true)] | |
[string]$LogFile, | |
# Event source to apply |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Archives roaming profiles for deleted accounts, then | |
# deletes old archived profiles, after retention period. | |
Start-Transcript C:\ProgramData\profile-hygiene.log -Append | |
$homePath = '\\file\User_Home$' | |
$profilePath = '\\file\User_Profile$' | |
function Remove-UserDirectory ($archivePath) { | |
foreach ($dir in (Get-ChildItem $archivePath)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Automated PowerCLI connections to vCenter Server | |
# Script will use stored PSCredentials if user is unprivileged | |
function AutoConnect-VIServer () { | |
Param( | |
[string]$server = 'vcenter' | |
) | |
# Check if user is in a group with vCenter permissions | |
if ([System.Security.Principal.WindowsIdentity]::GetCurrent().Groups.Translate( | |
[System.Security.Principal.NTAccount]) -contains 'DOMAIN\vCenter_Admins') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Hook to sign VMware kernel modules after kernel install | |
# Place at: /etc/kernel/install.d/98-vmware-modconfig.install | |
COMMAND="${1:-add}" | |
KERNEL_VER="${2:-$(uname -r)}" | |
SIGN_CMD="/lib/modules/$KERNEL_VER/build/scripts/sign-file" | |
SBSIGN_KEY='/etc/efikeys/db.key' | |
SBSIGN_CRT='/etc/efikeys/db.crt' |