Skip to content

Instantly share code, notes, and snippets.

View pldmgg's full-sized avatar

Paul DiMaggio pldmgg

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / Instructions_For_Set-AnacondaEnv.ps1
Last active July 7, 2020 06:07
Set Anaconda Usage Instructions
# Launch Windows PowerShell 5.1 or PowerShell Core 6.x and download the AnacondaEnv.psm1 Module
# to your Downloads folder (or wherever you like)
PS C:\Users\zeroadmin> $AnaEnvModuleUrl = "https://github.com/pldmgg/misc-powershell/blob/master/MyModules/AnacondaEnv/AnacondaEnv.psm1"
PS C:\Users\zeroadmin> $OutputPath = "$HOME\Downloads\AnacondaEnv.psm1"
PS C:\Users\zeroadmin> Invoke-WebRequest -Uri $AnaEnvModuleUrl -OutFile $OutputPath
# Import the AnacondaEnv Module
PS C:\Users\zeroadmin> Import-Module $OutputPath
# Now the following functions are available to you in your current PowerShell Session: Set-AnacondaEnv, Revert-AnacondaEnv
@pldmgg
pldmgg / AllInfo.md
Created July 17, 2018 09:52
OpenSSH Public Cert Auth Issues

"OpenSSH for Windows" version

PS C:\Users\zeroadmin> ((Get-Item (Get-Command sshd).Source).VersionInfo.FileVersion)
7.7.1.0
PS C:\Users\zeroadmin> ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion\" -Name ProductName).ProductName)
Windows Server 2016 Standard Evaluation
PS C:\Users\zeroadmin> Get-Command ssh.exe

CommandType Name Version Source
@pldmgg
pldmgg / 1Home.png
Last active December 8, 2019 06:27
PUDNetworkMonitor
1Home.png