Using Windows PowerShell as an IT Pro – Part 14

March 31st, 2010

In my last post I reviewed arrays. Now I will explore Operators.

An operator is a language element that can be used in a command or expression to perform an operation. Windows PowerShell supports several types of operators to help you manipulate values. First, let’s look at Arithmetic operators.

Arithmetic operators calculate numeric values. Arithmetic operators are used to add, subtract, multiply, and divide values, and to calculate the remainder (modulus) of a division operation.

In addition, the addition operator (+) and multiplication operator (*) also operate on strings, arrays, and hash tables. The addition operator concatenates the input. The multiplication operator returns multiple copies of the input. You can even mix object types in an arithmetic statement. The method used to evaluate the statement is determined by the type of the leftmost object in the expression.

Windows PowerShell supports the following arithmetic operators:

Operator Description Example
+ Adds integers; concatenates strings, arrays, and hash tables. 6+2
“file” + “name”
- Subtracts one value from another value. 6-2
(get-date).date – 1
- Makes a number a negative number. -6+2
-4
* Multiplies integers; copies strings and arrays the specified number of times. 6*2
“w” * 3
/ Divides two values. 6/2
% Returns the remainder of a division operation. 7%2

 

Windows PowerShell processes arithmetic operators in the following order:

· Parentheses ()

· – (for a negative number)

· *, /, %

· +, – (for subtraction)

Windows PowerShell processes the expressions from left to right according to the precedence rules. The following examples show the effect of the precedence rules:

3+6/3*4

Operator01

10+4/2

Operator02

(10+4)/2

Operator03

(3+3)/(1+1)

Operator04

You can also do this with non-numeric types. Numbers, strings, arrays, and hash tables can be added; numbers, strings, and arrays can be multiplied. However, you cannot multiply hash tables.
When adding strings, arrays, or hash tables, the elements are concatenated. When you concatenate collections, such as arrays or hash tables, a new object is created that contains the objects from both collections. If you try to concatenate hash tables that have the same key, the operation fails.
For example, the following commands creates two strings and then adds them:
$a = "1"
$b = "A"
$a + $b

In my next post we will examine assignment operators.

More Windows 7 Tips and Tricks

March 29th, 2010

Windows 7 builds and improves upon the advances made in Windows Vista.  A lot has been written about how to take advantage of the new features, but a lot of this information is scattered all over the place.  Here are some of the new features that I personally use.

Sizing and moving windows

If you want to have two windows up side-by-side, it’s easy have Windows automatically size them for you with the snap feature.  Simply drag a window to the left side of the screen, and it will automatically dock to the left.  Then do the same with your second window on the right side of the screen and you’ve got both windows running side-by-side.  This is great for widescreen monitors, and if you were paying attention to my previous blog, you know that you can do this with Windows key shortcuts (Win+Left/Right Arrow).

Let’s say you want to minimize all windows but the one in which you are currently working.  You can quickly do this by clicking and holding onto the windows bar of your current window and then shaking the mouse back and forth a few times.  Bring the minimized windows back by doing it again.

The improved calculator

In Windows 7, the built-in calculator has been redesigned to allow you to go beyond basic math with unit conversion, such as Fahrenheit to Celsius and ounces to grams. Calculation templates make it easier to figure out things like fuel economy and lease payments. Additionally, new features such as Programmer, Scientific, and Statistics modes and tracking calculation history make it a very powerful tool.

image

 

The Problem Steps Recorder

 

If you’re having a problem with an application and need an easy way to illustrate the problem to tech support or your friend the computer expert, you can use Problem Steps Recorder to automatically capture the steps you take, including a text description of where you clicked and screen shot. Once you have recreated the problem and captured these steps, you can save them to a file and send it to your support person, who can then open it up and view the steps you recorded.

To launch Problem Steps Recorder, simply click Start, type PSR and then hit Enter. Or, you can do it using the Win+R shortcut key.

image

Open multiple instances of the same program

Here’s another helpful tip that can make it easier to get things done in Windows. If you’ve already got an application running, like Microsoft Word, or a Command Prompt, and you want to open another instance of the program, rather than clicking through the Start menu, you can simply Shift+Click on the taskbar icon to quickly launch another instance.

The taskbar and Start menu

In Windows 7 you can pin favorite programs anywhere on the taskbar or Start menu for consistent and easy access. And once you’ve pinned some items to the taskbar, you can easily rearrange them any way you like by clicking and dragging. You can also use the taskbar to preview windows by moving the mouse over a taskbar icon to see a thumbnail preview of open files or programs. Then, move your mouse over a thumbnail to preview the window full-screen. You can even close a window from the thumbnail preview – a big time saver.

Windows 7 Windows Key Shortcuts

March 29th, 2010

