Skip to content

Instantly share code, notes, and snippets.

View wolruf's full-sized avatar

Olivier wolruf

  • Cloudflare
  • France
  • 06:39 (UTC +02:00)
  • X @wolruf
View GitHub Profile
@mreferre
mreferre / Hyper-V-NAT.ps1
Last active June 8, 2023 10:08
PS commands to create a Hyper-V internal switch and NAT rules
# the following 3 lines of PowerShell creates an Internal Switch on Hyper-V (https://www.petenetlive.com/KB/Article/0001384)
New-VMSwitch -SwitchName "NAT-Switch" -SwitchType Internal
New-NetIPAddress -IPAddress 192.168.200.1 -PrefixLength 24 -InterfaceAlias "vEthernet (NAT-Switch)"
New-NetNAT -Name "NAT-Network" -InternalIPInterfaceAddressPrefix 192.168.200.0/24
# the following line of PowerShell creates a DNAT rule (80->80) from the outside into a VM (previously created an running on the Switch with IP .10) (https://www.petri.com/create-nat-rules-hyper-v-nat-virtual-switch)
Add-NetNatStaticMapping -ExternalIPAddress "0.0.0.0/24" -ExternalPort 80 -Protocol TCP -InternalIPAddress "192.168.200.10" -InternalPort 80 -NatName NAT-Network
@PatrickTerlisten
PatrickTerlisten / Reclaim-ThinVMDK.ps1
Last active February 21, 2018 15:30
This script uses sdelete to zero-out all disks of a Windows VM. Afterwards, the VM is moved between datastores to reclaim zeroed space.
<#
.SYNOPSIS
No parameters needed. Just execute the script.
.DESCRIPTION
This script uses sdelete to zero-out all disks of a Windows VM. Afterwards, the VM
is moved between datastores to reclaim zeroed space.
History
v1.3: Redesign.