Saturday, February 27, 2016

VirtualBox VT-X/AMD-V Hardware Acceleration Error

I was getting this error about VT-X/AMD-V Hardware Acceleration not being available on my system and was very confused because I had enabled it in the BIOS and still got the error. Today I decided to do a little research on it. I had remembered in the past reading about Hyper-V causing issues with other virtualization software. So I did some checking on my system, because I know that Hyper-V is enabled/installed when you install the Android Emulator with Visual Studio. I checked if the Hyper-V feature was enabled, and sure enough, it was. I disabled Hyper-V and rebooted my system. Fired up VirualBox and loaded up the VM. Success.

To disable Hyper-V

  • Go to Control Panel –> Programs and Features
  • Click Turn Windows features on or off
  • Uncheck Hyper-V
  • Click OK
  • Restart

Friday, November 20, 2015

How to Run Hubot on Azure Websites

I wanted to get Hubot working in our slack channels at work and I thought I would share the process I took to get it working and running on Azure Websites.

 

First, make sure you have nodejs installed

> choco install nodejs.install -y

Make sure npm is up to date

> npm install -g npm

At this point, I also installed coffee-script because the first time I tried running it, I got errors about coffee script

> npm install -g coffee-script

Install the azure-cli node modules to generate the deploy file that will be used

> npm install –g azure-cli

Next we install the yo hubot generator

> npm install –g yo generator-hubot

create a directory for your hubot. I have found that you should not initially name it “hubot”, as npm will fail with some of the package installs (specifically, the hubot package). Then lets start the hubot configuration

> mkdir myhubot

> cd myhubot

> yo hubot

Now you will answer the question it asks to configure hubot. Again, I wouldn’t name it “hubot” when it asks. I will show you where to change it later so it will respond to hubot.

yohubot

Mine showed some error messages while running this, but still functioned correctly.

Now lets install the slack adapter

> npm install hubot-slack --save

next we need to create the azure deploy command.

> azure site deploymentscript –node

lets now make a couple tweaks to the hubot files:

first, open up external-scripts.json and remove

"hubot-heroku-keepalive",

"hubot-redis-brain"

if you want to use azure blob for the brain we can set that up now. while still in the external-scripts.json, add the line:

"hubot-azure-scripts/brain/storage-blob-brain"

Save the file and go back to the command prompt:

> npm install hubot-azure-scripts --save

You can go to https://github.com/hubot-scripts and find some other script that you may want to add

first install from npm:

> npm install [scriptname] --save

Then add it to the external-scripts.json

 

next we have to modify the deploy.cmd slightly. There is an issue with azure where it doesn’t like that hubot doesn’t have a file extension. So we copy the hubot file and add the coffee extension.

After :: 3. Install npm packages block add the following:

:: 4. Create Hubot file with a coffee extension
copy /Y "%DEPLOYMENT_TARGET%\node_modules\hubot\bin\hubot" "%DEPLOYMENT_TARGET%\node_modules\hubot\bin\hubot.coffee"

Since we created the hubot.coffee, we need to configure the server to use that:

> echo require('coffee-script/register'); > server.js & echo module.exports = require('hubot/bin/hubot.coffee'); >> server.js

you can either copy this and run in command prompt, or create a file called server.js and add the following:

