Wednesday, December 24, 2008

End of year

Hello everyone,

end of year is here – so merry Christmas to all of you :)

For next year I want to promise you something – I will write at least one post per week. What can you expect?

I think that Windows 7 will be very important OS release – as I mentioned few times in my posts, Windows Vista can be seen as Windows 2000 – new features, changes in MS approach etc, however still many annoyances and missing features. Windows 7 will be more like Windows XP – take already existing major release (Windows 2000), add new features and change some settings.

I really, really like Windows Vista – there are many features that I really love and are NOT obvious to normal users (MIC or I/O priorities) and I think that Windows 7 will make use of all these features.

As I am one of official MVP moderators for Windows 7, I want to share my thoughts with you and hope I’ll be able to make Windows 7 next-gen Windows XP – OS that we will happily use for years :)

You can also expect lot of posts about project I was working on called S4Matic. S4Matic is workflow framework based on PowerShell that allows you to easily automate processes. Consider scenario when new employee will come and all you need to do is to specify his name – his AD account is automatically generated, he is added to all required groups, his mailbox is generated and few emails are automatically sent (to create new badge for him for example or request for new mobile phone). This is quite simple scenario – consider more complex scenarios, for example if you have hundreds of Citrix servers and you want to reboot them during weekend without any downtime (I already implemented this). Or even better – you want to rebuild all servers during weekend without affecting any users. Sounds cool? You will see what S4Matic can do :)

Of course I want to continue with my Powershell blogging activities, I don’t like to post cool functions (there are many better bloggers for this), I prefer to write about general principles and how thinks works (or even better, what doesn’t work and why).

This blog is not only about technical stuff, so you can also expect some productivity posts – for example how versioning can improve your daily work or how to organize your drives.

And hopefully I will post some small programs and utilities :) And many many tips & tricks :)

Wednesday, December 17, 2008

What's The Difference Between Size And Size On Disk In Folder Properties

Many people don’t understand the difference between these two values:

image

 

Today I run into small blog post that describe these two values. However there is something I am still missing in Windows. We should be able to see 3 values:

Size

Size on disk

Virtual size on disk

Why is that? Because especially with Windows Vista\2008\7, softlinks and hardlinks are playing much more important role.

For example take folder WinSxS in Windows directory. If you check it’s size, you will be probably surprised that it is really big, in my case it is 10GB. Surprisingly this folder is NOT that big, because most files (or many of them) are in fact only hardlinks to existing files.

Confusing? Yes

Do you know real size of that folder? No

Same applies to my “loopback” symlink. I tried to use utility (Gladinet) that allows you to share some folders between computers. However I didn’t wanted to share only folder, I wanted to share whole C: drive (which is as far as I know not supported by that utility). So I used simple trick and created C:\Links\Loopbacks\C folder that is symlink to C:\. Worked great :) But as you can see below, that folder is really big (even though it DOESN’T occupy 75GB on my disk):

image

I think this can be pretty confusing\annoying in some situations – in my case if I would calculate size per folder, it would be at least 150GB (on my 110GB HDD) :)

Thursday, December 11, 2008

Google Zeitgeist

What I really like about internet is the fact that you can get access to real-life data sometimes. For example what is best method for identifying most popular songs of last year?

For some it can be charts - but charts are always depending on radio listeners or radio genre. Another approach can be number of sold records, however that doesn't say anything about number of listeners, for example if song is really great, however album is really bad, people won't buy album and will download MP3 instead. Not talking about fact that most people don't buy CDs anymore (IMHO) and are buying\downloading MP3s only (and I think that number of downloads is much higher than number of purchases).

So for me best method to identify hits of last year is to review numbers from Last.FM (that have millions of listeners and is not focused on single genre).

Want to know more? Have a look at Last.FM Best of 2008.

Don't interested in movies? What would be best method to see changes worldwide or in your country?

Great idea would be to base it upon search queries - especially in case of big player such as Google (that is used by different people all around the world). I blogged about Google Trends already and when I tried to play with some trends of year 2008, I discovered very interesting press page called Google Zeitgeist that already did this job. Very interesting with details about each country :)

Wednesday, December 10, 2008

LastPass - Free password manager

First of all - I was very busy with few projects, that is why I didn't post anything on this blog for long time. Situation is now better and from beginning of next year I would like to blog every week again, so keep tuned :)

Maybe you remember that I wrote about tools and utilities I am using and what am I missing. One of them was password manager and I finally found one I really like.

My requirements:

  • Online synchronization because I am using more computers
  • Support for multiple accounts for one site (typically Live ID or Gmail account)
  • Support for one account to multiple sites (again Live ID\Open ID\Gmail account)
  • Ability to have online access to accounts\passwords

2 months ago I found tool called LastPass. Major features they are promoting are online synchronization and fact that it is available for free.

From security perspective, central site DOESN'T store you password, it stores encrypted data by your master password.

There are many cool features I really like about LastPass... Because it have online synchronization, I finally started using autogenerated passwords (before I was scared what would I do in case of data loss)... You can even share sites with your friends.

So in case you are interested, head directly to LastPass homepage

Tuesday, November 18, 2008

ZoneAlarm Pro for free

You can get ZoneAlarm Pro for free today - however be careful, it is NOT full security suit as many sites are reporting, it is "only" firewall & antispyware suit (which I have no use for - both are already included in Vista by default)...

Anyway, if you find this information useful, so grab a copy while it is available ;)

Saturday, August 2, 2008

Returning values from Fuctions in PowerShell... Tricky :(

First let me explain something: I LOVE POWERSHELL...

No, I really do. After 3 years working every day with batches, vbscript & .NET I can see huge huge potential in PowerShell and more and more I use it I think it is genius shell.

However I am always trying to be skeptical about everything I do - and about every product I love.

I don't want to end up like some people that think their favorite product is PERFECT - and when there is new version, they suddenly realized that something that was PERFECT is more PERFECT ;)

 

I worked with Monad\PowerShell a lot 3 years ago, then I stopped and returned to batches (because of my work). It was quite fun and it turned out that with good imagination you can still achieve a lot with batches (script blocks, complex scopes, private variables, subroutines, functions etc ;)), however it was always just about building some workarounds. 1 month ago I returned to PowerShell and now I am working with it on daily basis - and of course I already encountered some things I don't really like. 

Working with function output

If you are familiar with programming, following code should be easy to understand for you:

Function bar {
$MyVariable = "Foo"
Return $MyVariable
}



Function bar returns MyVariable. So using $X = bar should be equivalent to $X = $MyVariable in fact.



Not in PowerShell. $X will get output from WHOLE function. That means that following function is equivalent to one above:



Function bar {
$MyVariable = "Foo"
$MyVariable
Return
}



I really, really don't like this behavior. Creating complex scripts is getting much more complicated. Consider example where you run into some problems in bar function. Most primitive debugging is always to use Echo (Write-Host) and just see value itself.



If I would have enough time, I would change it as follows:



Function bar {
$MyVariable = "Foo"
Write-Host "DEBUG: $MyVariable"
Return $MyVariable
}



Result would be as expected - if I will use $X = bar, $X will be Foo. However what if I try following:



Function bar {
$MyVariable = "Foo"
"DEBUG: $MyVariable"
Return $MyVariable
}


Looks fine? But doesn't work - $X in this case is Foo Foo and you will never see "DEBUG: Foo" output in console. I really think this is against object-oriented principle of PowerShell and it reminds me of 'For /f' behavior in batches.



You probably won't run into this problem - however you will run into it if you will start creating really complex scripts with XML handling, adding new elements etc. Usually (in .NET), if you for example add something to array, index is returned.



Look at following function. Variable $MyVariable is created, two numbers are added (1 and 2) and then it is returned:



Function bar {
[System.Collections.ArrayList]$MyVariable = @()
$MyVariable.Add("a")
$MyVariable.Add("b")
Return $MyVariable
}



Normally you would expect to get array that contains 'a' and 'b'. But because of PowerShell way of returning object, instead you will get array with 4 (!) entries: 0 1 a b.



0 and 1 in this case is index of added array elements. 



To make this function work as expected, you will need to redirect output to null:



Function bar {
[System.Collections.ArrayList]$MyVariable = @()
$MyVariable.Add("a") | Out-Null
$MyVariable.Add("b") | Out-Null
Return $MyVariable
}



Usually I try to write all my functions in following format:



Function <Name> {
<initial checks>
...
<final checks before return>
Return
}



With PowerShell this is usually not possible, because even if you check if $MyVariable is correct type with correct values etc, it is quite hard to know if something "leaked" before. 



For me ideal solution would be that PowerShell would support BOTH methods for returning:



Function bar {
$MyVariable = "Foo"
Return $MyVariable
}



Would return object $MyVariable



Function bar {
$MyVariable = "Foo"
$MyVariable
Return
}


Would return whole output from function



Friday, August 1, 2008

How to manage your small development projects??

Some of you are maybe hobby developers as I am... I am partially developing for my company and also I have few free public projects like Elevator.

There are 3 tools that I always must have when I work with my projects:

  • Subversion - used for versioning, very easy to setup and use, available for free, no need for database, integrated to shell.
  • Visual Studio - well, of course :)
  • PowerGUI - it contains very nice PowerShell script editor

If you have however some professional projects (that means projects with fixed deadline for me ;)) and you are not working for professional developer company, it can be pretty tough to keep project on track and not spend days implementing small features and tweaks. It is very important to organize your time and keep track of everything you have to do.

At beginning I was "wild" developer - that means no versioning system, all notes in txt files and backups and rollbacks implemented by copy&paste (or popular ".old", ".bak", ".backup", ".001" etc..). Of course this was long time ago.

Later on I started working with Subversion and storing my notes in Visio. Still, that was not ideal solution.

Few days ago I discovered Unfuddle webpage. Unfuddle is project that is used for hosting - it provides you with basic bug tracking system (that meets all my needs), subversion hosting, notes taking system...

And best of all - they have also free edition. In free edition you are limited to 1 project and 2 people, however still it is great way to discover Unfuddle.