Skip to content

Instantly share code, notes, and snippets.

View joshooaj's full-sized avatar

Josh Hendricks joshooaj

View GitHub Profile
@joshooaj
joshooaj / New-VmsSelfSignedCertificate.ps1
Last active August 7, 2023 17:59
New-VmsSelfSignedCertificate
#Requires -RunAsAdministrator
#Requires -Modules pki
#Requires -Assembly System.Windows.Forms
<#
.SYNOPSIS
Creates a new web server certificate signed by a self-signed "root" signing certificate.
.DESCRIPTION
This script creates a new web server certificate and adds it to the
Cert:\LocalMachine\My certificate store, where it can be used by a Milestone
@potatoqualitee
potatoqualitee / sys-summit-demo.ps1
Last active June 28, 2022 08:41
dbatools for systems engineers and accidental dbas
break
<#
01. Find instances
02. Connect to instances
03. Check backups
04. Check disk space
05. Perform backups
06. Check for corruption
07. Install maintenance scripts
08. Export all settings for DR
@Jaykul
Jaykul / About Batch and PowerShell.md
Last active January 24, 2024 05:27
Executable PowerShell (wrap a ps1 and name it cmd)

This is always my answer to all those "compile your .ps1" solutions that are floating around. Why would you wrap your PowerShell in an exe and some custom host?

Just paste this header on the top of your PowerShell script, and then before you share it, rename it with the .cmd extension. While you're writing, it's a nice syntax-highlighted PowerShell script, and when you rename it, *poof* it's double-clickable. Drop it in the PATH and you can execute it from the Run dialog or from PowerShell, batch, whatever.

Because there are still people around who actually use CMD, I've updated it to show how to handle passing parameters.

A couple of notes:

  1. It runs with ExecutionPolicy unrestricted because if you're still using CMD you probably haven't configured your ExecutionPolicy
  2. It uses -NoProfile to make sure the environment is the same on everyone's PC...
  3. It only creates function :: {} because that allows us to ignore the :: on the first line
@jborean93
jborean93 / Invoke-WithImpersonation.ps1
Last active June 7, 2024 15:17
Invoke a scriptblock in powershell with impersonation
# Copyright: (c) 2020, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Invoke-WithImpersonation {
<#
.SYNOPSIS
Invoke a scriptblock as another user.
.DESCRIPTION
Invoke a scriptblock and run it in the context of another user as supplied by -Credential.