Archive for the ‘IT Pro’ Category

Using Windows PowerShell as an IT Pro – Part 14

Wednesday, 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.

Share

More Windows 7 Tips and Tricks

Monday, 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.

Share

Windows 7 Windows Key Shortcuts

Monday, 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

Share

Data-tier Applications

Thursday, 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.

Share

SQL Server Utility: Managing Multiple SQL Server Instances

Thursday, 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.

Share

Using Windows PowerShell as an IT Pro – Part 13

Monday, 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.

Share

Using Windows PowerShell as an IT Pro – Part 12

Friday, March 19th, 2010

In my last post I began looking at variables. Now I will go over types and how they function.
Windows PowerShell supports a number of different types such as strings, integers, arrays, etc. You can explicitly specify a type or allow Windows PowerShell to do it dynamically, which is sometimes referred to as automatic type conversion. Type conversions are used when an object of one type is assigned a value that requires another type (such as adding a string to a number). This conversion happens automatically as long as the type was not specified manually, and it is not destructive to the original object.
For example we can assign a new value to the $Loc variable which currently has the System.Management.Automation.PathInfo type, and then use the GetType method to show its new type.
$Loc = "Test"
$Loc.GetType().FullName

Then, assign it a numeric value and check the type again.
$Loc = 3
$Loc.GetType().FullName

$Loc was made an Int32 because the value wasn’t enclosed in quotes and because the value was composed solely of digits. Had it been in quotes, it would have been interpreted as a System.String.
In both cases, Windows PowerShell determined the data type that was the most appropriate for the value of the variable. This should work for most variables but there may be situations where you want the variable type to remain as it is. Suppose you are reading values out of a file and you always want the values to be treated as strings. Some of the values, however, might contain only digits, raising the possibility that Windows PowerShell would treat them as Int32 or another numeric type, which may create problems for your script. If Windows PowerShell does not recognize the value as a string, then all the methods of the System.String class are not available (and your script might rely on one of these unavailable methods).
Manually assigning a type is simple and is done when you create it. Assigning a string to a variable essentially forces the variable to be of the System.String class. Assigning a number to a variable, on the other hand, usually results in the variable becoming an Integer (or, more specifically, an Int32, which can store a specific range of values). For example, we can create a new variable and define it as a string.
[String]$var = 5
$Var.GetType().FullName

Normally, $Var would have been an Int32, but because we defined it as a String, it makes the numeric value we assigned to it a string.
Forcibly declaring variables does have repercussions, though they are not necessarily bad. In the next example, a new variable is created, defined as an integer, and assigned a numeric value. Then, it is assigned a string value.
[Int]$Num = 4
$Num = "test"

As shown above, when we tried to assign a string value to it, an error message was displayed. Because $Num was defined as a Int32, Windows PowerShell expected to convert the string “test” into an integer value. It was unable to do this, nor was it able to change the type of $Num to String.
In my next post we continue to look at types.

Share

Using Windows PowerShell as an IT Pro – Part 11

Tuesday, March 16th, 2010

In my last post I reviewed the Out-Gridview cmdlet. Now I will look at variables.
Windows PowerShell lets you create variables – essentially named objects – to preserve output for later use. The Windows PowerShell variables are actually mapped to underlying classes in the Microsoft® .NET Framework. In the Framework, variables are objects, meaning they can store data and also manipulate it in many ways.
Variables are always specified with the initial character $ and can include a mix of letters, numbers, symbols, or even spaces. However, if spaces are used, the variable needs to be enclosed in braces, such as: ${My Variable} = “Hello”). Variables are created by typing a valid variable name or assigning a value to it. A variable name should help you remember what it contains, using a simple, straight-forward name.
$Loc = Get-Location

Output is not displayed when this command is entered, because the output is sent to $Loc. In Windows PowerShell, displayed output is a side effect of the fact that data which is not otherwise directed always gets sent to the screen. Typing $Loc shows its value, which in this case is the current location.
$Loc

Get-Member is used to display information about the contents of variables. Get-Member enumerates the properties and methods of that object type. Piping $Loc to Get-Member shows that it is a PathInfo object, just like the output from Get-Location.
$Loc | Get-Member

There is also a default variable that can be used for certain situations. The $_ acts a placeholder for the current object. This can be used to access the properties or methods of the current object in a command. For example we can use $_ to help filter the output of the Get-Service cmdlet, displaying only services that have a status of Running.
Get-Service | where {$_.status -eq "Running"}

In my next post we continue to look at variables and types.

Share

Exchange Server 2010: Personal Archives

Saturday, March 6th, 2010

