ScorpioTek Solutions
07-filler-left Information about ScorpioTek Services Offered by ScorpioTek Training Courses Offered by ScorpioTek Technology Blog by ScorpioTek Contact us for more information on training/services 08-filler-right

Archive for the ‘Tutorials’ Category

How to Set xdebug in Mac OS X with phpStorm and MAMP in 23 Easy Steps

Friday, September 27th, 2013

Ortodonciacr functions php ortodonciacr Copy Documents ingenium Sites ortodonciacr

It’s amazing how spoiled we tend to get with products such as Xcode and Visual Studio.  I’ve gotten accustomed to debugging a web application by hitting F5 and off you go.  After the last hour or so of configuring phpStorm has taught me, setting up remote debugging can be a bit of a pain.

I’m going to document all I did because I’m bound to forget it all.  Here is my current setup:

 I am assuming you have MAMP running and phpStorm installed.  I am also assuming you will be using Chrome.

  1. In you want to debug PHP using MAMP, you have to use PHP 5.2.17:

    PHP Version 5.2.17

  2. Open the PHP ini file for version 5.2.17, usually found under: /Applications/MAMP/bin/php/php5.2.17/conf/php.ini
  3. Look for the portion of the code that reads:


  4. Remove the ‘;’ before the zend_extension bit
  5. Append the following below that line:


  6. Stop your MAMP server and restart it again
  7. To make sure xdebug is properly installed, from the MAMP App, select “Open start page”

    MAMP and How to Set xdebug in Mac OS X with phpStorm and MAMP 2

  8. When the page loads, click the phpInfo link in the toolbar:


  9. Scroll all the way to the bottom and find the section called Xdebug, the following should be listed:

    Xdebug installed on OS X

  10. At this point, xdebug is installed.  Now we must configure phpStorm to work with it.  Launch phpStorm, create/open the project you want to debug and from the File menu select Preferences.
  11. From the Project Settings section, click the PHP node:

    PHP Node in phpStorm

  12. Notice the right pane now allows you to select the PHP interpreter to use.  MAMP ships with various versions of PHP, but we need to set this one to use 5.2.17 if we want to to debug.  Click the Ellipsis button, create a new configuration by clicking the ‘+’ and selecting “Specify Other”

    Interpreters and Settings

  13. Name the configuration PHP 5.2.17 and specify as the PHP home the following path: 


  14. phpStorm will now recognize the interpreter and display the version:


  15. From phpStorm, select from the Run menu Edit Configurations
  16. Click the ‘+’ sign and select PHP Web Application
  17. Fill out the values to your corresponding development environment, here is mine as a guide (make sure to select Chrome as your browser)

    Run Debug Configurations

  18. Almost there!  To make life easier when hooking up the debugging session with Chrome, we need to install an extension that will make life easier, the Xdebug helper extension.
  19. Once installed, open the web page you would like to debug in Chrome 
  20. Now it’s time to test debugging!   Set up a breakpoint somewhere in your code that will be hit when the web app runs.
  21. From the Run menu, select Debug [Name of your Project]
  22. Chrome will open the web application, you will notice that your URL has a debugging portion added to the URL:


  23. Back in phpStorm, your breakpoint will be hit and now you can debug!

    Ortodonciacr functions php ortodonciacr Copy Documents ingenium Sites ortodonciacr


If you have questions or comments, please post below, I’ll leave this thread open for a while.


How to get rid of ghost networks in Windows

Wednesday, January 18th, 2012

This is something that is bound to happen if you have virtual machines and you remove a NIC.  Say for instance that you have a VM that has a virtual network and under Network Adapters you give the name “Public”.  A few weeks later, you remove the virtual NIC, add a new NIC and then want to rename the NIC from “Local Area Connection” to “Public”.  You will most likely see this message:

Cannot rebame this connection.  A connection with the name you specified already exists.  Specify a different name.

So you take a peak at the Device Manager to find the old network to nuke it – good luck with that, you won’t find it!  Why?  The old NIC is hidden, and even if you select to view hidden devices in the device manager it won’t show up.  Why?  I have no idea:

No Ghost NIC 

So here is what you need to do:

  1. Close Device Manager if already open
  2. Open a command prompt as administrator
  3. Type:

Device Manager will show up.  From the View menu, select Show hidden devices:

Show Hidden Devices

And just like that, your ghost networks will show up:

Ghost NICs Found!

Nuke the ghost NICs and now your new NIC can have its old name back! 

