Customizing Windows PowerShell command prompt

Windows PowerShell is a great tool and, if you are using it frequently, one of the things you might want to do is to customize the default command prompt. This is actually a quite common activity among Linux users; hence, there are many tutorials on doing that as well. In case you want to do this kind of customization to Windows PowerShell, please follow the guidance below.

The text displayed as the prompt for each line in the PowerShell is defined with Prompt() function. You are free to override this function (hence, change the command prompt) the same way you can override any other function – by defining the function in the default user profile script. The profile scripts can be defined at one of the following locations: Continue reading

Creating ZIP archive from a Batch script

While writing a data collection script, I had a requirement to compress some files into a single archive. At first, it did not sound too challenging (Windows has integrated ZIP supported via Send To Compressed (zipped) folder since Windows XP), but it seems it is not so easy if you throw few extra requirements for this task:

After reading some Microsoft documentation, many online forums and trying many differing things, I finally came up with the solution. Continue reading

Count number of users who logged on to workstation in the last month (with Batch script)

Recently, at my job, I had a task to write script/program to count how many users had logged to workstation in the last month. While my colleague tried to complete this task with C#, I’ve decided to use old good Batch. In fact, I was thinking about using PowerShell at first, but since all computers this script will be run in are running Windows XP and do not have PowerShell installed.

To accomplish what I want I’ve found out about VBS script called EVENTQUERY which exists in Windows XP. After reading documentation I’ve decided that it would allow me to do exactly what I need. Though the script that relies on EVENTQUERY.VBS file, it wouldn’t work on newer Windows OS (Vista, Windows XP), but it wouldn’t cause any problems since, as I’ve mentioned before, all computers this script will be deployed to runs on Windows XP. If I would need it to work on Windows 7 later, I’m probably gonna use PsLogList from SysInternals. Continue reading

Look Ma, I’m using PowerShell


Couple of days ago I’ve decided to filter some of my music and upload it to my HTC HD2. I was using Windows Media Player (WMP) for that. I haven’t noticed that WMP converted all uploaded songs to WMA. Problem was that many of uploaded files were unable to play on my phone (neither by using HTC Player nor WMMP). I decided to upload all my favorite songs (ones I’ve already filtered before) one more time but this time directly to my MicroSD card as MP3. The worst thing was that I haven’t all my filtered songs (well just the ones in WMA and that’s not what I need). What makes it more complicated is that many of my songs ware stored as FLACs on my HDD, therefore I would need to convert them manually to. I couldn’t call myself an IT guy if I wouldn’t come up with idea to write a script to automatize entire process of filtering, converting and copying all songs I want to have on my phone to one place. Continue reading