# powershell script for VM mass management. Requires a .csv file containing the list of VMs and a name for the snapshot/ If no snapshot name is given, "Snapshot_1" is used.
#load powercli if needed
if (!(Get-Module -Name VMware.VimAutomation.Core) -and (Get-Module -ListAvailable -Name VMware.VimAutomation.Core)) {
Write-Output "loading the VMware Core Module..."
if (!(Import-Module -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue)) {
# Error out if loading fails
Write-Error "`nERROR: Cannot load the VMware Module. Is the PowerCLI installed?"
}
$Loaded = $True
}
# elseif (!(Get-Module -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) -and !(Get-Module -Name VMware.VimAutomation.Core) -and ($Loaded -ne $True)) {
# Write-Output "loading the VMware Core Snapin..."
# if (!(Add-PSSnapin -PassThru VMware.VimAutomation.Core -ErrorAction SilentlyContinue)) {
# # Error out if loading fails
# Write-Error "`nERROR: Cannot load the VMware Snapin or Module. Is the PowerCLI installed?"
# }
# }
# Define vmConfigSpec params
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo
$vmConfigSpec.Tools.ToolsUpgradePolicy = "UpgradeAtPowerCycle"
# Get the command-line params
$command = $args[0]
$list = $args[1]
$server = $args[2]
# define default params
if (!$list) { $list = "vm_mgmt.csv"}
if (!$server) { $server = "default.vCenter.domain.tld"}
# Start processing the command
switch ($command) {
default { $myname = $MyInvocation.MyCommand.Definition
echo "`nERROR! Usage:"
echo "$myname command [list] [server] "
echo "`ncommand is one of the following: viewsnap, takesnap, delsnap, revertsnap, hwupd, vmtoolsupd, vmoff, vmon."
echo " list is a .csv file containing 'VM_Name,Snapshot_name'. If no list provided, 'vm_mgmt.csv' will be used."
echo " server is the name of the server connecting to. If no server is provided, 'default.vCenter.domain.tld' will be used.`n"
}
"viewsnap" {
### View Snapshot
Connect-VIServer -Server $server -Protocol https
import-csv $list | ForEach-Object {
$_.VM_Name
$_.Snapshot_name
if (!$_.Snapshot_name) { $_.Snapshot_name = "Snaphot_1"}
echo "`nView Snaphots:`n"
get-vm -Name $_.VM_Name | get-snapshot
} }
"takesnap" {
### Take Snapshot
Connect-VIServer -Server $server -Protocol https
import-csv $list | ForEach-Object {
$_.VM_Name
$_.Snapshot_name
if (!$_.Snapshot_name) { $_.Snapshot_name = "Snaphot_1"}
echo "`nTaking Snapshots`n"
get-vm -Name $_.VM_Name | New-Snapshot -Name $_.Snapshot_1 -Quiesce -Memory
} }
"delsnap" {
### Delete Snapshot
Connect-VIServer -Server $server -Protocol https
import-csv $list | ForEach-Object {
$_.VM_Name
$_.Snapshot_name
if (!$_.Snapshot_name) { $_.Snapshot_name = "Snaphot_1"}
echo "`nDelete Snapshots`n"
get-snapshot -name $_.Snapshot_1 -vm $_.VM_Name | remove-snapshot -confirm:$false
} }
"revertsnap" {
### Revert To Snapshot
Connect-VIServer -Server $server -Protocol https
import-csv $list | ForEach-Object {
$_.VM_Name
$_.Snapshot_name
echo "`nReverting Snapshots. Confirmation is required for each restore.`n"
set-vm -VM $_.VM_Name -Snapshot $_.Snapshot_1 -whatif
# set-vm -VM $_.VM_Name -Snapshot $_.Snapshot_1 -confirm:$false
} }
"hwupd" {
# VM Hardware upgrade
Connect-VIServer -Server $server -Protocol https
import-csv $list | ForEach-Object {
$_.VM_Name
$_.Snapshot_name
if (!$_.Snapshot_name) { $_.Snapshot_name = "Snaphot_1"}
echo "`nVM Hardware upgrade to vmx-13`n"
$do = New-Object -TypeName VMware.Vim.VirtualMachineConfigSpec
$do.ScheduledHardwareUpgradeInfo = New-Object -TypeName VMware.Vim.ScheduledHardwareUpgradeInfo
$do.ScheduledHardwareUpgradeInfo.UpgradePolicy = “always”
$do.ScheduledHardwareUpgradeInfo.VersionKey = “vmx-13”
$vm.ExtensionData.ReconfigVM_Task($do)
} }
"vmtoolsupd" {
# VM Tools update
Connect-VIServer -Server $server -Protocol https
import-csv $list | ForEach-Object {
$_.VM_Name
$_.Snapshot_name
if (!$_.Snapshot_name) { $_.Snapshot_name = "Snaphot_1"}
echo "`nUpdating VM Tools`n"
get-vm -Name $_.VM_Name | %{$_.Extensiondata.ReconfigVM($vmConfigSpec)}
} }
"vmoff" {
# VM power off
Connect-VIServer -Server $server -Protocol https
import-csv $list | ForEach-Object {
$_.VM_Name
$_.Snapshot_name
if (!$_.Snapshot_name) { $_.Snapshot_name = "Snaphot_1"}
echo "`nTurning VMs OFF`n"
$vm = Get-VM -Name $_.VM_Name | Shutdown-VMGuest -Confirm:$false
} }
"vmon" {
# VM power on
Connect-VIServer -Server $server -Protocol https
import-csv $list | ForEach-Object {
$_.VM_Name
$_.Snapshot_name
if (!$_.Snapshot_name) { $_.Snapshot_name = "Snaphot_1"}
echo "`nTurning VMs ON`n"
$vm = Get-VM -Name $_.VM_Name | Start-VM -Confirm:$false
} }
}
-----------------------------------------------
type vm_mgmt.csv
VM_NAME,Snapshot_name
some-vm-name,Snapshot_342
another-vm-name,Snapshot_temp4
Search This Blog
Monday, April 01, 2019
Saturday, February 02, 2019
Chromium - Cast: "No Devices Found"
Starting chromium from the console you get "Component extension with id pkedcjkdefgpdelpbcmbmeomcjbeemfm not in whitelist and is not being loaded as a result."
- pkedcjkdefgpdelpbcmbmeomcjbeemfm is the Chrome Media Router, without it, you can go to chrome://flags and Enable the #load-media-router-component-extension as much as you want, no chromecast device will ever be detected.
- pkedcjkdefgpdelpbcmbmeomcjbeemfm is the Chrome Media Router, without it, you can go to chrome://flags and Enable the #load-media-router-component-extension as much as you want, no chromecast device will ever be detected.
My solution:
1: copy pkedcjkdefgpdelpbcmbmeomcjbeemfm folder from a google-chrome profile ( ~/.config/google-chrome/Default/Extensions/pkedcjkdefgpdelpbcmbmeomcjbeemfm) to the chromium profile ~/.config/chromium/Default/Extensions/pkedcjkdefgpdelpbcmbmeomcjbeemfm
( If you copy from a windows installation, make sure the files are chmod 600, the folders are 700 and you are the right owner)
2: in Chromium, go to chrome://extensions/, enable "Developer Mode", then "Load Unpacked" and point to ~/.config/chromium/Default/Extensions/pkedcjkdefgpdelpbcmbmeomcjbeemfm
3: Now Chrome Media Router is loaded and the chromecast devices will be detected:
Wednesday, January 16, 2019
drakboot "INTERNAL ERROR: unknown device"
1: obviously, run strace drakboot > /tmp/trace 2>&1
2: less /tmp/trace, look for the missing device (in my case it was sdd):
openat(AT_FDCWD, "/boot/grub2/install.sh", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 12
ioctl(12, TCGETS, 0xbfb7147c) = -1 ENOTTY (Inappropriate ioctl for device)
_llseek(12, 0, [0], SEEK_CUR) = 0
fstat64(12, {st_mode=S_IFREG|0755, st_size=22, ...}) = 0
read(12, "grub2-install /dev/sdd", 8192) = 22
read(12, "", 8192) = 0
3: edit /boot/grub2/install.sh and replace the wrong disk reference.
Tuesday, January 08, 2019
Push-button ON/OFF
In order to start the Peltier-based car freezer and to make sure that it turn off and stays OFF after the car stopped (a big Peltier is a huge battery drain!), I've made this 4-relay based circuit. No or "as little as possible" electronics in the car is the best approach - only the aerospace is harder for electronics than automotive - the best solution might involve some relays and, maybe, a couple of diodes, but stay away from amateurish electronics in the car! This is the diagram I draw on the back of a napkin (as usual) :)
Monday, October 15, 2018
Thursday, May 10, 2018
RDP Disconnected! Error Code: 2308 Error Description: Socket closed
After a windows update, a couple of Windows 2016 Servers on AWS started rejecting the RDP connections.
mRemote was giving the error "RDP Disconnected! Error Code: 2308 Error Description: Socket closed". MS RDP is giving "This computer can't connect to the remote computer. Try connecting again. If the problem continues, contact the owner of the remote computer or your network administrator."
After a bit of tinkering, I found that the problem seems to be the RDP TLS and encryption level.
To solve it:
- remote connect Registry Editor to the affected server and change the DWORD
HKLM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\SecurityLayer from "2" to "0"
- remote connect Services.msc to the affected server and restart TermService
mRemote was giving the error "RDP Disconnected! Error Code: 2308 Error Description: Socket closed". MS RDP is giving "This computer can't connect to the remote computer. Try connecting again. If the problem continues, contact the owner of the remote computer or your network administrator."
After a bit of tinkering, I found that the problem seems to be the RDP TLS and encryption level.
To solve it:
- remote connect Registry Editor to the affected server and change the DWORD
HKLM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\SecurityLayer from "2" to "0"
- remote connect Services.msc to the affected server and restart TermService
Saturday, December 02, 2017
Windows could not complete the installation. To install windows on this computer restart the installation
SHIFT-F10 to bring up command prompt.
cd c:\windows\system32\oobe
msoobe.exe
Make a generic account and password.
Hit finish (if it requests a product key and you have one, enter it now. if OEM/No key required, just finish).
Set time/date.
Finish.
cd c:\windows\system32\oobe
msoobe.exe
Make a generic account and password.
Hit finish (if it requests a product key and you have one, enter it now. if OEM/No key required, just finish).
Set time/date.
Finish.
Subscribe to:
Comments (Atom)
