Changing blog provider, please update you RSS ;)

Heya,


maybe you are old school reader of my blogs and you remember when I moved to msmvps.com from blogdrive.com (it didn’t support RSS feeds). Now it is time to leave msmvps.com and select new blog provider (if you tried to reach this blog in last 4 days, you know why ;)).


Few weeks ago I run into issue with embedding HTML code that contains flash (Jing videos) – this is not possible due to community server configuration. I started to think about moving to different blog provider – ideally big one that is being often updated and is keeping up to date.


Few days ago msmvps.com stopped working – and it was not available till today, without giving any reasons why and when it will be available again.


So I decided it is time to move my blog to new location. For various reasons I decided for Blogger.com.


So if you like my blog and you want to follow my (professional only) life path, change your registration to http://martinzugec.blogspot.com/


 Martin

Create file with specified size

Yesterday I run into very strange problem with one of my friends – Echo. stopped working.


 In batch scripts, you use Echo to output something to screen – and of course you can redirect it to file.


By using Echo. (mind the dot), you specify that you want to output empty line. So if you want to create empty file from batch, you can use Echo. > c:\Temp\Empty.txt


Yesterday one script stopped working – Echo. was not working. It was working for everything else (including log files etc), just not for creating files in one folder. I have absolutely NO IDEA how that was possible (and if someone does, share any ideas, I am very curious about this one).


I remembered of less known feature from FSUtil – FSUtil can create for you empty file with predefined size. And it worked:


FSUtil File CreateNew C:\Temp\Empty.txt 0


In my case I used it only as alternative method because Echo. failed, however it can be useful if you want to benchmark performance or do something similar.


For example if I want to create 10 files with 10GB size, I would run following command:


for /l %i IN (1,1,5) Do FSutil File CreateNew C:\Temp\PerfTest\Test%i 1073741824


This would create 5 files with 10GB size. What I like about it that all files are created within miliseconds.

Powershelling again – day 1

I haven’t seen PowerShell for last 2 years, so I was pretty curious what will be my learning curve now – if it will be like riding bicycle (once you know it, you will never forget it) or if I will spend countless number of sleepless hours trying to copy one file.

Well, I was surprised how easy it was to start using PS… I decided that I will try to do everything from PowerShell today – not only some manipulation with files, but also reading emails, replying to messages or listening to music… When I say everything, I really mean it :D And it was not always easy ;)

At first I checked few sources I remembered – first Mow’s excellent blog, but also PowerShell Analyzer and tons of other great resources (of course all blogs from MS PS team)… BTW I can highly recommend Top 10 tips for using Windows PowerShell at WindowsDevCenter, basic stuff there, but you can refresh your memory really quickly.

 

Getting help

I was able to remember how to use PS almost immediately (Jeffrey, if you are reading this, you have done GREAT job on PowerShell, it is very easy to use once you remember few rules). Of course I forgot some bits, but after implementing MSDN (and Google ;)) function on System.Object (as described by Jeffrey 2 years ago) and installing PowerTab from Mow, I had all I needed. Function Get-Member (my favorite cmdlet in PowerShell) was my best friend again ;)

BTW if you want to have also Google option, use following snippet in type definition:

      <ScriptMethod>
        <Name>Google</Name>
        <Script>
        if (($global:IE -eq $null) -or ($global:IE.HWND -eq $null))
        {   $global:IE = new-object -ComObject InternetExplorer.Application
        }
        $global:IE.Navigate2(“http://www.google.com/search?hl=en” + [Char]38 + “q=” + $this.GetType().FullName)
        $global:IE.Visible = $TRUE
        </Script>
      </ScriptMethod>

 

First command

But of course I started with Hello World – and because Hello World is too easy in PS, I tried something more complex:

image

BTW I did the code right on first try – but because (due to small experiment I tried before) .NET itself for corrupted, form only blinked and disappeared, so I spend lot of time trying to figure out why it doesn’t work (BTW Mow, if you read it, it would be nice if PowerTab could support Enums, I remembered that 5 = Fill only by accident ;))

 

Oops, mail arrived

While playing with Hello World new email arrived – so I tried to read it – and it was not that easy ;)

After few trial\error tests I came up will really dirty one-liner (of course it will be slow, but I just wanted to see that email without opening Outlook and then just kill Outlook.exe):

$(New-Object -ComObject Outlook.Application).GetNamespace(“MAPI”).GetDefaultFolder(“olFolderInbox”).Items | Where {$_.Unread -eq $True} | Select Body | Format-List

As I said, this is definitely not something I should be proud of, but it was working ;)

image

 

Messenger message

Later on I received message (Live Messenger) from  my girlfriend… I spend some time trying to somehow manage messenger from PS, but no luck :( When I saw that window is really blinking and it is obvious that I am behind computer not replying to her messenger, I left PS and replied – I gave up the fight with COM interface of Messenger ;)

image 

PowerShell Community Extensions

Before running powershell I installed PSCX from CodePlex (http://www.codeplex.com/PowerShellCX) – they are different extensions for PowerShell, some of them are very nice, some of them are not and I already found few problems (especially in CD function, but I didn’t really have time to debug and fix it yet). What is really nice that (as far as I see) 2 providers are added – AD and Feeds.

I am thinking about writing some providers for myself, just to test that functionality.

PSCX is nice project, however I think I will really need to have a look and remove stuff I don’t want (it slows down PS quite a lot and I already encountered few problems).

 

SysInternals

Later that day I run into problem when one of my files was locked by something – I wanted to use Handle from SysInternals, but then I figured out that I don’t have it locally yet. At first I thought I will try to download that file using PS, but then I realized that SysInternals recently went Live (most sites reported that http://live.sysinternals.com/ is live – it is just web page. More interesting is file://\\live.sysinternals.com ;)).

So I tried to access it directly (cd \\live.sysinternals.com\Tools), however without luck – there is problem in CD.ps1 from PSCX. I wanted to remove CD.ps1, but then I realized I can map it as PSDrive…

I tried New-PSDrive -Name SysInternals -PSProvider FileSystem -Root \\live.sysinternals.com\Toolsand it worked like a charm :) So now I can simply use cd SysInternals:

 

PowerShellPlus

I think PowerShell is extremely cool – and I think biggest drawback is still cmd host… I spent some time (few months ago) searching for some replacements, however there are none (tools like Console etc are not really what I am looking for). For powershell I remembered I was using PowerShell Analyzer as beta tester, so I downloaded PowerShellPlus (currently in beta) from same author and I am veeeeery very happy :)

Only thing I am missing is global shortcut for Mini-Mode, otherwise it is perfect (and free for non-commercial use).

image

You will also get nice Code Editor with it:

image

Well, that was my first day with PowerShell after 2 years :) From now on I can start using it on daily basis and I am really glad I can finally forget about all batch scripts – it was fun sometimes, but I can finally leave DOS past behind and focus on .NET future :)

Some changes to this blog…

Some time ago I mentioned that with new Desktop PC I will post more and more on this blog… If you have a look at posts numbers, you can see that it really happened :)

This month I joined company Login Consultants and I really love my new job :) One of advantages is that I am now consultant – which means I could focus on my blog again and post new and new stuff here ;)

 

Another advantage I can see is that I can finally return to PowerShell after years (and now I need to learn it again ;)).

 

Just wanted to let you know that in near future you can expect more posts about PowerShell and all SBC (Citrix, TS, Softgrid…) related topics

 

Martin

iPhone or Windows Mobile?

After Linux-mania we can see that Mac-mania is starting (in my opinion Apple could have bigger success than Linux due to marketing)…

Few years ago everyone was buying iPods – even I bought one for my girlfriend. I really loved iPod itself, but I was never able to get used to iTunes, especially not after I gave a try to Windows Media Player 11 and XBMC ;) For MP3s I used my PDA, old Dell Axim (first version) – it had one huge advantage compared to other MP3 players, enter button was bigger, so when I bound it to Skip song button in WMP, I was able to switch to next song by simply hitting my pocket.

