This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$VMName = "VM 1" | |
$BMPName = "C:\Users\benja\Desktop\test.bmp" | |
Add-Type -AssemblyName "System.Drawing" | |
$VMCS = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_ComputerSystem -Filter "ElementName='$($VMName)'" | |
# Get the resolution of the screen at the moment | |
$video = $VMCS.GetRelated("Msvm_VideoHead") | |
$xResolution = $video.CurrentHorizontalResolution[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$VMName = "VM 1" | |
Add-Type -AssemblyName "System.Drawing" | |
$VMCS = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_ComputerSystem -Filter "ElementName='$($VMName)'" | |
# Get the resolution of the screen at the moment | |
$video = $VMCS.GetRelated("Msvm_VideoHead") | |
$xResolution = $video.CurrentHorizontalResolution[0] | |
$yResolution = $video.CurrentVerticalResolution[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$VMName = "Windows" | |
# Load System.Drawing | |
Add-Type -AssemblyName "System.Drawing" | |
# Load AForge libraries - download from http://www.aforgenet.com/framework/ | |
Add-Type -Path "D:\aForge\Release\AForge.dll" | |
Add-Type -Path "D:\aForge\Release\AForge.Math.dll" | |
Add-Type -Path "D:\aForge\Release\AForge.Imaging.dll" | |
# Number parameter is percentage threshold for acuracy. 0.9 = 90% match |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$VMName = "New Virtual Machine" | |
# Rectangle format == top left x, top left y, width, height | |
# $cropRectangle = New-Object System.Drawing.Rectangle 35,485,218,147 | |
$cropRectangle = $null | |
$speakItToMe = $true | |
# Load System.Drawing | |
Add-Type -AssemblyName "System.Drawing" | |
# Load Tesseract - using code from https://github.com/jourdant/powershell-paperless |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prompt for the Hyper-V Server to use | |
$HyperVServer = Read-Host "Specify the Hyper-V Server to use (enter '.' for the local computer)" | |
# Get all virtual machine objects on the server in question | |
$VMs = Get-CimInstance -namespace root\virtualization\v2 Msvm_ComputerSystem -computername $HyperVServer -filter "Caption = 'Virtual Machine'" | |
# Create an empty hashtable | |
$table = @{} | |
# Go over each of the virtual machines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$foo = "7" | |
Invoke-Command -VMName "Test" { | |
param($localfoo) | |
write-host $localfoo | |
} -ArgumentList $foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Logger { | |
# Do pretty logging of information | |
} | |
function cleanupFile { | |
# Do some repetitive file manipulation | |
} | |
function PrepVM { | |
# Setup things inside a VM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Editing a virtual machine file | |
# This PowerShell code takes an unregistered VMCX file | |
# It change the VM Name, disables Dynamic Memory, and sets the memory to 2GB | |
# It then saves the changed virtual machine configuration to a new path | |
# Parameters that will be changed | |
$VMConfigurationToEdit = "D:\VMs\Virtual Machines\3F99446F-1D9A-4010-8C8B-4E554E845181.vmcx" | |
$pathToSaveNewConfigTo = "D:\" | |
$newVMName= "NewVMName" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$HyperVServer = "." | |
$VMName = "Test VM" | |
# Get the management service | |
$VMMS = gwmi -namespace root\virtualization\v2 Msvm_VirtualSystemManagementService -computername $HyperVServer | |
# Get the virtual machine object | |
$VM = gwmi MSVM_ComputerSystem -filter "ElementName='$VMName'" -namespace "root\virtualization\v2" -computername $HyperVServer | |
# SettingType = 3 ensures that we do not get snapshots |