Windows 7 comes with many new tools and features designed to make it the most robust and powerful operating system ever.  The intuitive design means that many people know how to use Windows, but there are numerous tips and tricks that you can master to make yourself a more efficient user, and in the next two updates, I’m going to talk about some of these.

Most people know how to use CTRL+C and CTRL+V to  copy and paste, but did you know that in addition to these and other commonly-known shortcut keys, there are numerous others that involve the Windows key? Take a look at this table and familiarize yourself with a few of these shortcuts and you’ll find yourself navigating Windows like an expert:

Key Combination

Result

Win+Up Arrow

Maximize window

Win+Down Arrow

Minimize / restore window

Win+Left Arrow

Snap window to left side

Win+Right Arrow

Snap window to right side

Win+Home

Minimize / restore all other windows

Win+Space

View desktop without minimizing any windows

Win+Tab  Win+Shift+Tab

Cycle through windows in 3D

Win+D

Minimize / restore all windows

Win+E

Open Windows Explorer at Computer node

Win+F

Open Windows Search

Win+L

Lock desktop

Win+R

Open Run window

Win+U

Open Ease of Access Center

How to Create Custom Ringtones for your iPhone from Music Files in iTunes

March 29th, 2010

In iTunes, by default, you can only create ringtones from music you purchased from the iTunes Store. I personally have never bought any music from the iTunes store – I have a lot of music on CD that I legally own and have ripped to my computer in the form of MP3 files. It’s easy enough to add such files to your iTunes library and subsequently your iPhone (use the File -> Add File/Folder to Library option in iTunes).

So let’s say you’ve got a song you like and you want to create a ringtone out of it. Since you can’t make a ringtone out of an entire song, you need to identify which portion of the song you want to use as the ringtone. I try to find a catchy riff that’s easy to loop and is going to be loud enough to hear like you’d expect from a normal ringtone.

So for example, I have a song here that I want to make a ringtone out of. I’ve identified that if I just use the first two bars, or roughly the first eight seconds of the song, it should be about right.

clip_image002

So right-click on the song and then click Get Info. Then click the Options tab. Set the Start Time and End Time values using the x:xx.xxx format and then click OK. At this point you’re just giving it your best guess.

clip_image004

Now back in the music library screen in iTunes, I like to select the checkbox for ONLY the song I’m creating the ringtone from, like so:

clip_image006

Then, at the bottom of the screen, select the repeat button – the third one from the left:

clip_image008

This allows you to play and loop the snippet so that you can hear it just as you would if it were playing as a ringtone from your phone.

Most likely you’re going to find that your timing is a little off and you’ll need to go back into the song properties and adjust the start and stop times. Ideally you want it to play so that when it loops back to the beginning, it maintains the beat and blends seamlessly from end to start. Here’s what I came up with for this song after I was satisfied with the timing:

clip_image010

Once you’ve done that, the next step is to right-click the song and then click Create AAC Version. This creates a compact audio file that captures only the portion of the song that you specified based on the start and stop time values.

Next, right-click the AAC version and then click Copy.

clip_image012

Now on your computer, create a folder where you will store ringtone files. Right-click in this folder and then click Paste. You should see your file name with a .m4a extension. Rename this, changing the extension to .m4r.

Now, back in iTunes you can delete the AAC version of the song you created. Right-click it and then click Delete. Click Remove and then click Keep File. This removes it from your iTunes library without deleting the file itself from your computer.

Also, don’t forget to go back into the options for the original song and uncheck the start and stop times. If you don’t do this, then any time you try to play this song in iTunes, or on your iPhone or iPod once you’ve synced with iTunes, then it will play only the portion of the song between the start and stop times.

Now, in iTunes, click the Ringtones library. Then on the File menu, click Add File to Library. Browse to the folder where you copied the ringtone file to and then click Open.

Clearly, you can see that I think KMFDM songs make great ringtones.

clip_image014

Finally, click your iPhone device, and then on the Ringtones tab, select Sync ringtones and then click Apply.

clip_image016

Having done this, you can now go into your contacts on your phone and assign a custom ringtone that you’ve created as the default ringtone, or even to individual contacts.

Sounding Off Part Three

March 29th, 2010

An internal paint job to avoid monotony and quality equipment completes the package.

With the anticipation of spending many hours in the studio, I took a creative approach to painting the walls. A darker base color with splashes of bright colors helped lighten the small space.

The Electro-Voice Cardinal microphone is the key to quality in the recordings. I started out with a USB headset microphone and found that it created a thin and often echoing sound quality. Changing to a cardioid condenser microphone eliminated many of the audio artifacts that I was struggling to process out of previous recordings.

A tube pre-amp from Behringer provides a warm, smooth sound that rounds out the dull sound of purely digital recordings. The amp also provides the phantom power required by the Cardinal microphone.