Exchange Server 2010 has several features to help manage the storage and retention of e-mail messages. One of the cool new features is called the Personal Archive, replacing the need for individual users to manage Microsoft Outlook PST files on their local computers. In essence, the Personal Archive feature provides users with a separate archive mailbox stored on the Exchange server and i accessible using Outlook 2010 and OWA.

The Personal Archive mailbox is created on a per user basis and can be enabled for both new mailboxes and for existing mailboxes. For new mailboxes, you will create the user’s mailbox using the New Mailbox wizard. When you get to the Archive Settings page, select Create an archive mailbox for this account. To enable the archive mailbox for an existing mailbox, find the mailbox in the Exchange Management Console (Recipient Configuration | Mailbox), and then click Enable Archive in the Actions pane. Mailbox items will then be moved automatically from the primary user mailbox to the archive based on the retention policy settings.

When you install Exchange Server 2010, it automatically creates a default archive policy and three personal archive policies available to the users. The default policy directs any messages that are more than two years old to be automatically moved to the archive mailbox. After the Exchange Mailbox Assistants run on the user mailbox and processes all messages against this default archive policy, the user can then select one of the other three policies for individual folders in their mailbox structure. These three personal policies allow messages to be archived after 1 year, after 5 years, or marks the folder as to never be archived.

The Personal Archive mailbox is stored in the same database as the user’s primary mailbox and will follow the primary mailbox if it is moved from one database to another.

Share

It’s Part of SQL Server 2008 R2?

Friday, March 5th, 2010

SQL Server 2008 R2 includes some impressive new features and functions. But, when you run setup they are nowhere to be found. Included in the list are the new StreamInsight, PowerPivot (sort of), and Master Data Services. Where are these features and why are they not included in the setup wizard?

Except for PowerPivot for SharePoint, the features are in their own distribution folders on the setup DVD. StreamInsight is in the StreamInsight folder and Master Data Services is in the MasterDataServices folder. PowerPivot for SharePoint is actually included in the setup wizard, but you need to know where to look. More on that later.

To answer the question as to why StreamInsight and Master Data Services are not part of the setup we need to look at the big picture as Microsoft defines it. Microsoft has decided to migrate all data management and analysis applications under a single umbrella and that umbrella is their flagship database, SQL Server 2008 R2. This is much like what they are doing with SharePoint by including PerformancePoint as a feature beginning with SharePoint 2010.

The thinking is that creating a comprehensive data management suite is simpler if the components are marketed as a single platform. Not only does this make sense logistically, it makes sense financially. Instead of socking companies with more fees as they continue to build their data management infrastructure, Microsoft has rolled many of their previous offerings into the SQL Server 2008 R2 platform. Companies now benefit financially by no longer being required to fork out thousands of dollars for each of the features that they want to implement. Rather than forking out thousands of dollars for each application, they can purchase the appropriate edition of SQL Server and find everything they need.

I mention this because StreamInsight, in particular, is not a SQL Server based product. StreamInsight sits outside of the SQL Server resource pool and performs Complex Event Processing on incoming data streams. Designed to handled massive volumes of data in memory, StreamInsight enables a company to create processes that scan the incoming data streams and discard or redirect the data based criteria written in a .NET compliant language and using LINQ.

StreamInsight can use SQL Server based data tables to hold static data used for comparison purposes. It can also pass selected data through and ouput adapter to SQL Server for storage. Because StreamInsight runs against memory based data, it can process the queries without the I/O overhead required by a traditional database server.

Master Data Services is another application included with SQL Server 2008 R2. Master Data Services does store data in SQL Server. However, the processing it does is not a pure database or data warehouse function. Master Data Services (MDS) enables and organization to gather multiple copies of significant master data together, merge and standardize the data, and then send it back out the original applications. Those applications then contain a consistent and accurate representation of the common data. A previous blog contains a more detailed discussion of what constitutes master data so I will not go into that here.

Finally, we have the new PowerPivot for SharePoint. PowerPivot for SharePoint is a new addition to SQL Server Analysis Services in SQL Server 2008 R2. Microsoft created the SharePoint add-in to enable users to create, share, and manipulate PowerPivot workbooks in concert with PowerPivot for Excel 2010. The only way to install PowerPivot for SharePoint is to perform a SQL Server Analysis Services installation with SharePoint integration. After selecting SharePoint integration, the wizard walks through the essential configuration tasks for PowerPivot. A standard Analysis Services installation does not include PowerPivot. For a more in depth discussion of PowerPivot for SharePoint and PowerPivot for Excel please see my previous blogs.

By combining all of these features into SQL Server 2008 R2, Microsoft is proving even more that they are committed to improving the way businesses handle data without requiring excessive investments. I am sure that there is even more to come and that the next release of SQL Server will continue this trend of managing data where ever it is so that companies can continue to gain ground in managing and analyzing business critical data.

Share