Skip to content

Instantly share code, notes, and snippets.

View AfroThundr3007730's full-sized avatar
🔧
Hacking all the things...

Eddie Carswell AfroThundr3007730

🔧
Hacking all the things...
View GitHub Profile
@AfroThundr3007730
AfroThundr3007730 / Get-ESXiSerials.ps1
Last active March 31, 2024 18:55
Get the serial number and service tags for ESXi hosts
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
)
@AfroThundr3007730
AfroThundr3007730 / Write-ScriptEvent.ps1
Last active March 31, 2024 18:55
Wrapper to write PowerShell transcripts to the event log
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
@AfroThundr3007730
AfroThundr3007730 / AutoConnect-VIServer.ps1
Last active March 31, 2024 18:55
Automate PowerCLI connection to vCenter
# 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') {
@AfroThundr3007730
AfroThundr3007730 / vm-deploy-progress.ps1
Last active March 31, 2024 18:55
Get completion percentage for batch VM clone tasks
# Get completion percentage for batch VM clone tasks
function Get-VMDeployProgress() {
[Alias('deployProgress')]
Param(
[string]$VCUser = $global:DefaultVIServers[0].User.Split('\')[1]
)
do {
$Tasks = Get-Task | Where-Object { $_.Name -match 'clone' `
-and $_.State -match 'running' `
-and $_.ExtensionData.Info.Reason.UserName -match $VCUser }
@AfroThundr3007730
AfroThundr3007730 / SignScript.ps1
Last active March 31, 2024 18:25
Wrapper to Set-AuthenticodeSignature
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
)
@AfroThundr3007730
AfroThundr3007730 / Get-SSLServerCertificate.ps1
Last active March 31, 2024 18:25
Powershell function similar to openssl -s_client to retrieve a certificate
function Get-SSLServerCertificate {
<# .SYNOPSIS
Retrieves the X509 certificate by connecting to a SSL enabled server #>
[Alias('s_client')]
Param(
# Hostname or IP address to connect to
[Parameter(Mandatory)]
[String]$Hostname,
# Port to connect to
[Parameter()]
@AfroThundr3007730
AfroThundr3007730 / Get-SMSManagementPoint.ps1
Last active March 31, 2024 18:24
Finds SCCM management point in AD based on site code
function Get-SMSManagementPoint {
<# .SYNOPSIS
Finds SCCM management point based on site code #>
Param(
# The site code to search
[Parameter(Mandatory)]
[string]$SiteCode
)
return [adsisearcher]::new(
@AfroThundr3007730
AfroThundr3007730 / Resolve-DnsRecordAllDCs.ps1
Last active March 31, 2024 18:24
Resolves a DNS record on all active DCs in a domain
function Resolve-DnsRecordAllDCs {
<# .SYNOPSIS
Resolves a DNS record on all active DCs in a domain #>
[Alias('nslookup_all')]
Param(
# Name to resolve
[Parameter(Mandatory, ValueFromPipeline)]
[string]$Name,
# Type of record
[Parameter(ValueFromPipelineByPropertyName)]
@AfroThundr3007730
AfroThundr3007730 / Edit-VMDKHeader.ps1
Created October 24, 2022 20:12
Edit the metadata header of a VMDK file
Set-StrictMode -Version Latest
function Edit-VMDKHeader {
<# .SYNOPSIS
Edit the metadata header of a VMDK file #>
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
Param(
# The VMDK file to edit
[Parameter(Mandatory)]
[string]$VMDKFile
@AfroThundr3007730
AfroThundr3007730 / Invoke-GithubFileRequest.ps1
Created April 3, 2023 18:41
Powershell function to retrieve a file from a Github repository
Set-StrictMode -Vesion Latest
function Invoke-GithubFileRequest {
<# .SYNOPSIS
Retrieves a file from a Github repository. #>
[Alias('gh_curl')]
Param(
# URL of file to download
[Parameter(Mandatory)]
[Uri]$URL,