Friday, June 30, 2017

Run elevated programs from normal command prompt

I had an issue recently where a computer joined the domain while sysprep was still active and a group policy with password complexity broke the admin account that sysprep was using. To fix this we had to run a command prompt with admin permissions to run some commands, but we weren't able to start an elevated prompt.

The fix is to run the following command

runas /netonly /user:computername\adminaccount cmd

This will open an elevated command prompt. You can substitute cmd with anything else to run it as an admin.

Monday, June 12, 2017

FAILED: Unable to create a VSS snapshot of the source volume(s). Error code: 2147754758 (0x80042306). - VMware

I was getting this error trying to convert a couple of physical machines to virtual machines.

FAILED: Unable to create a VSS snapshot of the source volume(s). Error code: 2147754758 (0x80042306).

None of the other blogs or posts were able to help me fix it.

Resolution: The VSS settings on the HDDs were somehow set for 32mb. VSS requires a minimum of 300mb.

This is your PowerShell ISE on ISESteroids

This is your PowerShell ISE on ISESteroids 

PowerShell. I have learned to love it over the past few months. At work, I have ran into issues that Macro Express or AutoHotKey wouldn't cut it as a viable option. I had looked into PS before, but with just the shell, its not that accessible. Resigning myself to work in the shell, I started to do some research. I found out that MS released a tool for PowerShell that was like an IDE. Hallelujah! As I was playing in it, I came to the realization that I needed "MOAR POWER". PowerShell ISE is amazing, but it still needed a bit more.... umph. Dr. Tobias Weltner is a brilliant man because he thought the same thing! :D However, he is much more brilliant than I because he did something about it.

He gave PowerShell ISE a shot of steroids. ISE Steroids that is. You can download a trial at his website:  http://www.powertheshell.com/isesteroids2/download/

This tool is like dropping a turbocharger into your car, but 10 times easier. You install it and you are up and running in no time flat.

I am going to skip over the installation (you can find instructions on the link above) and talk about some of my favorite features.

Refactoring

First off I love refactoring. It lets me build out test scripts quickly without worrying about a naming scheme, or what I am calling my variables. Might not be the best SOP but it works for me. PowerShell ISE does have a replace feature (Ctrl + H) but to me its a bit clunky, and not as useful. ISE Steroids gives you in-line on-the-fly refactoring with one button

  1. Place the cursor in the text you want to change. (I am refactoring the $install variable on line 2)
  2. Press F2
  3. Start typing to refactor!

Original
After refactor














Did you notice that it only changed in the function that you are working in? That is great if you don't want to go changing every instance of that text in your whole script. But what if you want to?

Original
After refactor

  1. Highlight the whole selection you want to change ($client including the $)
  2. Press F2
  3. Start typing to refactor! It will refactor all instances (look at the second function, all the $client instances were renamed too)

Start typing to refactor! It will refactor all instances