Thursday, November 27, 2014

Can you access ODATA with PowerShell?

Yes you can. However you need to use PowerShell Version 4.0. On the computer where this post is created PowerShell 4.0 is installed by default (Windows 8.1). But if you are using Windows 7.0 read here:

Here is an example.
I take the example of using the ODATA service provided by ODATA.Org
Here is the URL of this service:

If you were to type this into you browser,you would see this.

This shows meta data of the collection in this service

Launch Windows PowerShell with elevated permissions.

Verify you are using Version 4
PS C:\Windows\system32> $PSversionTable.PSversion
Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1


Declare a $Categories variable as shown
You will be returned to the next line if there are no errors
Let us see what is in categories
PS C:\Windows\system32> $categories
id       :
category : category
link     : {link, link, link}
title    : title
updated  : 2014-11-27T21:11:29Z
author   : author
content  : content

id       :
category : category
link     : {link, link, link}
title    : title
updated  : 2014-11-27T21:11:29Z
author   : author
content  : content

id       :
category : category
link     : {link, link, link}
title    : title
updated  : 2014-11-27T21:11:29Z
author   : author
content  : content
Looks like there are three categories
Let us look at the titles and link of these categories
PS C:\Windows\system32> $categories.title
type                                                        #text
----                                                        -----
text                                                        Food
text                                                        Beverages
text                                                        Electronics

PS C:\Windows\system32> $
rel                                     title                                   href
---                                     -----                                   ----
edit                                    Category                                Categories(0) Products                                Categories(0)/Products Products                                Categories(0)/$links/Products
edit                                    Category                                Categories(1) Products                                Categories(1)/Products Products                                Categories(1)/$links/Products
edit                                    Category                                Categories(2) Products                                Categories(2)/Products Products                                Categories(2)/$links/Products

Tuesday, November 25, 2014

What is a Easy Transfer Cable? or do you need to go from XP to Windows 7?

You have already heard that Windows XP support is history. If not, read the following:

After Windows XP came a number of OS Upgrades the most important ones being Windows Vista, Windows 7, Windows 8, Windows 8.1 and soon Windows 10. Of course there were two different architectures as well x32bit and x64bit.

If you had had a Windows XP and migrating to Windows 7 you would need a easy tool. Looks like Windows Easy Transfer was utility made just for this and should be available in Windows 7.

With this utility there were three ways you could transfer stuff between two computers as shown in the opening screen of Windows Easy Transfer (migwiz.exe).

If you were without a network connection you could use the Easy Transfer Cable or create a file on a external HD or a USB Flash drive.

Well what is this Easy Transfer Cable?

It is a USB Male-to-Male connector with an intervening electronic device that allows fast transfer between the connected computers while providing short-circuit protection.

You could buy this cable from a number of vendors such as Belkin (Model FSU258, FSU279),  Dynex (DX-C113231), and many others.

Here is a picture of one of the Belkin cables.
 Here is a listing of transfer support it provides.

Read more here:

Friday, November 21, 2014

How can I install PHP on Windows 8.1?

In order to install PHP on your machine you should have the local web server working which is IIS 8.0 on a Windows 8 OS.  if it is not activated you can activate it from Control Panel (Turn Windows features on or off ).

If the IIS 8.0 is activated you should be able to see the following screen when you access  http://localhost in  browser on your computer.

For the current laptop the following is the response:

Assuming you had no problem activating IIS 8.0 we can move to the next step of installing PHP 5.x.

Downloading and installing PHP 5.X:

PHP can be downloaded (free) using the latest Web Platform Installer (WebPI) which happens to be WebPI version 5.0 from here:

The advantage of using the WebPI is that it not only it installs PHP engine but also configures it to work with IIS.

Downloading and installing is quite easy as shown in the following post:

After installing PHP engine you should test to verify it is working correctly by browsing the info.php file shown next from the following file location:


Here is the simple code listing for info.php:

If your PHP engine is working well you should see the following (only part of a very long page is shown) when you browse this file in your IIS or type the following in the address box of your browser.
This completes the installation of PHP 5.6 on Windows 8.1 Professional that works well with IIS 8.0

In a future post we take a look at accessing SQL Server 2012 from a PHP application.

Related must read article:
I have covered in detail how to use PHP applications (PHP versions 5.2.4 or later) to access data on Microsoft Azure SQL Databases (formerly called  Microsoft SQL Azure) using PHP Data Objects. Details are on pages 369-373, Chapter 10 in my 2010 book here:

You can buy or join the library here:



Wednesday, November 19, 2014

What is DMCA?

DMCA stands for Digital Millennium Copyright Act (it is part of the US Copywrite law) and it criminalizes, "production and dissemination of technology, devices, or services intended to circumvent measures (commonly known as digital rights management or DRM) that control access to copyrighted works".

This United States copywrite law implements two 1996 treaties of World Intellectual Property Organization.

Follow Wikipedia for further details:

According to this law you could be penalized and pay penalties for copywrite infringement on the Internet.

