Copy Locked File Windows

## Usage: .\copy_locked_file.ps1 -lockedfilepath windows\appcompat\programs\Amcache.hve -destination C:\

param (
  $LockedFilePath = $(throw "LockedFilePath parameter is required."),
  $Destination = $(throw "Destination parameter is required.")
)

$LastShadow = (Get-WmiObject -list win32_shadowcopy).create("C:\","ClientAccessible")
$LastShadowID = $LastShadow | Select-Object -Last 1 -ExpandProperty ShadowID
$LastShadowRef = Get-WmiObject win32_shadowcopy | Where-Object { $_.ID -eq $LastShadowID }
$LastShadowPath = $LastShadowRef | Select-Object -Last 1 -ExpandProperty DeviceObject
$FullPath = $LastShadowPath + '\' + $LockedFilePath
cmd /c copy $FullPath $Destination
vssadmin delete shadows /Shadow=$LastShadowID /Quiet

Create Swap File

sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Borg Hourly Backup

isodate=$(date -Ihours)
borg create -v --stats -p repo::hourly_$isodate input_dir

Convert VHDX to VMDK

sudo apt-get install qemu-utils -y
qemu-img convert $1 -O vmdk $2

Kill VMware VM

vmrun -T ws stop vmware/VM/myVM.vmx hard