The Behringer MX602A low-noise mixer provides live control over basic EQ and gain settings. It also provides a headphone jack. Using the mixer’s headphone jack instead of the computer’s jack eliminated the distracting delay that sound cards are notorious for.

I also added a Vistablet digitizing tablet for more precise control over mouse and cursor movement while recording the video portion of projects. Using a mouse works fine. However, the mouse would not always register when I moved it. Not to mention that the mouse pad is rarely able to cover the entire space on the monitor resulting in a jerky recording from picking the mouse up and moving back to the other side of the pad so it would roll clear across the screen. The digitizing tablet represents the entire area of the monitor providing instant movement of the cursor without the typical trials of a mouse.

All of this is used with the new Camtasia version 7 for both audio and video recording. If any additional processing of audio is required, I can easily do that with Audacity 3.0.

The final touch was the strategic placement of baffling materials on the walls and ceiling. My first recordings were much too “live” with reverberation, even in this small space. Baffling hung from the ceiling and on the walls dampened that to a reasonable bright sound. Some additional wall hangings also cancelled out an annoying high frequency ring. I had no idea when I started that it would get that detailed and nitpicky to make everything work smoothly.

I have now spent nearly a week and a half recording both video and audio in the new studio. The difference it has made is indescribable in both the quality of the recordings and my ability to block out the daily distractions.

Sounding Off Part Two

March 28th, 2010

The greatest challenge to building a room, or booth, suitable for recording quality audio is ambient noise. Simple walls and basic building materials are definitely not suitable for dampening the various sounds and frequencies that surround us. To solve this issue, walls were built with two by four construction overlayed with dense compressed wood. Inside the walls is standard insulation along with a specialized sound dampening board that looks like compressed dead grass and dirt.

Most of the wall studs and floor joists are offset instead of straight across to help capture various sound frequencies. My research indicated that the more consistently shaped the air spaces in the wall and floor, the easier it is for various frequencies to penetrate into the sound room.

The floor is elevated two inches off the office floor by commercial casters. This helps isolate the floor of the “studio” from the low end frequencies and vibrations that easily move through solids. Flooring is completely enclosed with the spaces filled with the same as the walls. A dense foam rubber gasket to further isolate the interior of the room from the exterior also isolates the top floor.

All cabling and wiring is also run with an offset. By this I mean that the entry location of any cabling or wiring is approximately 30 inches to the side, or below the location of the other end on the inside of the room. Any straight through access from the outside to the inside would allow sound to travel through the walls with very little if any dampening.

Ventilation is provided by an ultra-quiet bank of 12v fans. The fans are placed within a ventilation box that is composed of two sides. One side provides incoming air and the other provides a return. Within the box are randomly placed caches of baffling to quiet the sound of air movement within the ventilation box.

Lighting comes from a special fluorescent lighting fixture rated for extremely quiet operation. There is none of the typical buzz heard from standard fluorescent lights.

Flooring is simply low pile commercial carpeting over a six pound pad and stretched to keep it from bunching up.

Finally, the door is built with an outside layer that is about three quarters of an inch overlap similar to the way the walls are built. This helps eliminate sound penetration through any gaps along the sides of the door.

In the next blog, I will discuss the equipment used to create the audio recordings.

Data-tier Applications

March 25th, 2010

SQL Server 2008 R2 provides an easy way to author, deploy, and manage data-tier objects as a single entity through data-tier applications. A data-tier application (DAC) is an entity that contains all of the database and instance objects used by an application.

You can create DACs using two methods. First, you can use the Extract Data-tier Application wizard to extract database and instance objects from a database in SQL Server Management Studio (SSMS). This wizard will take you through a couple simple steps and create the DAC for you.

After you have extracted the DAC, you can author it in Visual Studio 2010 or you can deploy it to an instance of SQL Server using the Deploy Data-tier Application wizard. The Deploy Data-tier Application wizard will guide you through several steps to deploy the DAC to the instance you select.

You can create a DAC in Visual Studio 2010 or author a DAC you extracted by starting a Data-Tier Application project. After a DAC has been imported, you can add several elements to the DAC project: DAC properties, definitions of all the database objects used by the application, definitions of the instance-level objects, a server selection policy that defines the pre-requisite conditions an instance of the Database Engine should have to host the DAC, and files and scripts that can be embedded in the DAC.

There are two ways to view DACs: through Object Explorer and through Utility Explorer. Object Explorer will let you see a list of DACs on the instance. Utility Explorer will give you a more detailed view of the DAC, and allows you to view utilization information just like managed instances.

SQL Server Utility: Managing Multiple SQL Server Instances

March 25th, 2010