DMCA provides protection to online providers such as Google from copywrite infringement liability claims provided, Google and similar providers remove or disable the alleged infringing sites.
You can get more information here for DMCA related information for Google Products:

If you think you are the target of copywrite infringement (Let us say your blog or some picture) you could bring it to the notice of Google or the other provider so that they can take steps to remove.

How effective is this process?

Internet is big and the complexity grows each day and I am not really sure how much protection you can get. I have been the target and you can read about it here  and here.


Monday, November 10, 2014

What is the difference between Windows PowerShell and Windows PowerShell ISE?

Windows PowerShell is not a GUI application and it runs the PowerShell engine in the host program. You will see the following screen displayed when you access Windows PowerShell from the Search charm on Windows 8.1.

If you choose to launch you should search for 'Windows PowerShell ISE. The following screee will be displaced. It is rich interface that has many features including interactive help in scripting. If you are new to Power Shell you should begin your learning with this tool.

You can launch them as administrator which gives you more power (Run as Administrator) and is called launching with elevated permissions.

You can launch multiple instances.

You may be interested in these two posts as well:

Do you know that Here-Strings are?
Find it here:

Monday, November 3, 2014

How do you work with Javascript Object Notation?

With enhancements to JavaScript in recent years and the advent of AJAX, interest in JavaScript took a turn for the better. Early on with AJAX it was recognized that there was a contender for XML for handling data which was stable, faster, and portable. This was the beginning of JSON.

Although RFC 4627 marks a JSON milestone, it appears that it had already been discussed among the JavaScript cognoscenti. JSON is equally, or even more suited, for data exchange than XML, which was originally considered to be the ideal wire friendly format.
What is JSON?
So what is JSON? It’s an acronym you might have started appearing in greater frequency on the Internet. JSON stands for JavaScript Object Notation. Well, it is a special object notational construct and is a subset of JavaScript. It can be used wherever JavaScript can be used and you do not need to download anything. There is no need to worry about the version of JavaScript.
You can read more about JSON in RFC 4627. JSON was designed to be minimal (small), textual, and portable. The MIME Media Type is now registered as application/json. JSON can handle exchanging data in applications written in different programming languages such as C, C#, ColdFusion, Perl, Python, Ruby, and so forth.

JSON Basics
JSON has simple types and two structures which are very similar to the universally used data structures such as dictionary objects, hash values, key/value pairs, lists, sequences, record sets, arrays and so on. It is a natural.

Types in JSON