Right now everyone is buying iPhones – but I am still conservative and keep my WM6 device. There are 2 reasons for me:

  • I am still not really used to touch screens, I am faster with keyboard
  • my favorite and most commonly used feature from WM6 is missing

You ask which feature? Most of the time I am

  • calling someone
  • sending messages
  • searching emails

For calls and sms messages I first need to find person – and this is for me field where WM6 is still superior. For searching through address book WM6 is using T9, which is extremely fast if you get used to it.

For example if I would like to call my girlfriend (Iwy Janeckova entry), I can simply press either 499 (4=i, 9=w, 9=y) or 5263 (5=j, 2=a, 6=n, 3=e)… Also if I am not sure if I should use “v” or “w”, I can use 1 (which acts as *). So I could achieve same result witt 4*9 (i, *, y)…

This is really killing feature for me – hope so that either WM will become competitor of iPhone in rest of categories (WM7 maybe, but it’s going to be TOUGH challenge) or iPhone will implement something similar for searching (which is more probable)…

 

Well, I missed searching emails bit – T9 is also implemented there and most people are not aware of this… Most of the time if I want to get email I am searching for I need to type only 3-4 numbers. I wish something similar could be implemented also for desktop Outlook ;)

Martin

"Enter email to register" solution

Sometimes I figure out that solution for some problem I am using is not very common between rest of world, so I will try to share such tricks.

One of them is how do I handle websites that require email address for registration. My favorite way to solve it is to use MailExpire – you simply specify your (real) mail address, when you want to expire temporary mail and that’s all.

For specified time period everything that is send to that mail address (for example turziosior@farifluset.mailexpire.com) is redirected to your real mailbox. You can change expiration if you want or immediately kill that mail when it is no longer needed.

 

Martin

Which symlinks are supported in Windows Vista and how to configure them

I would like to write comprehensive article about symlinks\hardlinks\junctions\reparse points and mount points in future – however that topic is so complex, that I would need to spend few days just to prepare materials etc for this…

So for now all I want to tell you is that symlinks were supported by Windows since Windows 2000 – implementation was done through “reparse points”, which is something like special tag on NTFS object that allows special FS filter to process them. Biggest limitations were that explorer was not able to handle them correctly (well, it was not able to delete junction, it deleted also target) and only L2L (local to local) symlinks were supported.

In Windows Vista, symlinks are implemented as new NTFS object – so major change is NOT introduction of concept, but rather possibilities and different implementation.

Major difference is that Vista supports all 4 common scenarios:

I don’t have (yet) experiences with R2L and R2R, however I really love L2L (which is possible also in w2k and wxp) and L2R (which is something new, but I love that functionality).

If (for any reason) you want to disable particular scenario, you can use FSUtil .

Syntax is FSUtil Behavior Set SymlinkEvaluation followed by symlink type (L2L etc) and status.

For example if I want to disable R2L and R2R, syntax is FSUtil Behavior Set SymlinkEvaluation R2L:0 R2R:0

image

Which tools\utilities I use

Well, some people use their blog as reminder – I am one of them ;)


It is loooooooong time ago since I wanted to replaced everything in Windows and I modded everything possible and even impossible – currently I prefer mostly built-in utilities, I don’t even have FireFox… However there are some utilities that I really need to have on every computer I must work with for more than few days.


So I decided to put together list of tools\utilities I like to use for easy reference in future. All of them are freeware (except Total Commander):


 


Command line utilities


  • SysInternals – everyone knows SysInternals, everyone love their tools…
  • JoeWare – home of CPAU and MANY great utils :)
  • Bill Stewart – another collection of great tools
  • SystemSherlock Lite – easy to use and powerful snapshoting – now with GUI :D
  • Windows Resource Kit – tons of tools – some are useful, some obsolete, overall must have
  • Ritchie Lawrence – home of cmdown and mtee
  • UnxUtils – port of most famous unix tools to Windows – NO INSTALLATION REQUIRED, these tools are native to Windows
  • Err.exe – well, officially Exchange utility, but is not really related only to Exchange. It allows you to translate error codes to friendly text
  • File Checksum Integrity Verifier – great small utility from Microsoft that allows you to generate hash from files. It supports also recursive mode – so it is VERY useful when generating hashes from folders, especially in combination with sha1.exe:
  • fciv -add “<Folder>” -r -bp “<Folder>” | find /i /v “End Time..:” | find /i /v “Start Time:” | sha1

    This command will generate hash from specific folder. Because we include -bp, you can also use to to compare 2 folders (fullpath is not hardcoded ;))

     


GUI Tools


  • Switcher – Do you know Expose for Mac? Switcher is same for Vista :) It is probably best replacement for Alt+Tab – with built-in searching
  • Qliner – easily assign programs to WinKey combinations – WinKey+C for cmd, WinKey+T for Total Commander etc…
  • Total Commander – hmmm, I would like to replace it with something else, but as far as I know there is no real alternative :(
  • Vista Battery Saver – got Vista & Laptop? Then you must download Battery Saver, it will really help you a lot (specially in case when you want to use Aero)
  • Jing – taking screenshots and videos – Jing is best for this, however I still have feeling it won’t stay free for long :(
  • Last.FM – no more media player, no more web radios – last.fm is simply best for music :) Software player is still missing many features (global hotkeys, global hotkeys, global hotkeys…), but it works :)
  • TortoiseSVN – I love SVN, even for my home projects\scripts and Tortoise is definitely best SVN client available
  • Windows Live Writer – really great utility for writing blog posts from Microsoft
  • Windows Live Messenger – Messenger… Ehm…
  • WinSplit Revolution – small utility that allows you to easily work with windows – resize, store at predefined coordinates, move etc… Also allows you to move windows between monitors
  • Crimson Editor – last version was released in 2004, but it is still my favorite text editor – but I need to find some time and evaluate alternatives (already tried PsPad, but was not really satisfied)
  • Application Compatibility Toolkit – even though it is still missing documentation, I really like ACT
  • Free Download Manager – nice, free, functional. What else do you want from download manager? ;)
  • Dependency Walker – nice tool for monitoring dll dependencies – it is however obsolete and would need few patches :(
  • RSAT\AdminPack – ehm, mandatory? ;)
  • Plaxo Toolbar – easy to use and FUNCTIONAL central synchronization of contacts and calendar.

Obsolete (I don’t use them in Windows Vista anymore)


  • RevoUninstaller – really nice utility for uninstalling applications. In Vista, instant search is enabled, so I use it really only in case of some leftovers (it is portable)
  • visionapp Remote Desktopnice RDP manager – version 2008 is not free anymore, so I am looking for alternative right now. UPDATE: Visionapp is working on new version of free edition. Only feature I am missing is configuration stored in file instead of registry value (because there is limitation of string lenght in registry and you run into such issues with big number of servers).
  • Process Lasso – I don’t have corporate notebook, so I don’t have 16 processes from Altiris\Symantec running on my PC. However I still love Process Lasso – it saved my nerves many times ;)
  • TaskSwitchXP – really nice replacement for Alt+Tab – in my case it was replaced with Switcher (WDM supported). One feature I loved was “minimize to tray” when you right-clicked on minimize button

Tools I am missing :(


As you can see, it is not really long list, I like to keep my computer as close to default configuration as possible… I would however like to add few tools to this collection, so if you know about any, let me know ;)


 


  • MultiMon management – when using multiple monitors, I would like to have few additional features (well, first of all I think it should be included in OS) – separate taskbars for different monitors and button next to minimize to move window between monitors. As far as I know there are only 2 products available – MultiMon (doesn’t work on Vista) and Ultramon (not free) :(
  • Total Commander replacement – I would like to have something that runs natively in 64b and is fully multi threaded (each tab separate thread, so the whole commander won’t freeze when you try to connect to unavailable share)
  • Ad blocker – really small blocker, something like AdMuncher, but available for free UPDATEL: IE7Pro have built-in ad blocker. Simply and functional.
  • Good password manager – RoboForm is not free, SSOPlus is too buggy, AlPass is missing many features… And rest of them is either not really reliable, or is missing good credentials management, or doesn’t support autofill :(  UPDATE: Dennis showed me utility he is using called Sticky Password and that was exactly what I was looking for. It is NOT freeware, however I will probably just pay 25$ they want for it ;)
  • RDP manager – some replacement for vRD. I definitely want to have same credentials management as vRD (that is very limiting, I know) UPDATE: VisionApp is working on new version of freeware vRD – and I like concept of free vs. Pro edition. So there is no reason why to look for alternative when it is only question of time.
  • Text editor – I need to finally replace Crimson Editor, but haven’t evaluated any other text editors (except PSPad) yet :(

Use RunAs from non-domain computer?

First I would like to make big announcement – after almost 3 years I left DHL and joined company called Login Consultants… So after long time I am consultant (again) and you can expect more posts about different problems I encountered during my consultancy career…

And I already encountered one during my first day – working with domain-based environment from non-domain computer. As mentioned before, I really love Vista (it took me however some time to get used to it) so I immediately installed it on my new laptop (that is no longer under corporate policies and rules). And then I realized that customer have (well, of course) domain and my non-domain laptop won’t be able to do much (except accessing remote shares and running RDP\ICA sessions).

So I started to investigate and came with solution. I found MSDN article http://msdn.microsoft.com/en-us/library/ms682434(VS.85).aspx and one specific part of the article grabbed my attention:

 

LOGON_NETCREDENTIALS_ONLY
0x00000002

 

Log on, but use the specified credentials on the network only. The new process uses the same token as the caller, but the system creates a new logon session within LSA, and the process uses the specified credentials as the default credentials.

This value can be used to create a process that uses a different set of credentials locally than it does remotely. This is useful in inter-domain scenarios where there is no trust relationship.

The system does not validate the specified credentials. Therefore, the process can start, but it may not have access to network resources.

Sounds very interesting – so I started to play with this API and it turned out (to make it very simple) that it acts as token that contains multiple credentials (Logon SIDs):

image

Notice the Logon SID – there are 2 values

This way you can specify MULTIPLE accounts you want to use. In example below I have 3 different credentials:

image

Cmd with 3 Logon SIDs

Just be aware, based on my testing each credential should be from different domain, otherwise only FIRST match is used.

I tested this solution today – and it works like charm :) For accessing local PC, I am using my account (MartinNB\Martin), for accessing any domain resources, I am using Domain\Operator account automatically. I tried this with accessing remote shares, MMC console (AD Users and Computers) and also PsExec with implicit authentication (that means no username\password defined).

When I knew what I was looking for, it turned out that my whole research was partially waste of time – this functionality is already included in RunAs itself through /NetOnly parameter :)

 

To show you example how to use it:

We have company XYZ. They provided account SuperAdmin for me with password SuperPassword.

I will first run command RunAs /NetOnly /User:XYZ\SuperAdmin cmd and specify password SuperPassword when prompt appear. New cmd window will automatically appear.

Now I can simply kill explorer (taskkill /f /im explorer.exe) and run it again (explorer.exe) – my desktop will switch, so from now on I can normally work with XYZ domain AND my non-domain laptop :D

 

I am just thinking about writing some small utility that would allow you to easily switch between different customers profiles (codename Desperate Consultant)… I wrote to Joe from Joeware if he is willing to add this (NetOnly functionality) to his cool utility CPAU – if he agrees, I will wait for him and build it, otherwise I will create some wrapper around RunAs.

Idea is that you will predefine any credentials and that easily merge that credentials into your session.