Skip to content

Instantly share code, notes, and snippets.

View mcc85s's full-sized avatar
💭
Keeping it real and simple.

Michael C Cook Sr. mcc85s

💭
Keeping it real and simple.
  • Secure Digits Plus LLC
  • 201D Halfmoon Circle, Clifton Park NY
View GitHub Profile
@mcc85s
mcc85s / Elevate-Script.ps1
Last active November 10, 2022 14:09
self elevating powershell script
$ID = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
If (!($ID.IsInRole("Administrator") -or $ID.IsInRole("Administrators")))
{
If (Get-CimInstance Win32_OperatingSystem | ? { [UInt32]$_.BuildNumber -ge 6000 })
{
Write-Host "Not running as admin, attempting elevation..."
$Command = $MyInvocation | % { "-File `"{0} {1}`"; Exit" -f $_.MyCommand.Path, $_.UnboundArguments }
Start-Process PowerShell -Verb Runas -Args $Command
}
@mcc85s
mcc85s / Download-WindowsServer2019.ps1
Last active November 10, 2022 15:08
Server2019.ps1
Function Download-WindowsServer2019
{
[CmdLetBinding()]Param(
[Parameter(Position=0,Mandatory=$True)][String]$Path)
$Current = [Net.ServicePointManager]::SecurityProtocol
[Net.ServicePointManager]::SecurityProtocol = 3072
Import-Module BITSTransfer
$Image = "17763.379.190312-0539.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us.iso"
@mcc85s
mcc85s / Gather-Download.ps1
Last active November 10, 2022 15:08
For downloading any file, assuming a default location, and immediately obtaining and displaying the SHA256 output of said file once it is downloaded
Function Gather-Download
{
[CmdLetBinding()]Param(
[ValidateNotNullOrEmpty()]
[Parameter(Position=0,Mandatory)][String]$URL,
[Parameter(Position=1)][String]$Path="$Home\Downloads",
[Parameter(Position=2)][String]$Info=$URL,
[Parameter(Position=3)][Switch]$Hash)
Import-Module BitsTransfer
@mcc85s
mcc85s / Character Arrays
Last active November 10, 2022 14:55
Precalculating an array
# // __________________________________
# // | Original @ 09/26/2019 14:49:00 |
# // ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
# // __________________________________________________________________________________________________________
# // |¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
# // | Example, you want to have a spacing in the way your stuff is written to the screen. |
# // | You can have characters already fully assembled, and then select the distance with the array selector. |
# // | You can use this idea in a couple different ways... |
# // |________________________________________________________________________________________________________|
@mcc85s
mcc85s / Start-ProcessExt.ps1
Last active November 10, 2022 13:51
An idea to extend process execution/handling
$Path = "File path"
$Arguments = "Arguments"
If (![System.IO.File]::Exists($Process))
{
Throw "File does not exist"
}
$Name = Split-Path $Path -Leaf
$WorkingDirectory = Split-Path $Path -Parent
$Process = [System.Diagnostics.Process]::New()
Class CustomProperty
{
[UInt32] $Index
Hidden [String] $Path
Hidden [Object] $Property
[String] $Name
[Object] $Value
[UInt32] $Exists
[Object] $Target
[UInt32] $Compliant
@mcc85s
mcc85s / Import-NTDSCertificate.ps1
Last active February 1, 2023 19:09
To import an NTDS Store Certificate... not yet tested.
# Bennett @ https://stackoverflow.com/questions/21895800/powershell-script-to-install-certificate-into-active-directory-store
# Modified/Simplified
Function Import-NTDSCertificate
{
[ CmdletBinding () ] Param (
[ Parameter ( Mandatory ) ] [ String ] $File ,
[ Parameter ( Mandatory ) ] [ String ] $Password ,
#Remove certificate from LocalMachine\Personal certificate store
@mcc85s
mcc85s / VMDKConversion.ps1
Last active November 10, 2022 15:10
For converting a VirtualBox/VMware vmdk file to vhdx
# [VMDK] (VMWare/VirtualBox) -> [VHDX] (Hyper-V)
# https://gist.github.com/rahilwazir/69a750b70348459875cbf40935af02cb
# Microsoft Virtual Machine Converter (Link active as of 2021_0121)
# http://download.microsoft.com/download/9/1/E/91E9F42C-3F1F-4AD9-92B7-8DD65DA3B0C2/mvmc_setup.msi
# Import Module
Import-Module "C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1"
# Pathing
@mcc85s
mcc85s / Hyper-V.ps1
Created January 24, 2022 13:52
# [Install Hyper-V Manager on Windows 10 Home]
# [Install Hyper-V Manager on Windows 10 Home]
$OS = Get-CimInstance Win32_OperatingSystem
If ($OS.Caption -match "Home")
{
Get-ChildItem $Env:SystemRoot\servicing\Packages\*Hyper-V*.mum | % {
dism /online /norestart /add-package:"$($_.FullName)"
}
dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /All
$Gps = [System.Device.Location.GeoCoordinateWatcher]::New()
$Gps.Start()