Have you ever wanted to be able to see a centralized view of Microsoft SQL Server instances and database applications? SQL Server 2008 R2 introduces a new way to view information about your SQL Server instances.  At a glance, you can see a snapshot of your instances including utilization information using the SQL Server Utility. This information is available in a new view called the Utility Explorer that you access through SQL Server Management Studio.

When you open the Utility Explorer, you are presented with the screen shown below. In this screen, you are given the steps you need to do in order to use SQL Server Utility. Each of these topics links to steps to complete the activity.

In order to use SQL Server Utility, you must create a Utility Control Point. The other steps are optional. A Utility Control Point, or UCP, is configured on a SQL Server instance. After configuring a UCP, you can enroll other SQL Server instances on the same UCP. The Utility Explorer displays information about each instance such as CPU utilization, file space utilization and volume space utilization. The display will look similar to the image below. The columns displayed are configurable by right-clicking the title bar and selecting the information you wish to view.

Notice the red arrow under volume space. This is indicating the instance is overutilized. If the instance were underutilized, there would be a green down arrow. The green checkmarks indicate the instance is well utilized. You can configure the values that will alert you when the instance is overutilized or underutilized. This allows you to customize these values best for your organization.

In addition to view information about SQL Server instances, you can view information about data-tier applications. My next post will discuss data-tier applications.

Using Windows PowerShell as an IT Pro – Part 13

March 22nd, 2010

In my last post I looked at some basic variable types. Now I will examine arrays.
An array is a data structure for storing a collection of data elements of the same type. Basically this means that you can have a single variable that stores multiple values.
Assign multiple values to a variable to create and initialize an array. The values stored in the array are delimited with a comma and separated from the variable name by the assignment operator (=).
For example, to create an array named $a that contains the seven numeric (int) values of 22, 5, 10, 8, 12, 9, and 80, type:
$a = 20,4,11,3,1,9,60

When no data type is specified, Windows PowerShell creates each array as an object array (type: object[]). You can create a strongly typed array, that is, an array that can contain only values of a particular type, the same way you create a strongly typed variable. You specify a type, such as string[], long[], or int32[]. Precede the variable name with an array type enclosed in brackets to cast an array.
[int32[]]$ia = 1500,2230,3350,4000

Simply type the array name to display all the elements in the array. For example:
$ia

You can refer to the elements in an array by using an index, beginning at position 0. Enclose the index number in brackets. For example, to display the third element in the $a array, type:
$ia[2]

You can create arrays that are cast to any supported type in the Microsoft .NET Framework. For example, the objects that Get-Process retrieves to represent processes are of the System.Diagnostics.Process type. Enter the following command to create a strongly typed array of process objects.
[Diagnostics.Process[]]$gp = Get-Process

Then, display the contents of $gp to see a list of running processes.
$gp

In my next post we will review operators and expressions.

Sounding Off Part One

March 21st, 2010

A big part of what we do at Aeshen is creating instructional and informational content. We painstakingly work to create PowerPoint presentations, demonstration scripts for instructors, and supporting documentation. After creating these materials, we are often called upon to create a complete set of video and audio recordings based on the new content.

Creating the video recordings is a simple task. Very few things in the surrounding environment force me to re-record video footage of the demonstrations or PowerPoint presentations.

Audio is a completely different story. The human brain is very sophisticated. Not only can it perform calculations and orchestrate the overall functioning of your body, it works as an extremely fine tuned filter for extraneous stimuli. I did not realize this until I began recording audio tracks for the content that I developed.

It quickly became evident that a silent office or home space is not quiet at all. The extra sounds were simply filtered out and ignored by my brain. When I played back some of my first recordings, they were filled with sounds of breathing, air moving through the ventilation system, vehicles passing by, airplanes overhead, birds, dogs, and even far off construction noises.

I started out by hanging carpet and other materials around me to absorb the sounds. When that did not work, I moved from location to location hoping to find a quieter spot to record in. What I really found out is that each location in the building presented a different collection of background noises to filter out.

The other frustration was the variety of reverberation experienced in each location. One location was a simple room that offered little reverberation, but was subject to a great deal of background noise. Another room had a vaulted ceiling set at odd angles. Definitely not the right place to record quality audio.

After trying every room I could, I finally resigned myself to finding an alternative place to record. Unfortunately, recording studios charge from $65 to well over $100 per hour of use. That put them out when I realized that I would need many hours to record the audio.

Some heavy research helped me to decide that the best thing to do was to create my own studio. I am now sitting in a six by eight foot sound isolating room writing this blog. Building the studio was definitely not without its challenges. However, the tighter control I now have over the environment is enabling me to record much higher quality audio than I had before.

In the second installment of this blog, I will discuss the building of the studio along with some of the challenges I faced.