Skip to content

Instantly share code, notes, and snippets.

View pldmgg's full-sized avatar

Paul DiMaggio pldmgg

View GitHub Profile
@pldmgg
pldmgg / AnacondaEnv.psm1
Last active July 8, 2020 09:00
Set Anaconda Environment in PowerShell
#region >> Helper Functions
function Get-FilePath {
[CmdletBinding()]
Param (
[Parameter(Mandatory=$True)]
[string]$FileNameWExtension,
[Parameter(Mandatory=$True)]
[string[]]$DirectoriesToSearch
@pldmgg
pldmgg / WinRM_Cheat_Sheet.ps1
Last active August 5, 2019 22:21
WinRM Config Cheat Sheet
try {
$null = Enable-PSRemoting -Force -ErrorAction Stop
}
catch {
$null = Get-NetConnectionProfile | Where-Object {$_.NetworkCategory -eq 'Public'} | Set-NetConnectionProfile -NetworkCategory 'Private'
try {
$null = Enable-PSRemoting -Force -ErrorAction Stop
}
catch {
@pldmgg
pldmgg / MobyLinux.ps1
Created May 8, 2018 14:44
MobyLinux.ps1 Hyper-V VM Management from Docker CE Install
<#
.SYNOPSIS
Manages a MobyLinux VM to run Linux Docker on Hyper-V
.DESCRIPTION
Creates/Destroys/Starts/Stops A MobyLinux VM to run Docker on Hyper-V
.PARAMETER VmName
If passed, use this name for the MobyLinux VM, otherwise 'MobyLinuxVM'
@pldmgg
pldmgg / Get-LDAPCert_Sample_Output
Created April 4, 2018 16:21
Get-LDAPCert_Sample_Output
PS C:\Users\zeroadmin> $636Test = Get-LDAPCert -LDAPServerHostNameOrIP ZeroDC02.zero.lab -Port 636
PS C:\Users\zeroadmin> $636Test | fl *
LDAPEndpointCertificateInfo : @{X509CertFormat=[Subject]
CN=ZeroDC02.zero.lab
[Issuer]
CN=ZeroDC01, O=ZERO, C=LAB
@pldmgg
pldmgg / VaultTokenManagement.ps1
Last active April 1, 2018 01:25
Vault Token Management
# Example Usage:
# PS C:\Users\testadmin> $CurrentTokens = Get-VaultTokens -VaultBaseUri "http://192.168.2.12:8200/v1" -VaultAuthToken "myroot"
# PS C:\Users\testadmin> $CurrentTokens
function Get-VaultTokens {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$VaultBaseUri, # Should be something like "http://192.168.2.12:8200/v1"
[Parameter(Mandatory=$True)]
@pldmgg
pldmgg / GetNetNatExternalAddressOutput.txt
Created March 19, 2018 18:23
Output of PowerShell Get-NetNatExternalAddress
PS C:\Users\pdadmin> Get-NetNatExternalAddress
ExternalAddressID : 0
NatName : ICS74e71ad9-651a-4d18-98f0-5fd67522ede4
IPAddress : 127.0.0.1
PortStart : 49708
PortEnd : 49717
Active : True
@pldmgg
pldmgg / DockerForWindowsManagement.ps1
Last active March 21, 2018 16:18
A few functions to help manage Docker For Windows
function Start-DockerAfterReboot {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$False)]
[switch]$SkipPrompt
)
if (!$(Check-Elevation)) {
Write-Error "The $($MyInvocation.MyCommand.Name) function must be run with elevated privileges (i.e. start PowerShell with 'Run As Administrator'). Halting!"
$global:FunctionResult = "1"
@pldmgg
pldmgg / dhcpd.conf
Created March 8, 2018 16:28
Centos7 dhcpd.conf
# dhcpd.conf
# option definitions common to all supported networks...
option domain-name "random.lab";
option domain-name-servers 8.8.8.8;
option option-128 code 128 = string;
option option-129 code 129 = text;
default-lease-time 600;
max-lease-time 7200;
@pldmgg
pldmgg / Error-HandlingTest.ps1
Created February 14, 2018 16:10
PowerShell Error Handling Output Testing
function Test-Func {
try {
$NewVagrantBoxResult = New-VagrantBox -VagrantBox "centos/7" -ErrorVariable NVBErr -ErrorAction SilentlyContinue
if (!$NewVagrantBoxResult) {throw "The New-VagrantBox function failed!"}
$NewVagrantBoxResult
}
catch {
Write-Error $_
Write-Error $($NVBErr | Out-String)
@pldmgg
pldmgg / HyperV_Networking.txt
Created February 1, 2018 14:13
HyperV_Networking
PS C:\Users\zeroadmin> Get-VMSwitch -Name ToInternal | fl *
Name : ToInternal
Id : 2302da2b-bf3c-42eb-93f7-4e37fa7da892
Notes :
Extensions : {Microsoft Windows Filtering Platform, Microsoft Azure VFP Switch Extension, Microsoft NDIS Capture}
BandwidthReservationMode : Absolute
PacketDirectEnabled : False
EmbeddedTeamingEnabled : False
IovEnabled : False