Possible Fix for “The boot selection failed because a required device is inaccessible”

Tuesday, March 8th, 2011

After upgrading some of our VMs to the latest Hyper-V Integration Services, some machines failed to boot and prompted us with:

“The boot selection failed because a required device is inaccessible”

0xc000000f error code

After some searching, I was able to repair the BCD of the failed machines. Here is what you need to do:

  1. Boot into Windows 7 / Windows Server 2008 R2 disk
  2. Select to open a repair and open a command prompt
  3. Type: Bootrec.exe /FixBoot
  4. Type: Bootrec.exe /RebuildBcd

Reboot the machine, and hope for the best.

Debugging Symbols

Tuesday, March 1st, 2011

While trying to set a cluster debugging demo, I realized that loading the symbols from Microsoft servers was taking quite a while. After searching a bit, I found a page that has the debugging symbols required for cluster debugging with Windows HPC Server 2008 R2.

I downloaded these 2 for cluster debugging:

Expand them to your favorite folder (in my case E:\Symbols) and then point Visual Studio to that folder:

You will then be able to debug immediately since the symbols will now reside locally and there will be no need to download them from the Internet to cache them.

How to install Windows Server 2008 R2 SP1 RC with previous Beta install

Tuesday, December 7th, 2010

If you installed Windows Server 2008 R2 SP1 Beta when it was available, you might want to try the RC version that is now available. The new version of the operating system includes a series of features such as dynamic memory for Hyper-V and RemoteFx.

Before you double click on the RC installer file, you might want to know that it is not possible to upgrade the Beta to RC. However, you can uninstall the Beta and install RC once you are done. The process is fairly simple:

  1. Open Programs and Fearures
  2. Click View Installed Updates
  3. Find Microsoft Windows (KB 976932) and uninstall it

Your machine will need to reboot and it can take up to 30 minutes to remove the Beta. Once it comes back, you should be able to install the RC version of 2008 R2 without issues.

HPC Server 2008 Heat Map Resuscitation with PowerShell

Monday, May 31st, 2010

Note: This script will work with PowerShell v1.0 and is slow.  If you would like a faster version and you are willing to upgrade your head-node to v2, check this post instead.

I’ve been working in creating a series of demos for a couple of HPC trainings we are delivering this month.  One of the things that I’ve noticed with the heat map, is that when restoring the nodes from a snapshot (they are virtual nodes) the heat map fail to display the info.  This is due to some services on the nodes not starting and failing to communicate with the head node.  The solution is to go through every node and restart this service.  Good luck doing that if you are running a 1,000 node cluster!

You might think “well, why not just use clusrun to stop and start the service?”  Thought of that and then realized that one of the services that need to be restarted is the one that is used for clusrun, so as soon as you shut it down, your clusrun session is over.