JSON’s JavaScript subset admits of the following four primitive types.
* strings [except ", and Control Characters]
* number [Integer, real and Floating point]
* Boolean [literals, true and false]
* null

Unlike JavaScript it does not support hexadecimal and octal representation of numbers, nor does it support NaN (not a number) and infinity. Also numbers do not need quotes but strings do.
In addition to the four primitives it also supports two kinds of structures, object and array.

JSON Object
A JSON object is an unordered set (members) of key/value pairs, with keys being separated by values using a colon (:) and the members being separated by a comma (,). The colon and the comma are respectively called the name separator and the value separator.
Here is a variable that represents a JSON object with three members. “company”:”Hodentek” is one member of the JSON object where the key, which is “company,” is separated by the value, which is “Hodentek.” The object is always enclosed between curly brackets as shown in the declared variable. In this example all the values are of type string.

var jObj={"company":"Hodentek", "phone":"609-275-1205", "city":

You can access any member’s value using the dot notation as shown in the next snippet, which shows the “phone” of the object in the alert as “609-275-1205.”


The values of members of the JSON object can be of different types as shown in the following code listing.
Script Language="JavaScript"›

//values are numbers (integer and floating point)
var jobj2={"sunday":1, "tuesday":2.85, "wednesday":3};
document.write("‹b›jobj2.tuesday:‹/b› " + jobj2.tuesday +"‹br›");
//values are of mixed types
var jObj3={"culprit":true, "innocent":false, "notsure":null};
document.write("‹b›jObj3.culprit:‹/b› " + jObj3.culprit +"‹br›");
document.write("‹b›jObj3.innocent:‹/b› " + jObj3.innocent +"‹br›");
document.write("‹b›jObj3.notsure:‹/b› " + jObj3.notsure +"‹br›");


The displayed output when this code is browsed is as shown in the next picture.

JSON Array

Unlike JSON objects, JSON arrays are enclosed between square braces [ ]. The JSON array is an ordered sequence of values separated by a comma (,). The values can be any of the primitive types as well as the two structures, JSON objects and JSON arrays. Here is a JSON array variable with four string values.

var myJsonArray=["Red", "Blue", "Yellow", "Magenta"];

You will be able to access an array item from its position (0 based) as shown in the following listing.

var myJsonArray=["Red", "Blue", "Yellow", "Magenta"];
for (i=0; i‹4; i++){
document.write("‹b›myJsonArray["+i+"]‹/b›="+ myJsonArray[i]+"‹br›");

The displayed output when this script is executed is as shown in the next picture.

It is possible to have an array  whose elements are of different types. Array items can be objects and arrays as well, as shown in the next listing.
//Array with different types
myJA2=["red", 1, null, true];
document.write("‹;b›myJA2:‹;/b›  " + myJA2[2]);
//Nested array
myJA3=["red",1,["a", "b", "c"], false];
document.write("‹;b›myJA3[2][1]:‹;/b›  " + myJA3[2][1]);
//Object in an array
myJA4=["red", {"Yes":"Yes, you do", "No":"No, you do not"}, 2];
document.write("‹;b›myJA4[1].Yes: ‹;/b›"+ myJA4[1].Yes);

The displayed output when this script is executed is as shown in the next picture.

Notice how the inner array and the object inside the array are  accessed.
JSON is minimal textual representation of data as compared to the “verbose” XML, which makes equivalent XML much larger than JSON. Well, both are textual, but JSON is more so than XML with all its “angularities.” This is not to put down XML but just to highlight the obvious. This has obvious implications for AJAX, and more often JSON is the preferred data format in which AJAX results are received.
Everything in XML is a string but JSON has types as discussed earlier. JSON equivalent of XML In my previous tutorials, XML Islands and XML Responses and AJAX, the file webstudents.xml was used for illustration.

The same file will be represented as a JSON object in this section. The file is reproduced here for reference. In writing down the equivalence only the root element and its children are considered. Here is the listing of webstudents.xml.
‹!--My students who took web programming class with me--›
‹student id="1"›
‹name›Linda Jones‹/name›
‹legacySkill› Access, VB5.0‹/legacySkill›
‹student id="2"›
‹name›Adam Davidson‹/name;
‹legacySkill›Cobol, MainFrame‹/legacySkill›
‹student id="3"›
‹name›;Charles Boyer‹/name›
‹legacySkill›HTML, Photoshop‹/legacySkill›
‹student id="4"›
‹name›Charles Mann‹/name›
‹legacySkill›Cobol, MainFrame‹;/legacySkill›

The rules in this conversion are simple. The root element will be the main object, and the three student nodes will form an array. Each array element will be a student object with its own attributes as a string value pair. If you keep the following syntax  in your cross-hairs it will be easy to follow the listing.

Object: var obj={key1:value1, key2:value2 ,key3:value3};
Array: var Arr=[valueA, valueB, valueC];

The XML document has both simple and complex types and this is developed piecewise to make the explanation easy to understand.

Root element with students and their attributes

The root element is the object with the three students arranged in an array. Each of the students is an object as shown in the next listing.

var justStudents={"wclass":[
This is an object whose value is an array. The wclass[1] refers to the second student object and is accessed as shown in the alert statement. This code will display an alert window with value 2. In the above code the children of the students are not included.
Root element with student’s children

The next listing shows the JSON object with only the children of students shown in an array.

var webclass ={
{"name":"Linda Jones", "legacySkill":"Access, VB 5.0"}},
{"name":"Adam Davidson", "legacySkill":"Cobol, MainFrame"}},
{"name":"Charles Boyer", "legacySkill":"HTML, XML"}}

Here student 2 is “Charles Boyer” and his legacyskill is displayed in the alert box. Combining the two, it is easy to see how the JSON equivalent of webstudents.xml can be fashioned as shown in the next listing.
var studentAll={"wclass":[
{"student":{"id":"1"},"name":"Linda Jones",

"legacySkill":"Access, VB 5.0"},
{"student":{"id":"2"},"name":"Adam Davidson",

"legacySkill":"Cobol, MainFrame"},
{"student":{"id":"3"},"name":"Charles Boyer",

"legacySkill":"HTML, XML"}
document.write("‹b›Id of 3rd student: ‹/b›" + studentAll.wclass[2].;
document.write("‹b›name of 2nd student:‹/b› " + studentAll.wclass[1].

document.write("‹b›legacySkill of 1st student:‹/b› " + studentAll.


The listing also shows how the various values are accessed. The displayed output when this script is executed is as shown in the next picture.

Notice how the student attributes are accessed.

What about binary object representation?

There is no native support for binary objects. However some new formats have appeared recently.
Read here and here. However their universal adoption will take time.


JavaScript Object Notation (RFC 4627) is introduced with examples of its types, objects and structures in this post. JSON is well suited for data interchange. JSON is stable because it has no versions; needs no validation; and is not extensible, all very likable characteristics which may make it a long time player in JavaScript.

However, since JSON is a subset of JavaScript, it has to conform to the same naming conventions regarding the use of language specific keywords and other rules. Also, its usefulness in AJAX calls is obvious because JSON is as easy for humans as it is for machines, and a lot simpler and more understandable. he fact that it is easy for machines makes it an obvious for the Internet of Things where communication with machines takes center stage.

In the simple example of webstudents.xml, the number of characters for XML amounted to 413, whereas when formatted in JSON it required 243, a substantial difference. Accessing values is also a lot simpler than going through the ECMA object model climbing up and down the XML tree.

Unmodified version of the post appeared here: