May 2010 Archives

Once, once in a Blue moon you’ll run into a situation where the Hyper-V Child is “starting” and shows a stuck status of 0%.   You can’t stop it.  You can’t access it.

You’re stuck!

No.  No you’re not.  It’s an easy fix.  Just kill the VMWP.EXE associated with the Child.   But how do you tell?

Believe it or not it’s incredibly easy.  Just use Process Explorer from www.sysinternals.com

Use the Process Explorer on your problematic host to see all the VMWP.EXE processes.    When you examine the details you’ll notice that the working VMWP.EXE processes contain a reference to the Physical VHD file.   The ones that are stuck have no reference to anything. 

If you look at them in Process Explorer you will see references to files, but NONE with a reference to the configuration or the VHD data.   Those are safe to “End Process”.

Once you do that the problematic Children in Hyper-v will start.

Yes a restart will fix you, but the fact is not everybody can reboot a host Server.   Key word “Production Environment”.  Second key word “Downtime”

Your best setup involves of course a clustered setup with failover.  But in some situations you can’t do that.  Budget can be one.

Knowing you CAN patch the situation without killing the host?  Very important.

Strive for the redundancy.  But remember, recovery should always be under YOUR control

The Power is YOURS

Sean
The Energized Tech

Powershell

So we now have a Server 2008R2 core box, Powershell enabled that can easily Add/Remote Roles and Features.  Let’s make this a useful box.

One of the simpler roles you’ll typically run is the File Server so you can share files.   Using the Powershell module “ServerManager” makes adding or removing these changes very easy.  

Just execute in Powershell

IMPORT-MODULE ServerManager
ADD-WINDOWSFEATURE “File-Services”

It will require one reboot after it’s done to allow it to take foot properly

Once done you now have a potential file server.   I say “Potential” since you still have to create Shares, Files and Permissions.

Well generally once you have a Folder you can create a Share Correct?

So we’re going to place a Folder at the root of the C: Drive called “DATA”

NEW-ITEM –path C:\DATA –type directory –force

Now to create a Network share in Powershell we’re going to leverage the built in WMI libraries in Windows to create them.  WMI (Windows Management Instrumentation) allows you to not only View but manipulate many features of Windows.  

[wmiclass]”win32_share”

Is the technique you can use in Powershell to access the Keying in a

[wmiclass]”win32_share” | get-member

Will show us all the available members of this object.  There is one in particular called “Create”. 

Definition : System.Management.ManagementBaseObject Create(System.String Path, System.String Name, System.UInt32 Type, System.UInt32 MaximumAllowed, System.String Description, System.String Password, System.Management.ManagementObject#Win32_SecurityDescriptor Access)

For us non Programmers it breaks down to this.  The Create Method will take up 5 particular parameters in this order.

PATH, NAME,PermissionFlags, MaximumAllowedConnections, DescriptionOfShare,SharePassword,

Creating a share is just a matter of passing some basic information to this class.  Namely the Name of the Share, the physical location and the maximum allowed users.

So if I have a potential folder called “C:\Powershell” and I’d like to share it out to my network as “POWERSHELL” as a fileshare I just fire up this command.

([wmiclass]”win32_share”).create(“C:\Powershell”,”Powershell”,0)

Why the “0”? You don’t just have file shares.  You also have Printer shares and IPC as well.   The same command is used to create and mange them all

But just as easily, we can make this into a function to add to out Powershell profile.   Just substitute in what we need to change on a regular basis.

function global:NEW-SHARE($Location,$Name) {
    ([wmiclass]”win32_share”).Create($Location, $Name)

}

This is of course a very simple function but one we can build on later.    Like the ability to set share security and the maximum number of allowed users.  As well we should check the status of whether it was created successfully.

But that’s where Powershell is just fantastic.  We can build the tool to MEET our needs in the short term and later on add on to it.

Next time we’ll dig into some more features of Server 2008R2 Core and how we can use Powershell to manage them.  

The Power of Shell is in YOU

Sean
The Energized Tech

Powershell

Today I had something that was just BUGGING me.   Like many people I have a collection of Music.   And like many, that folder structure justs SITS for the most part unmaintained.  The only maintenance being whatever the music software did.

I started going through the pile and found I had a series of folders that no longer contained MP3 files (I deleted it from the collection at one point with the supplied software).  However it left behind .INI, Thumbs.DB or .JPG files

Well I wasn’t worried about the JPG files in the music folder collection since most of the time they would redownload from the source site.  So I decided to get thiings clearned up ONCE and FOR ALL without spending $$$.

So I used Powershell :)

GET-CHILDITEM FolderName –recurse –include *.EXT | REMOVE-ITEM

Will easily remove all offending items (like say .TMP files?) but certain file types are automatically hidden by the O/S.  Rather than editing my default folder settings globally, I can tack on a –force which “FORCES” the Commandlet to show me everything.

So phase one.  REmove all those .JPG files in the Music Collection.

GET-CHILDITEM C:\Music –recurse –include *.jpg,Desktop.ini,thumbs.db –force

Once I could see it was pulling up what I wanted successfully I patched on REMOVE-ITEM.  Now since I trust MYSELF but NOT “Murphy’s Law” I tacked on a –whatif just to be safe.  Also since many of the items I was going to removewere hidden, I have to tack on an additional –force to make sure REMOVE-ITEM is allowed to see them. 

If you don’t, you will get an error about lack of access, security denied, cows falling from the sky, blah blah blah….

GET-CHILDITEM C:\Music –recurse –include *.jpg,Desktop.ini,thumbs.db –force | REMOVE-ITEM –force -whatif

So now once I can see it will remove all the correct data I remove the –whatif and the let the command do it’s work in Powershell.  Now a new problem surfaces.  I have folders that are now empty wasting space.

Again in Powershell this is not a problem.  For within the Objects for Filesystem are Methods to see how many files OR Directories are within a folder.  So by adding in a .GETFILES().COUNT or GETDIRECTORIES().COUNT to a particular object I can see, literally if it’s empty!

So I make second script than can remove the dead folders

GET-CHILDITEM C:\Music –recurse –force | where { $_.PSISContainer } | foreach { IF { $_.Getfiles().Count –eq 0 –and $_.GetDirectories.Count –eq 0) { REMOVE-ITEM $_ }}

Now the tricky part.   Since we know each time we clean this up, we may have NEW empty folders.  so we’ll have to repeat this process until we have no empty ones.  So we’ll need to add in a counter to track how many empty folders.  So at this point, let’s just make a script so it’s all viewable and clean.

--------------- Begin Cleanup Script ------------------------------

Do {

# Get of all the directories in the Target tree, ONLY the Directories

$LIST=GET-CHILDITEM C:\Music –recurse –force | where { $_.PSISContainer }

# We Flag the $DONE variable.  If even ONE folder is removed (Empty)
# It will flag as $FALSE

$DONE=$TRUE

foreach ($Directory in $LIST) {

# Check the count of folders and Directories in THIS directory
# If it’s a total of 0 for both, we remove the directory and flag at least ONE $FALSE
#
# If no Blank folders ever get found, $DONE will be $TRUE and the loop will exit
#

IF { $Directory.Getfiles().Count –eq 0 –and $Directory.GetDirectories.Count –eq 0)
     { REMOVE-ITEM $Directory
     $DONE=$FALSE
}
}

} until ($DONE –eq $TRUE)

----------------- End Cleanup Script ------------------------------

So now what do we have?  A simple way to go through a list of folders and purge blanks.  You could tweak this script any way that suits you as well,  tacking in Date/Time filters.  Even prompting where to start.

Remember, the Power of Shell is in YOU

Sean
the Energized Tech

Powershell

Now I just realized something.   I was just about to go on about how to setup Core as s File server and something hit me.

I’ve been mentioning OCSETUP and OCLIST as the ways to determine and add features to your Core box.   But I neglected to mention you can also do this in Powershell.

In order to do this you DO have to add a feature to your Core box called “ServerManager-PSH-Cmdlets”.  So within Powershell execute a

START-PROCESS –wait ocsetup “ServerManager-PSH-Cmdlets”

That is the command required in Powershell to add this in to your Core features.  Once done you’ll have a small but powerful list of Commandlets added to your repertoire.

Execute an

IMPORT-MODULE ServerManager

and you’ll soon have access to these new commandlets

ADD-WindowsFeature
GET-WindowsFeature
REMOVE-WindowsFeature

The names are wonderfully obvious as to what they will do.   Where I find this is a win over OCSETUP is I can have a much cleaner list about what is already installed by executing an

GET-WINDOWSFEATURE | where { $_.Installed –eq $TRUE }

Oclist (at least to my knowledge) does NOT have this ability.   I can also easily search for types of features available on CORE, such as adding in ASP to a Web Core Server.

GET-WINDOWSFEATURE *ASP*

Will show me all features where “ASP” is part of the feature name or Description.  No more digging!

If I have decided to remove all features that are based on IIS I could do this

GET-WINDOWSFEATURE *IIS* | REMOVE-WINDOWSFEATURE

And like every command that will remove something I can even tack on a –WHATIF to see what WILL happen when I execute this command.

But of course just as easily, I can say “Add in all the features tied to Active Directory” with a

GET-WINDOWSFEATURE AD* | ADD-WINDOWSFEATURE

What I did find ironic (and irritating) is it WON’T let me add/remove features from Powershell (Like additional modules).

I can understand that since potentially you’re disrupting the very base from which you’re doing the adding and removing, but it still irritates me :P

NOW next time we’ll look at that Easy to deploy and Secure File Server on Core

The Power of Shell is in YOU

Sean
The Energized Tech

A part of my life passed on today.   A huge rock hero I followed for a very long time.

Ronnie James Dio.

Did I know him?  No.  But like many fans his music carried us through it all.

“Dio” was talented beyond the years.   Many people just remember him from days as a Solo artist and with Black Sabbath.

Understatement of the day.  Ronnie James Dio was involved with Rainbow in the 70’s, Elf in the 60’s.

One thing can always be stated (for me at least) listening to the music of Dio.   It was truly epic. 

A Dio tune was NOT just “Guitars and Drums and Screaming".  Dio wrote songs that were stories both dark and mysterious and in many ways mystical like a good Tolkien novel.    The Chords, Lyrics and Chorus would weave together into an unforgettable Medley.

Was his music “Evil” ?  No.  It was like a good Alice Cooper song.  It was an experience.   It was something to let you release your frustrations as a teenager harmlessly while at the same time become carried away with his more mellow music.

Ronnie James Dio, you will be missed by many of us.

Where you pass to only you know.

But we; the Lost Children of the Sea, will never forget you.   You ARE a Star now amongst the Stars.

Here’s something to put in your hat and a truly solid reason to get Sharepoint 2010 or even just try Skydrive.live.com

It’s called WebApps.

Imagine having a VERY functional version of Office applications on your PC WITHOUT having to physically install it?

Imagine a way to truly control the costs in your office.  

Webapps is part of Sharepoint 2010 and something that’s becominig available in Skydrive, Microsoft’s free web based 25 gig storage account.

Want to try it?

Go to http://skydrive.live.com and get a free account.  Then upload something like a simple Excel spreadsheet or Powerpoint presentation on there.

 

You’ll notice this button “EDIT”

image

Click on it, read the agreement and accept.

Without having EXCEL on your computer, you now have a way to edit that spreadsheet.  Free.   It’s not as full featured as FULL Excel 2007 or Excel 2010 but you can edit cells, manipulate data.   It will even link to the Full version if you have it.

Although not as Powerful as it’s bigger cousin, it DOES provide a nice way for all those people that want Excel on their computer but really only need it to view and do minor edits.

 

Presently there are versions for Powerpoint and Excel online now and the list is growing.

Curious and want to know more?  Check out this link on Microsoft for further details about WebAppsOr check out the Blog on Microsoft about WebApps. 

 

I strongly encourage to see just what YOU can leverage them to make both yourself and your staff more productive.

Sean
The Energized Tech

Powershell

Here’s a trick I stumbled across.   Converting Environment variables (%SOMENAME%) in Powershell.

Now every Powershell person knows that using $ENV:VariableName (without the % before and after) will reveal that variable.   Very simple.

But what if it’s embedded in a path?  How about TWO or THREE?

Now I COULD figure out some Ultra cool “Convert O Matic” function or I could leverage some already existing technology.  Creating fresh is better but today, I don’t have the time.  Much like many of us.

So I was thinking “Gee, If I could somehow use the ECHO command in CMD.EXE it would work, even if it’s just to get this working”

Well you can.  Microsoft didn’t lock you out with Powershell, they gave you another TOOL to use and leverage how YOU need to use it.

CMD.EXE (and any other executable) can still be launched in Powershell.  It’s output can be captured and parsed afterwards as well.  As an added bonus, the Powershell interface will even pass it’s OWN $Variables to NON Powershell applications (Provided the content is what the application is expecting).  You can also leverage other applications like Robocopy.exe and pass Powershell $variables to them (Again, as long as the content is what they are expecting)

So keying in

CMD.EXE /?

Showed me all the parameters I needed.   I found a /C which launches a command and returns when done.

So a simple

$VariableForDos=”%SYSTEMROOT%\System32\drivers\etc”

CMD.EXE /C “ECHO $VariableForDos”

Will echo back

C:\Windows\System32\Drivers\etc

If I’d like this as an easy to use function

Function global:GET-DOSVARIABLE($Convert) {

$RESULTS=CMD.EXE /C “ECHO $Convert”
RETURN $RESULTS

}


The nice part is if you create this is a function, is if you DO find a more elegant solution you only need re-write the function, not your entire Shell Script.

So what does this show us?  a Few things. 

I can pass $Powershell variables to a non Powershell executable (CMD.EXE) and I can leverage and use IT’S resources rather than rebuilding them in Powershell.  

I can also use some bulit in older technology to my advantage as an Administrator.  I am not tied down to building it all from scratch in Powershell.

After all, isn’t that what it’s all about?  Making things EASIER?

The Power of Shell is in YOU

Sean
The Energized Tech
www.Powershell.ca

A good friend of mine is doing something I couldn’t imagine any human doing.  He’s riding over 200 miles on a BICYCLE to help raise money to conquer cancer.

TWO HUNDRED MILES.  The first time I heard that number I stared in disbelief.  The words “IMPOSSIBLE” left my mouth.   Over 200 miles in barely a weekend.  A HUMAN on a BICYCLE.

a Mere Mortal

For more details on THAT major endeavour go to http://www.conquercancer.ca/goto/rbuike

I’m certain Rodney thought that too.  You have to.  When we are faced with a challenge that SEEMS insurmountable and unstoppable we ALL say that. “Oh NO!  I’ll never do this!”

But then you set down that road.  “Just Cuz!” is sometimes the reason we do it.  Sometimes the reason we don’t stop is “I’ll be embarassed” or “I can’t let people down”

Maybe even as simple as “I can’t let myself down.”

then something happens.   That effort begins to reward, internally, sometimes physically, sometimes socially.  Very often in ways that just can be foreseen by ANYBODY.

But often positive results in some way.

For my friend Rodney, he lost weight, took on a new vigour on life I don’t he ever foresaw.   Became more than he ever thought.

So can you.  

Take up something, something hard.  Take the challenge.  Try (maybe fail) and try AGAIN.  But never give up. 

Those rewards will be yours.

For my friend Rodney, others touched by his effort will be rewarded beyond years.   His effort has inspired others (like myself) to TAKE that chance and try for a difference in our own ways.   It’s infectious in the most wonderful of ways.

So raise a toast.  For those that try to make a change, each and every day.

Please check out http://www.conquercancer.ca/goto/rbuike and help out in YOUR way.  No matter HOW small and make a difference.

Even if it is to go down and cheer Rodney on.  It’ll make his day

Powershell

So today, let’s talk a look at add in Roles and Features to our new Server 2008R2 Core box.

Enabling any Role in CORE requires the knowledge of at least THREE Commands.

 

OCLIST, OCSETUP and NOTEPAD

 

I can hear people giggling about “NOTEPAD”.  But when you see WHY it will make so much sense.

OCSETUP is the command you use to ADD IN those features to the server.  the format of the command is OCSETUP “NameOfFeatureYouareTrying2Use”.

Personally when I use OCSETUP I launch it like this

START /W OCSETUP “NameOfFeatureYouareTrying2Use”

This is because there is NO status bar when you’re adding in a Role or feature.  Remember this is CORE.  It’s what you NEED not what you WANT.  

You NEED to know when the setup is done, you WANT a status bar.   Launching OCSETUP with a START /W will not return you the command prompt until that process finishes.   In that way the NEED is filled.  You can tell when it’s done installing.

This also makes the process scriptable and repeatable for multiple servers.

OCLIST is the command that lists all of the Roles and Features available to you.  Just like Server Manager.  The names are Case Sensitive.  THIS IS INCREDIBLY IMPORTANT TO REMEMBER!

A role called “SomeSillyRole” is completely different from “somesillyrole”.  If you’re trying to figure out why the new role or feature says “I’m not available”; it’s usually like the same mistake I initially made.

It’s all Case sensitive.  Type it EXACTLY the way you see it.

Now here’s where NOTEPAD comes in.

My little trick (since it’s a HUGE list on the screen that OCLIST will produce, TRUST ME) is this.

OCLIST > C:\FEATURES.TXT

And then I use NOTEPAD to peruse that file to get the exact spelling of the features and roles or more specifically what roles I have to work with.

See? Not so silly.

So if we wanted to add in the Feature “Telnet” to a Server core box to allow you to Telnet TO other boxes you would type in

START /W “TelnetClient”

That’s it! Easy!

Next time we’ll look into setting up Server 2008R2 Core as a File Server.

Sean
The Energized Tech

Powershell

 

A little over two years ago Microsoft released a Great new technology.  Core.  Server 2008 in Core mode.  No Gui, no MMC, No Solitaire.  Just what we REALLY needed.  Bare Metal.  Power without the fluff.

One problem.  It was a pain to setup.  

In the quest to create a truly secure O/S, EASY basic management was forgotten.   Users and Administrators got angry.

Microsoft listened.

With the Advent of Server 2008R2, the new core is SEAMLESS.  It’s still clean and stripped down but now has TWO major addons that make setup ready to go.

The first is simple VBscript based system called SCONFIG.   SCONFIG is a simple but useful menu system to enable the most basic tasks on a Core box to eliminate Administration headaches.  The ability to Name it, Join Domain, Configure Remote Management.

The important stuff.

It also incorporated the ONE feature that SHOULD have been placed into Server 2008 CORE, POWERSHELL.

Powershell is the Management Shell somebody up there overlooked.   That oversight has been corrected.   

What we will attempt to cover in this small series of Blog Posts, is how to ENABLE and MANAGE various roles directly on Server 2008R2 Core with Powershell.

There are many others who will touch on how to setup a Server 2008R2 Core box, but for me; I’m more concerned on how do I MANAGE and CONTROL what I have if I can’t have the MMC GUI console.

I’m going to try and help YOU so that if you are thinking of Server 2008R2 Core for just security reasons, you should understand that Management is not an afterthought and your Administrators can work with it easily.

So let’s take a look a Core, because although it is truly HARD CORE there’s nothing “HARD” about it.

Sean
The Energized Tech

Powershell

Well It’s not OFTEN I get to play with Powershell in SQL Server and I had an opportunity today.

I had to check on what Recovery Model a database was setup as.  There’s usually three, Simple, Full and Bulk-Logged.

I am not an SQL Server expert so I won’t go into the big details about what each model offers or compare the advantages and disadvantages of each.  Not my forte. 

This is just a simple one.  How do you QUICKLY tell what Recovery model is the database setup to use?

Within Powershell in SQL Server 2008 it’s a one liner.

GET-ITEM SQLSERVER:\SQL\SERVERNAME\INSTANCENAME\Databases\DatabaseName | SELECT-OBJECT Recovery Model

That’s it!  Nothing more to it than that.  If you need to change this setting, in THEORY Powershell should be able to just “DO IT” but I recommend using ESTABLISHED METHODS when changing that SQL Database. 

For that Scenario just execute a T-SQL script like this

ALTER DATABASE Databasename

SET RECOVERY RecoveryModelType

(Where the RecoveryModelType is FULL, SIMPLE or BULK-LOGGED)

Cheers, The Power of Shell is in YOU

Sean
The Energized Tech

Here I am…

Sitting in my kitchen working on a little this and a little that and Two words are pounding at the back of my head.

“Techdays”

Microsoft Techdays 2010 for those of you who are not aware is a conference held by Microsoft right here in Canada at various KEY Canadian cities.   It is a conference that is targeted to YOU, to the technology and the knowledge YOU need know.    More details will follow on this blog later and www.techdays.ca .  Upcoming dates for the Canadian tour can be seen hear in the short term from a Posting from John Oxley of Microsoft Canada.

Each year Microsoft Canada has done the Techdays conference they have strived to listen to the feedback of attendees to shape the conference and expand it more across this great nation of ours.

This year, they have added EDMONTON to the list.  So EIGHT, count them EIGHT key Canadian cities will have this conference making more accessible than imagined!

Vancouver Convetion Centre SCC logo image

Vancouver
September 14-15
Vancouver Convention Centre

Edmonton
October 5-6
Shaw Conference Centre

Toronto
October 27-28
Metro Toronto Convention Centre

Winnipeg
December 7-8
Winnipeg Convention Centre
       
World Trade and Convention Centre Halifax image image image

Halifax
November 2-3
World Trade & Convention Centre

Ottawa
November 9-10
Hampton Inn & Conference Centre

Montreal
November 23-24
Palais de Congres


Calgary
December 14-15
Calgary Stampede

 

Right now, as we speak they are gearing up all pulling together the content that is relevant to YOU and YOUR day to day tasks in the field.   Pricing is at $699.99 for the complete conference BUT there WILL be Early bird pricing of $349.99!

Seize the opportunity.   A conference not only geared to YOU but the IT Community local to YOU.   Network with others, find answers, get training.

Heck take two days to yourself.

Techdays 2010.  It’s arriving YOUR way :)

Sean
The Energized Tech