# Tips and tricks of the trade

**URL:** https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444
**Category:** george
**Created:** [March 20, 2018, 1:13pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444 "2018-03-20T13:13:00Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Ook](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/ook/32/72_2.png) [@Ook](https://cog.discourse.group/u/Ook)
#### Post date: [March 20, 2018, 1:13pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/1 "2018-03-20T13:13:00Z")

</div>

Recently we had an issue where one of our remote sites had frequent power failures.

Upon closer investigation it was found that the 3kVa UPS was overloaded (with 3.4kVa) instead of a healthy 2.2kVa.

This caused the servers to yoyo down and up, which’s Not A Good Thing.

On this site we had a cluster setup (two blades, server2016 and a 2k16 NAS). One of the iSCSI virtual drives got corrupted (vhdx virtual disk)

The easiest (and quickest) way out of this mess was to start up diskpart, attach the corrupted VHDX image and run CHKDSK on it, and we were home free.

Steps :

1. Create a backup of the affected VHDX file.
2. Open an elevated command prompt.
3. Type in diskpart and press enter.
4. Before mounting or unmounting virtual disk, you need to specify the location of your vhd/vhdx file. Type the following command and hit Enter.  
select vdisk file=“[location of vhd]”
5. Once that is done, type in attach vdisk  
The disk should show up in Drive Manager or Windows Explorer. You can then run a regular chkdsk /f on it.  
 ![mount-vhd-from-command-line](https://us1.discourse-cdn.com/flex001/uploads/cog/original/2X/4/4312daaa61fa5ef8546b613f24dee2900a91d03c.png)

To unmount it, either right-click on it and eject it, or type in detach vdisk and press Enter.

You can also use PowerShell to do the same job, but you’ll need Hyper-V installed for this to work (which I could not do as it was on the NAS and the NAS does not need Hyper-V installed) :

1. Open PowerShell as Administrator.
2. When the command-line window opens, you can run the Mount-VHD cmdlet to mount your vhd/vhdx file.  
Mount-VHD –Path “[location of vhd]”  
To unmount your virtual hard disk, just run the Dismount-VHD cmdlet instead.  
Dismount-VHD –Path “[location of vhd]”

If you get the error message like “Mount-VHD is not recognized as the name of a cmdlet“, you need to add a feature named “Hyper-V Module for Windows PowerShell” to your server.

Gratuitiously copied from [2 Ways to Mount and Unmount VHD / VHDX from Command Line | Password Recovery](https://www.top-password.com/blog/mount-and-unmount-vhd-vhdx-from-command-line/) without permission.

---

<div class="post-metadata">

### Author: ![Ook](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/ook/32/72_2.png) [@Ook](https://cog.discourse.group/u/Ook)
#### Post date: [April 1, 2018, 6:21pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/2 "2018-04-01T18:21:58Z")

</div>

Some user managed to flip the screen upside down?  
Ctrl+arrow down should return it to normal configuration.  
Then disable the hotkeys in the video control panel (intel/nvidia etc)

---

<div class="post-metadata">

### Author: ![Ook](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/ook/32/72_2.png) [@Ook](https://cog.discourse.group/u/Ook)
#### Post date: [April 1, 2018, 6:25pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/3 "2018-04-01T18:25:46Z")

</div>

Gummed-up laptop CPU fan not working properly? A few generous spritzes with a can of carburetor cleaner (take care to spray and drain the fluids away from the motherboard) then apply some electrical cleaner (for lubrication).

A word to the wise - do not, never ever, use WD40 or any oil-based lube on a fan as it will attract dust and cause a bigger problem than before.

---

<div class="post-metadata">

### Author: ![Nabiki](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/nabiki/32/935_2.png) [@Nabiki](https://cog.discourse.group/u/Nabiki)
#### Post date: [April 1, 2018, 10:10pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/4 "2018-04-01T22:10:47Z")

</div>

I’ve seen that one before. I tell my classes about that one because it happens pretty often since a lot of laptops have the arrow keys right next to the delete, so they type Ctrl+Alt+Arrow instead of Ctrl+Alt+Delete.

Another thing I teach my classes is RATS (Read ALL The Screen). That tells you what’s going on most of the time.

---

<div class="post-metadata">

### Author: ![balance](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/balance/32/1888_2.png) [@balance](https://cog.discourse.group/u/balance)
#### Post date: [April 2, 2018, 1:39pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/5 "2018-04-02T13:39:00Z")

</div>

I used to hit these combos a lot… Muscle memory from MacOS where they do different functions.

---

<div class="post-metadata">

### Author: ![Ook](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/ook/32/72_2.png) [@Ook](https://cog.discourse.group/u/Ook)
#### Post date: [April 25, 2018, 10:51am UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/6 "2018-04-25T10:51:46Z")

</div>

Too many colours on the screen causing colourblind people to faff around?

Then use Crtl+win key+C (for Win10 only)

It removes colours from the screen. Supposedly to help/assist colourblind people.

Also good at trolling people with Win10.

---

<div class="post-metadata">

### Author: ![Darktan](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/darktan/32/36_2.png) [@Darktan](https://cog.discourse.group/u/Darktan)
#### Post date: [April 26, 2018, 7:18pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/7 "2018-04-26T19:18:48Z")

</div>

> [@Ook](#):
>
> Too many colours on the screen causing colourblind people to faff around?
> 
> Then use Crtl+win key+C (for Win10 only)
> 
> It removes colours from the screen. Supposedly to help/assist colourblind people.

As a color blind person… neat. Thanks for thinking of us MS.  
As an ‘older’ color blind person… meh. I’ve developed other coping mechanisms that are second nature to me so I don’t really need it.

---

<div class="post-metadata">

### Author: ![Ook](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/ook/32/72_2.png) [@Ook](https://cog.discourse.group/u/Ook)
#### Post date: [May 28, 2018, 2:44pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/8 "2018-05-28T14:44:06Z")

</div>

Excellent Powershell scripts for backing up your VM’s.

Obtained from this article : [Two tricks to automate the export of live VMs in Windows Server | InfoWorld](https://www.infoworld.com/article/2610395/windows-server/two-tricks-to-automate-the-export-of-live-vms-in-windows-server.html)

> [@](#):
>
> #requires -version 3.0  
> #requires -module Hyper-V
> 
> \<#  
> .SYNOPSIS  
> Export virtual machines  
> .DESCRIPTION  
> This utility will export virtual machines to a target destination. By default  
> it will create a folder using the format:
> 
> Weekly\_Year\_Month\_Day\_HourSecond
> 
> The script will delete the oldest folder once 4 subfolders have been created.  
> Use the -Monthly parameter to do the same thing but for folders that begin  
> with Monthly, i.e. Monthly\_Year\_Month\_Day\_HourSecond.
> 
> Because the export process can be time consuming, you can use the -AsJob parameter  
> which will be passed to Export-VM. You will then get PowerShell background jobs  
> which you can manage with the standard job cmdlets.
> 
> This script must be run as an administrator in an elevated session.
> 
> .PARAMETER VM  
> A comma separated list of virtual machines. You can also pipe Get-VM into  
> this command. This parameter has an alias of Name.  
> .PARAMETER Path  
> The path to the top level backup or export folder.  
> .PARAMETER Monthly  
> Run the script in Monthly mode  
> .PARAMETER AsJob  
> Export virtual machines using background jobs  
> .EXAMPLE  
> PS C:\> get-vm chi-dc01,chi-dc02 | c:\scripts\ScheduledExport.ps1 -path e:\export
> 
> Get the virtual machines, CHI-DC01 and CHI-DC02 and pipe them to the script which will  
> export them to the given folder.
> 
> .EXAMPLE  
> PS C:\> c:\scripts\ScheduledExport.ps1 “CHI-DC01”,“CHI-FP01” -path E:\Export -asjob
> 
> Export virtual machines CHI-DC01 and CHI-FP01 to a weekly folder under E:\Export.
> 
> .EXAMPLE  
> PS C:\> get-content c:\work\vms.txt | c:\scripts\ScheduledExport.ps1 -asjob -monthly
> 
> Read the text file, vms.txt, and pass each virtual machine name to the script. This will  
> use the Monthly backup folders. Exports will be done as jobs.
> 
> .LINK  
> Get-VM  
> Export-VM
> 
> .NOTES  
> Last Updated: 3/11/2014  
> Version : 1.1
> 
> Learn more from Jeff Hicks:  
> PowerShell in Depth: An Administrator’s Guide  
> PowerShell Deep Dives  
> Learn PowerShell 3 in a Month of Lunches  
> Learn PowerShell Toolmaking in a Month of Lunches
> 
> * * *
> 
> - DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED \*
> - THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK. IF \*
> - YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, \*
> - DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING. \*
> 
> * * *
> 
> #\>
> 
> [cmdletbinding(SupportsShouldProcess=$True)]
> 
> Param(  
> [Parameter(Position=0,Mandatory=$True,  
> HelpMessage=“Enter the virtual machine name or names”,  
> ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]  
> [ValidateNotNullorEmpty()]  
> [Alias(“name”)]  
> [string]$VM,
> 
> [Parameter(Position=1)]  
> [ValidateNotNullorEmpty()]  
> [string]$Path = “C:\work\export”,
> 
> [Parameter(Position=2)]  
> [switch]$Monthly,
> 
> [Parameter(Position=3)]  
> [switch]$AsJob  
> )
> 
> Begin {
> 
> #define some variables if we are doing weekly or monthly backups  
> if ($monthly) {  
> $type = “Monthly”  
> $retain = 2  
> }  
> else {  
> $type = “Weekly”  
> $retain = 4  
> }
> 
> Write-Verbose “Processing $type backups. Retaining last $retain.”
> 
> #get backup directory list  
> Try {  
> Write-Verbose “Checking $path for subfolders”
> 
> #get only directories under the path that start with Weekly or Monthly  
> $subFolders = dir -Path $path$type\* -Directory -ErrorAction Stop  
> }  
> Catch {  
> Write-Warning “Failed to enumerate folders from $path”  
> #bail out of the script  
> return  
> }
> 
> #check if any backup folders  
> if ($subFolders) {  
> #if found, get count  
> Write-Verbose “Found $($subfolders.count) folder(s)”
> 
> ```
> #if more than the value of $retain, delete oldest one
> if ($subFolders.count -ge $retain ) {
> #get oldest folder based on its CreationTime property
> $oldest = $subFolders | sort CreationTime | Select -first 1 
> Write-Verbose "Deleting oldest folder $($oldest.fullname)"
> #delete it
> $oldest | Remove-Item -Recurse -Force
> }
> 
> ```
> 
> } #if $subfolders  
> else {  
> #if none found, create first one  
> Write-Verbose “No matching folders found. Creating the first folder”  
> }
> 
> #create the folder  
> #get the current date  
> $now = Get-Date
> 
> #name format is Type\_Year\_Month\_Day\_HourMinute  
> $childPath = “{0}_{1}_{2:D2}_{3:D2}_{4:D2}{5:D2}” -f $type,$now.year,$now.month,$now.day,$now.hour,$now.minute
> 
> #create a variable that represents the new folder path  
> $new = Join-Path -Path $path -ChildPath $childPath
> 
> Try {  
> Write-Verbose “Creating $new”  
> #Create the new backup folder  
> $BackupFolder = New-Item -Path $new -ItemType directory -ErrorAction Stop  
> }  
> Catch {  
> Write-Warning “Failed to create folder $new. $($\_.exception.message)”  
> #failed to create folder so bail out of the script  
> Return  
> }  
> } #end begin
> 
> Process {
> 
> #only process if a backup folder was created  
> if ($BackupFolder) {  
> #export VMs  
> #define a hashtable of parameters to splat to Export-VM  
> $exportParam = @{  
> Path = $new  
> Name=$Null  
> ErrorAction=“Stop”  
> }  
> if ($asjob) {  
> Write-Verbose “Exporting as background job”  
> $exportParam.Add(“AsJob”,$True)  
> }
> 
> ```
> Write-Verbose "Exporting virtual machines"
> <#
> Go through each virtual machine name, and export it using Export-VM
> #>
> foreach ($name in $VM) {
> $exportParam.Name=$name
> #if the user did not include -WhatIf then the machine will be exported
> #otherwise they will get a WhatIf message
> if ($PSCmdlet.shouldProcess($name)) {
> Try {
> Export-VM @exportParam
> }
> Catch {
> Write-Warning "Failed to export virtual machine(s). $($_.Exception.Message)"
> }
> } #whatif
> } #close foreach
> 
> ```
> 
> } #if backup folder exists  
> } #Process  
> End {  
> Write-Host “Export script finished.” -ForegroundColor Green
> 
> }  
> \<#  
> Sample Code to create PowerShell scheduled job
> 
> $trigger = New-JobTrigger -Weekly -DaysOfWeek Friday -At 12:00  
> $options = New-ScheduledJobOption -RunElevated  
> $VMs = “test vm\*”,“demo rig”
> 
> #specify script parameter values in order  
> Register-ScheduledJob -Name “Weekly VM Export” -FilePath c:\scripts\jpb.ps1 -Trigger $trigger -ScheduledJobOption $options -ArgumentList $VMs,“c:\work\export”,$False,$False
> 
> $trigger = New-JobTrigger -Weekly -DaysOfWeek Friday -WeeksInterval 4 -At 12:00AM  
> #reuse options and vms  
> Register-ScheduledJob -Name “Monthly VM Export” -FilePath c:\scripts\BackupVMScripts.ps1 -Trigger $trigger -ScheduledJobOption $options -ArgumentList $VMs,“c:\work\export”,$True,$False
> 
> #\>

---

<div class="post-metadata">

### Author: ![balance](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/balance/32/1888_2.png) [@balance](https://cog.discourse.group/u/balance)
#### Post date: [May 29, 2018, 1:28pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/9 "2018-05-29T13:28:56Z")

</div>

I prefer having my VMs as replicating entities scattered across routers within my org.

I might be building skynet.

---

<div class="post-metadata">

### Author: ![Darktan](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/darktan/32/36_2.png) [@Darktan](https://cog.discourse.group/u/Darktan)
#### Post date: [June 1, 2018, 5:35pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/10 "2018-06-01T17:35:41Z")

</div>

Not bad. I thought for sure I’d see the use of snapshots (If I walk into your environment and find you using snapshots as a backup method I will kick you in the leg!). I’m currently tweaking a PS script that shuts down an environment. Moves specific VM’s to a specific host, shutdown everything but vCenter, configure hosts for shutdown (disables DRS) and puts them into maintenance mode to power them off. We have a vSAN in some of our environments so it’s a little trickier than a straight shutdown. It’s supposed to be a script to run when the UPS detects a power outage so this version is a straight shutdown. But I have another version that reads an INI file for inputs that has a nice menu and gives you the option to both shutdown and power up an entire environment. The hosts do have to be powered on though.

---

<div class="post-metadata">

### Author: ![Ook](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/ook/32/72_2.png) [@Ook](https://cog.discourse.group/u/Ook)
#### Post date: [June 1, 2018, 6:20pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/11 "2018-06-01T18:20:27Z")

</div>

I don’t believe in snapshots, but rather taking said VM offline, run an export-vm job, bring it back online and do whatever borkage you want to do.

Same for backups. Current script pauses the VM, backs it up, and resumes the VM.

That’s what I absolutely like about VM’s - the ease with which they can be backed up and restored…

---

<div class="post-metadata">

### Author: ![Rizak](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/rizak/32/4190_2.png) [@Rizak](https://cog.discourse.group/u/Rizak)
#### Post date: [June 1, 2018, 10:22pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/12 "2018-06-01T22:22:15Z")

</div>

We finally got twin 10Gb connections between everything in our server enclave. The speed is amazing.

---

<div class="post-metadata">

### Author: ![CaffeinatedNoms](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/caffeinatednoms/32/3779_2.png) [@CaffeinatedNoms](https://cog.discourse.group/u/CaffeinatedNoms)
#### Post date: [June 10, 2018, 12:09pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/13 "2018-06-10T12:09:17Z")

</div>

> [@Ook](#):
>
> Too many colours on the screen causing colourblind people to faff around?
> 
> Then use Crtl+win key+C (for Win10 only)
> 
> It removes colours from the screen. Supposedly to help/assist colourblind people.
> 
> Also good at trolling people with Win10.

I’m red-blind (I was young, there were lasers, the obvious happened) and while mono wouldn’t be much good for me (messes with luma as it rebalances the greys) I always found Apple’s cmd+opt+ctrl+8 to _flip_ colours rather useful. Not sure whether that hazy mess is pink or orange? Flip it. Now it’s either cyan or teal.

---

<div class="post-metadata">

### Author: ![Viking](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/viking/32/32_2.png) [@Viking](https://cog.discourse.group/u/Viking)
#### Post date: [June 10, 2018, 10:42pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/14 "2018-06-10T22:42:54Z")

</div>

> [@CaffeinatedNoms](#):
>
> I always found Apple’s cmd+opt+ctrl+8 to _flip_ colours rather useful.

Thanks for reminding me of that key sequence. It’s rather trippy to flip between ‘normal’ and ‘inverse’ colours. I suspect it would be good for night-work in a dark room where the default colour scheme is too bright. (Although the ‘Night Shift’ setting helps a lot with that - all the colours gain a warm red/orange tint. Probably not much help if you’re red-blind, sadly)

---

<div class="post-metadata">

### Author: ![Ook](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/ook/32/72_2.png) [@Ook](https://cog.discourse.group/u/Ook)
#### Post date: [July 18, 2018, 3:03pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/15 "2018-07-18T15:03:11Z")

</div>

Testing out a SMTP app/function?

smtp4dev is your friend. It basically emulates an SMTP server, and you can SMTP to it and inspect your headers, body and everything to see that the pesky program/function doing SMTP is doing it right.

Yay for not havening to set up a VM with an SMTP server and slogging through a ton of logs to find out just what went wrong.

---

<div class="post-metadata">

### Author: ![moufassa](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/moufassa/32/41_2.png) [@moufassa](https://cog.discourse.group/u/moufassa)
#### Post date: [July 19, 2018, 2:36am UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/16 "2018-07-19T02:36:03Z")

</div>

> [@Ook](#):
>
> Testing out a SMTP app/function?

Yes, but as a result of going Office 365.

We’ve managed to get $parent\_company to set us up a connector, so that I can build a dedicated SMTP server, assign it an external IP and have O365 whitelist it. I got this working literally last Friday.

smtp4dev would have been very useful in troubleshooting what was required for a few of our apps…

---

<div class="post-metadata">

### Author: ![Ook](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/ook/32/72_2.png) [@Ook](https://cog.discourse.group/u/Ook)
#### Post date: [July 19, 2018, 2:34pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/17 "2018-07-19T14:34:08Z")

</div>

It always is so - once you’ve gone through some backbreaking (not to mention ballbreaking) work, something turns up which would’ve made your work sooooo much easier… 🙄

Our devs love this app since I introduced them to it - makes their lives so much easier.

---

<div class="post-metadata">

### Author: ![Ook](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/ook/32/72_2.png) [@Ook](https://cog.discourse.group/u/Ook)
#### Post date: [November 4, 2018, 5:31pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/18 "2018-11-04T17:31:38Z")

</div>

Want to harass spambots?

Of course you do.

[http://www.turnstep.com/Spambot/index.html](http://www.turnstep.com/Spambot/index.html)

---

<div class="post-metadata">

### Author: ![Ook](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/ook/32/72_2.png) [@Ook](https://cog.discourse.group/u/Ook)
#### Post date: [November 9, 2018, 5:33pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/19 "2018-11-09T17:33:05Z")

</div>

Veeam ONE for free monitoring of HyperV and ESXi servers (both free and licenced).

The free edition can give you an overview of CPU and RAM usage per host and per VM. Great to check if you’re not overcommitting memory and that there’s no bottlenecks.

Veeam Backup and Replication for backing up and restore of your HyperV and (licenced only) ESXi hosts.

With the free version you can backup selected VM’s to any suitable location, but only manually, whereas the licenced version can do it scheduled. A nice thing is that the backups are compressed and deduped, so as to take as little space as possible.

ESXi support is also included, but only for licenced hosts, the free version is NOT supported.

---

<div class="post-metadata">

### Author: ![Ook](https://sea1.discourse-cdn.com/flex001/user_avatar/cog.discourse.group/ook/32/72_2.png) [@Ook](https://cog.discourse.group/u/Ook)
#### Post date: [November 9, 2018, 5:50pm UTC](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444/20 "2018-11-09T17:50:39Z")

</div>

Netwrix Auditor to keep track of file accesses etc. The licenced version keeps a database so you can do all sorts of nifty reporting, whereas the free version only reports on activity.

[Next page](https://cog.discourse.group/t/tips-and-tricks-of-the-trade/1444.md?page=2)