require("coffee-script/register’);

module.exports = require("hubot/bin/hubot.coffee");

Here is when we can change the name of the hubot back to acutally be hubot.

Open ./myhubot/bin/hubot.cmd in notepad and change “myhubot” to “hubot”.

You may also want to edit the readme.md and replace “myhubot” with “hubot” as well.

 

At this point you should make your github repo for your hubot and then commit your changes to github. (Use your github and your own repo)

> git init

> git add .

> git commit -m "initial hubot commit"

> git remote add origin https://github.com/[your-user-name]/[your-hubot-origin]

> git push -u origin master

 

Azure setup

Login to your Azure portal and create a new Web App: (The name has to be unique)

webapp1

 

If you are using Azure blob for the brain, create the storage account as well.

blob1

 

After the storage is created, we will need the Storage Account Name, and Primary Access Key. Copy these for use a little later:

keys

Go in to the settings for your newly created web app and click on “Continuous Deployment”. We are going to configure Azure Web Site to pull directly from the Github repo for the hubot configuration.

Choose Github as the provider and then authorize Azure to connect. Then choose your Hubot

cd

 

Finally we have to set up the environment variables that Hubot needs to function:

properties

You will create the following keys:

HUBOT_SLACK_TOKEN:  Your Slack Token for Hubot when you enable the integration

HUBOT_SLACK_TEAM:  myslack (from https://myslack.slack.com)

HUBOT_SLACK_BOTNAME: The name of your hubot

HUBOT_ADAPTER: slack

HUBOT_BRAIN_AZURE_STORAGE_ACCOUNT: The storage account name we saved from above

HUBOT_BRAIN_AZURE_STORAGE_ACCESS_KEY: The storage access token we saved from above

 

Go to your webapp to test that your hubot is working.

http://myhubot1.azurewebsites.net/hubot/help

help

Sometimes it doesn’t respond the first time, but if it continues to fail when requesting, there there may be an issue. Try running locally (you will have to remove the azure-blob when running local) and see if everything is working.

That’s about it. Enjoy!

Friday, November 6, 2015

Persistent Command History in PowerShell

If you are familiar with .bash_history or just wish you had a history of your powershell commands persist between sessions here is a handy little script. It will persist command history when you exit a powershell session to a file in %USERPROFILE% called .ps_history.

Copy the code below and save to a file called “Microsoft.PowerShell_profile.ps1” and save it in “%USERPROFILE%\Documents\WindowsPowerShell”

$HistoryFilePath = Join-Path -Path ([Environment]::GetFolderPath('UserProfile')) -ChildPath ".ps_history"; 
function Persist-History {
Register-EngineEvent -SourceIdentifier PowerShell.Exiting -Action {
Get-History | Select-Object -Unique | Export-Clixml -Path $HistoryFilePath;
} | Out-Null;
if (Test-path -Path $HistoryFilePath) {
Import-Clixml -Path $HistoryFilePath | Add-History;
}
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward;
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward;
}
Persist-History;
 

Disclaimer: I have only tested this with PowerShell 5


If it doesn’t work, you could probably make it work by installing the PackageManagement modules for PowerShell and install the “PSReadline” module.

Saturday, October 31, 2015

Microsoft Channel9 Addon for Kodi

To add to the my list of hobby projects, I created a fork of an addon for Kodi that provides browsing of videos on Microsoft Channel9. This was my first attempt at a Kodi addon, and really my first time working with writing python. I started out by just reading over the original code and tweaking it a bit because some things were not working. Then I started following the pattern that existed and implementing new features, like being able to browse Channel9 authors, and Channel9 events.

Once I got these features in place, I started doing some real refactoring of the original code base. There was a ton of code that was duplicated in multiple places. I spent a few hours of the day really rewriting the entire addon. As the project stands right now, it is basically a complete rewrite of the original addon.

The project is on Github and building on AppVeyor.

Download the latest Release

Sunday, October 4, 2015

Simplify standing up an IE Virtual Machine with PSIEVM

Over the weekend I was bored and decided to start a project to automate the process of standing up an IE VM with powershell. I would like to introduce PSIEVM. A powershell module that allows you to stand up an IE VM in VirtualBox (other hosts coming in the future) in one line.

PS> Get-IEVM –OS Win7 –IEVersion 9

That is the simplest form of the command.

Installation

To install, download from the github project releases page and extract to $env:USERPROFILE\WindowsPowerShell\Modules. Then to use it just import it

PS> Import-Module psievm
PS> Get-IEVM –OS Win7 –IEVersion 10 –AlternateVMLocation "G:\VMs\" –VMRootPath "G:\VMs\"

 

The parameters for Get-IEVM:

Name

Required

Type

Default

OS

YES

String

[Empty]

The OS to use:

  • WinXP, WindowsXP, Windows XP, XP
  • WinVista, WindowsVista, Windows Vista, Vista
  • Win7, Windows7, Windows 7, 7
  • Win8, Windows8, Windows 8, 8
  • Win8.1, Windows8.1, Windows 8.1, 8.1
  • Win10, Windows10, Windows 10, 10

IEVersion

YES

String

[Empty]

The version of IE. This is dependant on the version of Windows (See the table below).

  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • Edge

Shares

NO

String[]

[Empty]

These are the paths to add as a share in the VM through the VMHost. May not be fully supported in all VMHosts.

AlternateVMLocation

NO

String

[Empty]

By default the VM images will be downloaded from Microsoft, but if you have the images downloaded already, you can use this to tell the script where to get them. This can be a URL, Network Share, or a local path. The images need to follow the following pattern:

IE: IE<IEVersion>.Win<OSVersion>.For.Windows.<VMHost>.zip
Edge: Microsoft%20Edge.Win10.For.Windows.<VMHost>.zip

VMHost

NO

String

VirtualBox

The VM Host to use. Only VirtualBox is currently supported but here is the full list that will be supported (and maybe others).

  • VirtualBox
  • HyperV
  • Vagrent
  • VPC
  • VMWare

IgnoreInvalidMD5

NO

Boolean

$False

After the zip image is downloaded, the file MD5 hash is validated. If you use your own images, you will want to set this to $True.

VMRootPath

NO

String

$PWD

This is the path to download the zip image to and create the VM image folder where the VM will reside. By default it will use the Current Working Directory.

OS / IEVersion

This is the version of the OS that you want hosted and the version of IE you want with it. Here are the supported values:

 

IE 6

IE 7

IE 8

IE 9

IE 10

IE 11

MS Edge

Requires 64-bit Emulation

XP

X

 

X

 

 

 

 

 

Vista

 

X

 

 

 

 

 

 

Win7

 

 

X

X

X

X

 

 

Win8

 

 

 

 

X

 

 

 

Win8.1

 

 

 

 

 

X

 

X

Win10

 

 

 

 

 

 

X

X

Download PSIEVM

VirtualBox VT-X/AMD-V Hardware Acceleration Error

I was getting this error about VT-X/AMD-V Hardware Acceleration not being available on my system and was very confused because I had enabled it in the BIOS and still got the error. Today I decided to do a little research on it. I had remembered in the past reading about Hyper-V causing issues with other virtualization software. So I did some checking on my system, because I know that Hyper-V is enabled/installed when you install the Android Emulator with Visual Studio. I checked if the Hyper-V feature was enabled, and sure enough, it was. I disabled Hyper-V and rebooted my system. Fired up VirualBox and loaded up the VM. Success.

To disable Hyper-V

  • Go to Control Panel –> Programs and Features
  • Click Turn Windows features on or off
  • Uncheck Hyper-V
  • Click OK
  • Restart

How to Run Hubot on Azure Websites

I wanted to get Hubot working in our slack channels at work and I thought I would share the process I took to get it working and running on Azure Websites.

 

First, make sure you have nodejs installed

> choco install nodejs.install -y

Make sure npm is up to date

> npm install -g npm

At this point, I also installed coffee-script because the first time I tried running it, I got errors about coffee script

> npm install -g coffee-script

Install the azure-cli node modules to generate the deploy file that will be used

> npm install –g azure-cli

Next we install the yo hubot generator

> npm install –g yo generator-hubot

create a directory for your hubot. I have found that you should not initially name it “hubot”, as npm will fail with some of the package installs (specifically, the hubot package). Then lets start the hubot configuration

> mkdir myhubot

> cd myhubot

> yo hubot

Now you will answer the question it asks to configure hubot. Again, I wouldn’t name it “hubot” when it asks. I will show you where to change it later so it will respond to hubot.

yohubot

Mine showed some error messages while running this, but still functioned correctly.

Now lets install the slack adapter

> npm install hubot-slack --save

next we need to create the azure deploy command.

> azure site deploymentscript –node

lets now make a couple tweaks to the hubot files:

first, open up external-scripts.json and remove

"hubot-heroku-keepalive",

"hubot-redis-brain"

if you want to use azure blob for the brain we can set that up now. while still in the external-scripts.json, add the line:

"hubot-azure-scripts/brain/storage-blob-brain"

Save the file and go back to the command prompt:

> npm install hubot-azure-scripts --save

You can go to https://github.com/hubot-scripts and find some other script that you may want to add

first install from npm:

> npm install [scriptname] --save

Then add it to the external-scripts.json

 

next we have to modify the deploy.cmd slightly. There is an issue with azure where it doesn’t like that hubot doesn’t have a file extension. So we copy the hubot file and add the coffee extension.

After :: 3. Install npm packages block add the following:

:: 4. Create Hubot file with a coffee extension
copy /Y "%DEPLOYMENT_TARGET%\node_modules\hubot\bin\hubot" "%DEPLOYMENT_TARGET%\node_modules\hubot\bin\hubot.coffee"

Since we created the hubot.coffee, we need to configure the server to use that:

> echo require('coffee-script/register'); > server.js & echo module.exports = require('hubot/bin/hubot.coffee'); >> server.js

you can either copy this and run in command prompt, or create a file called server.js and add the following:

require("coffee-script/register’);

module.exports = require("hubot/bin/hubot.coffee");

Here is when we can change the name of the hubot back to acutally be hubot.

Open ./myhubot/bin/hubot.cmd in notepad and change “myhubot” to “hubot”.

You may also want to edit the readme.md and replace “myhubot” with “hubot” as well.

 

At this point you should make your github repo for your hubot and then commit your changes to github. (Use your github and your own repo)

> git init

> git add .

> git commit -m "initial hubot commit"

> git remote add origin https://github.com/[your-user-name]/[your-hubot-origin]

> git push -u origin master

 

Azure setup

Login to your Azure portal and create a new Web App: (The name has to be unique)

webapp1

 

If you are using Azure blob for the brain, create the storage account as well.

blob1

 

After the storage is created, we will need the Storage Account Name, and Primary Access Key. Copy these for use a little later:

keys

Go in to the settings for your newly created web app and click on “Continuous Deployment”. We are going to configure Azure Web Site to pull directly from the Github repo for the hubot configuration.

Choose Github as the provider and then authorize Azure to connect. Then choose your Hubot

cd

 

Finally we have to set up the environment variables that Hubot needs to function:

properties

You will create the following keys:

HUBOT_SLACK_TOKEN:  Your Slack Token for Hubot when you enable the integration

HUBOT_SLACK_TEAM:  myslack (from https://myslack.slack.com)

HUBOT_SLACK_BOTNAME: The name of your hubot

HUBOT_ADAPTER: slack

HUBOT_BRAIN_AZURE_STORAGE_ACCOUNT: The storage account name we saved from above

HUBOT_BRAIN_AZURE_STORAGE_ACCESS_KEY: The storage access token we saved from above

 

Go to your webapp to test that your hubot is working.

http://myhubot1.azurewebsites.net/hubot/help

help

Sometimes it doesn’t respond the first time, but if it continues to fail when requesting, there there may be an issue. Try running locally (you will have to remove the azure-blob when running local) and see if everything is working.

That’s about it. Enjoy!

Persistent Command History in PowerShell

If you are familiar with .bash_history or just wish you had a history of your powershell commands persist between sessions here is a handy little script. It will persist command history when you exit a powershell session to a file in %USERPROFILE% called .ps_history.

Copy the code below and save to a file called “Microsoft.PowerShell_profile.ps1” and save it in “%USERPROFILE%\Documents\WindowsPowerShell”

$HistoryFilePath = Join-Path -Path ([Environment]::GetFolderPath('UserProfile')) -ChildPath ".ps_history"; 
function Persist-History {
Register-EngineEvent -SourceIdentifier PowerShell.Exiting -Action {
Get-History | Select-Object -Unique | Export-Clixml -Path $HistoryFilePath;
} | Out-Null;
if (Test-path -Path $HistoryFilePath) {
Import-Clixml -Path $HistoryFilePath | Add-History;
}
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward;
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward;
}
Persist-History;
 

Disclaimer: I have only tested this with PowerShell 5


If it doesn’t work, you could probably make it work by installing the PackageManagement modules for PowerShell and install the “PSReadline” module.

Microsoft Channel9 Addon for Kodi

To add to the my list of hobby projects, I created a fork of an addon for Kodi that provides browsing of videos on Microsoft Channel9. This was my first attempt at a Kodi addon, and really my first time working with writing python. I started out by just reading over the original code and tweaking it a bit because some things were not working. Then I started following the pattern that existed and implementing new features, like being able to browse Channel9 authors, and Channel9 events.

Once I got these features in place, I started doing some real refactoring of the original code base. There was a ton of code that was duplicated in multiple places. I spent a few hours of the day really rewriting the entire addon. As the project stands right now, it is basically a complete rewrite of the original addon.

The project is on Github and building on AppVeyor.

Download the latest Release

Simplify standing up an IE Virtual Machine with PSIEVM

Over the weekend I was bored and decided to start a project to automate the process of standing up an IE VM with powershell. I would like to introduce PSIEVM. A powershell module that allows you to stand up an IE VM in VirtualBox (other hosts coming in the future) in one line.

PS> Get-IEVM –OS Win7 –IEVersion 9

That is the simplest form of the command.

Installation

To install, download from the github project releases page and extract to $env:USERPROFILE\WindowsPowerShell\Modules. Then to use it just import it

PS> Import-Module psievm
PS> Get-IEVM –OS Win7 –IEVersion 10 –AlternateVMLocation "G:\VMs\" –VMRootPath "G:\VMs\"

 

The parameters for Get-IEVM:

Name

Required

Type

Default

OS

YES

String

[Empty]

The OS to use:

  • WinXP, WindowsXP, Windows XP, XP
  • WinVista, WindowsVista, Windows Vista, Vista
  • Win7, Windows7, Windows 7, 7
  • Win8, Windows8, Windows 8, 8
  • Win8.1, Windows8.1, Windows 8.1, 8.1
  • Win10, Windows10, Windows 10, 10

IEVersion

YES

String

[Empty]

The version of IE. This is dependant on the version of Windows (See the table below).

  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • Edge

Shares

NO

String[]

[Empty]

These are the paths to add as a share in the VM through the VMHost. May not be fully supported in all VMHosts.

AlternateVMLocation

NO

String

[Empty]

By default the VM images will be downloaded from Microsoft, but if you have the images downloaded already, you can use this to tell the script where to get them. This can be a URL, Network Share, or a local path. The images need to follow the following pattern:

IE: IE<IEVersion>.Win<OSVersion>.For.Windows.<VMHost>.zip
Edge: Microsoft%20Edge.Win10.For.Windows.<VMHost>.zip

VMHost

NO

String

VirtualBox

The VM Host to use. Only VirtualBox is currently supported but here is the full list that will be supported (and maybe others).

  • VirtualBox
  • HyperV
  • Vagrent
  • VPC
  • VMWare

IgnoreInvalidMD5

NO

Boolean

$False

After the zip image is downloaded, the file MD5 hash is validated. If you use your own images, you will want to set this to $True.

VMRootPath

NO

String

$PWD

This is the path to download the zip image to and create the VM image folder where the VM will reside. By default it will use the Current Working Directory.

OS / IEVersion

This is the version of the OS that you want hosted and the version of IE you want with it. Here are the supported values:

 

IE 6

IE 7

IE 8

IE 9

IE 10

IE 11

MS Edge

Requires 64-bit Emulation

XP

X

 

X

 

 

 

 

 

Vista

 

X

 

 

 

 

 

 

Win7

 

 

X

X

X

X

 

 

Win8

 

 

 

 

X

 

 

 

Win8.1

 

 

 

 

 

X

 

X

Win10

 

 

 

 

 

 

X

X

Download PSIEVM