Once again, psexec and PowerShell save the day.  If you would like to restore heat map functionality from the head node to all nodes on your cluster, follow these steps:

  1. Download and drop a copy of psexec on c:\Windows\System32 on your head node
  2. Copy the PowerShell code below and save it in a file, say “C:\FixHeatMap.ps1″
    Write-Host "Setting Head Node To:" $HEAD_NODE
    $nodes = Get-HpcNode
    $services = "HpcManagement", "HpcNodeManager"
    foreach ($node in $nodes)  {
    foreach ($service in $services) {
    $serviceStart = "net stop $service"
    $serviceStop = "net start $service"
    $commandBytesStart = [System.Text.Encoding]::Unicode.GetBytes($serviceStart)
    $commandBytesStop = [System.Text.Encoding]::Unicode.GetBytes($serviceStop)
    $encodedStartCommand = [Convert]::ToBase64String($commandBytesStart)
    $encodedStopCommand = [Convert]::ToBase64String($commandBytesStop)
    $commandLine += $encodedCommand
    $computer = $node.NetBiosName
    $computer = "\\$computer"
    psexec $computer cmd /c "echo . | powershell -EncodedCommand $encodedStartCommand"
    psexec $computer cmd /c "echo . | powershell -EncodedCommand $encodedStopCommand"
    #Start the service that retrieves info from CN to heat-map
    net stop HpcSdm
    net start HpcSdm
  3. Edit the text of the file so that $HEAD_NODE = “HPC-HN” matches the name of your head node
  4. Open an HPC PowerShell command prompt and launch the script, here is the script in action with 4 nodes:

One of the things you will notice is that it can be slow as 3 services are started and stopped for every node via a remote call with psexec.  I know the process can be long but I don’t have time to optimize it.  If there are PowerShell gurus that would like to chip in, please be my guest!


How to get Server Core 2008 R2 to Hyper-V in 10 Minutes or Less

Tuesday, May 25th, 2010


I need to showcase the capabilities of Windows HPC Server 2008 and for doing so I’ve decided to host 4 VMs that will be part of the cluster.  My VM server only has 4 GB of RAM and I need to make the best usage out of the hardware.  I decided to install Windows Server 2008 R2 Enterprise as the Server Core option, this would give me more RAM for the VMs to run. I wrote this guide to get your base Windows Server 2008 R2 installation to a full Hyper-V server in a matter of minutes, let me know if it works for you!


One of the first things you want to do is enable remote desktop connections:

WMIC RDToggle Where ServerName="%COMPUTERNAME%" Call SetAllowTSConnections AllowTSConnections="1"

Then, enable the firewall to allow RDC:

netsh advfirewall firewall add rule name="RemoteDesktop" dir=in action=allow protocol=TCP localport=3389

That’s it in terms of sitting in front of your server core, you can now connect remotely and carry out the rest of the procedures.

If you have not done so already, log-in from a remote computer to your server core box.

Let’s now enable .Net 2.0:

dism /online /enable-feature /featurename:NetFx2-ServerCore

And now, let’s enable PowerShell:

dism /online /enable-feature /featurename:MicrosoftWindowsPowerShell

Download Core Configurator, burn it to a CD/DVD and insert it into the server core box.

Copy all the contents of the DVD to your server core machine, for instance:

xcopy /Y D:\* c:\Program Files\CoreConfiguratorv20\

Open PowerShell:


Enable RemoteExecution policy:

Set-ExecutionPolicy RemoteSigned

Change directories to the CoreConfigurator directory:

cd "C:\Program Files\CoreConfiguratorv20\"

Launch Core Configurator:


Now on CoreConfigurator carry out these steps:

  1. Click “Computer Settings…”
  2. Click Roles and Features
  3. Enable the Hyper-V role and click Apply:
  4. You will be prompted to Reboot, click Restart now

    You machine will reboot and after configuring Windows will reboot once again

    You should now have a full Hyper-V Server Core installation, pat yourself in the back, you deserve it.  Now…how do you do stuff with it?  Well, first and foremost, CoreConfigurator has a Hyper-V settings button:

From that setting you should be able to start/stop VMs:

But what about controlling the Hyper-V settings from a Hyper-V manager from another machine?  The good news is that is possible, and the bad news is that is not straightforwards.  Luckily for us, John Howard was cool enough to write a utility that enables a much easier configuration: the Hyper-V Remote Management Configuration Utility

Read the instructions carefully and you should be able to control your Server Core Hyper-V from a remote Hyper-V machine:

How to use QuickSFV to verify file integrity

Saturday, May 22nd, 2010

We usually exchange large files with our customers, such as highly compressed virtual machines.  Compression works perfectly for us, as it allows us to send a VM as one file, which is usually a self-extracting archive.  However, downloading files opens up the possibility of download corruption, which can render the compressed archive useless.

In order to avoid corrupted downloads, you should use a download manager that allows you to resume the download in case it breaks.  We’ve had good luck recently with Internet Download Manager.

In order to verify that no corruption has happened during the transfer process, we usually send our clients a sfv file.  This file is intented to be used with QuickSFV in order to verify that the download is not corrupt .  The following guide will instruct you on how to use QuickSFV to verify that your download is not corrupt.


We are assuming that you:

  1. Already have the files downloaded somewhere on your computer
  2. Already have installed QuicSFV on the computer where the files were download (make sure you install the correct one if you are using a 64-bit OS)
  3. Have placed the sfv in the same folder where the files you want to check are located


  1. Navigate to the folder where your downloaded files are
  2. Double click the sfv file
  3. QuickSFV will start checking your files.  Depending on the size of the files, this might take some time

    Verification in Progress

  4. If you see a dialog similar to the one below that displays All files OK, you are good, the files have been verified:


  5. If you see the dialog below, pay attention to which file is corrupt and re-download the file:


Parting Words

ALWAYS use a download manager for large files, you’ll be sorry if you stick to FireFox/Internet Explorer for these types of downloads.

Consider donating to QuickSFV, it’s a great utility that can save you hours of pain.

How to avoid duplicate messages in OS X with Spotlight (Gmail)

Saturday, May 22nd, 2010

I love Spotlight in OS X, especially for finding that particular message.  Finding a message buried in thousands of mails can be as easy as typing into Spotlight some of the properties of the mail you are looking for.  If you use IMAP with Gmail, or IMAP with a domain of your own under Google Apps, you might notice that when you search for a mail, lots of duplicates can quickly pile up, which is truly frustrating:

Thanks, but no thanks!

I quickly got fed up with this and decided to look for a solution and fortunately there is one :)

The first thing you need to do is enable Labs for your Gmail account, this is simple and I found some instructions here.

Once you have enabled Labs, access the Labs tab and look for a lab feature called Advanced IMAP Controls:

Enable this Option

Enable this option

Once you have enabled the feature, make sure you scroll down and click the Save Changes button or nothing will be saved.

Almost there…now from your Gmail account, from Settings and then hit the Labels link:

You should now get a listing of the mailboxes that usually show up in Mail.  Un-check the one that is causing the duplicates to show up in Spotlight, which is usually the All Mail one.  As an extra, I like to uncheck the Spam folder as well, I really don’t go around looking for spam every now and then:

Close and reopen, rebuild your Spotlight index and say goodbye to duplicate entries in your Spotlight results forever!


How to Execute Remote PowerShell Commands using C#

Sunday, April 11th, 2010

UPDATE: The post below works when you are trying to execute simple commands.  I had issues when trying to execute full scripts.  After searching some more, I found amazing tutorials on how to carry out this procedure, check them out:

Before I start this post that I am urging to write (before I forget all I did), I must clarify that all the code here was from various sites/forums.  All I did was to try and get the combination right, which basically took all of my time yesterday.  Nonetheless, at least it’s working.

So what I am writing at this moment is a C# application that will issue SCVMM commands from any machine in my domain.  SCVMM’s API is 100% PowerShell, so anything you need to run automatically via code in SCVMM, needs to be called through PowerShell somehow.

PowerShell v2.0 includes Remoting, which allows you to issue PowerShell commands remotely on other machines by using Windows Remote Management (WinRM).  So let’s see how on Earth this is done:


Before you do any of this, you must run the following command in an admin PowerShell command prompt on the machine where you would like to run the remote command:

winrm quickconfig

The Code References

You need to use the correct version of System.Management.Automation.dll.  If you are running Windows 7 / Windows Server 2008 R2, you must include this reference in your project from the following path:


Note: When importing the aforementioned DLL, I was having all kinds of issues with Visual Studio 2008.  I tried it with Visual Studio 2010 and it worked right away.

The Namespaces

Include the following namespaces in your code:

using System.Management.Automation; // Windows PowerShell namespace
using System.Management.Automation.Runspaces; // Windows PowerShell namespace
using System.Security; // For the secure password

The Function

This is the function you need to invoke when you want to run a remote command.  The incoming string, scriptText, is the PowerShell command you would like to execute:

public static string RunScript(string scriptText)

           Runspace remoteRunspace = null;
                ref remoteRunspace);

                StringBuilder stringBuilder = new StringBuilder();
                using (PowerShell powershell = PowerShell.Create())
                    powershell.Runspace = remoteRunspace;
                    Collection<PSObject> results = powershell.Invoke();
                    foreach (PSObject obj in results)

                return stringBuilder.ToString();

Note that you must replace DOMAIN\USERNAME with your domain and username.  You must also replace PASSWORD with your password.  I really don’t know how to carry this out using my logged-in credentials, so until then, I’ll have to include my password in the code, which is crappy but works.  Also note that you must also replace SERVERNAME with the machine you are trying to connect to.  The port MUST be 5985, if you try the default (80), it will fail to connect (at least, it did in my case).

The magic happens inside the static function openRunspace which is defined as follows:

        public static void  openRunspace(string uri, string schema, string username, string livePass, ref Runspace remoteRunspace)
            System.Security.SecureString password = new System.Security.SecureString();
            foreach (char c in livePass.ToCharArray())
            PSCredential psc = new PSCredential(username, password);
            WSManConnectionInfo rri = new WSManConnectionInfo(new Uri(uri), schema, psc);
            rri.AuthenticationMechanism = AuthenticationMechanism.Kerberos;
            rri.ProxyAuthentication = AuthenticationMechanism.Negotiate;
            remoteRunspace = RunspaceFactory.CreateRunspace(rri);

Let me know if it works for you in the comments.