Tuesday, July 23, 2019

#95: Why I like Visual Studio Code?

We all are familiar with Visual Studio. We have community edition of Visual Studio as well. But Visual Studio is more preferable for developing complex software. For our day-to-day scripting, we need something lightweight.

Most of our scripting needs are fulfilled by Powershell ISE. But Powershell ISE is limited to certain features, I accept that it has improved alot but still I feel it slower and little blur(ish) fonts makes me difficult to connect with it. It is my personal comment, but if you have also felt the same, do let me know. I might be wrong.

Coming to the point why I am writing today's post. So, today we will talk about Visual Studio Code. I have been using it since it was released. Believe me, this is great free tool provided by Microsoft. I love the interface, themes and great capability to customise.



Below are the few bullet points that I found great about Visual Studio Code:

- You need not install it, download a zip file from Microsoft.
- Available in Linux, Mac and Windows.
- Several themes available. Dark to light to many experimental that suit your taste of colors.
- Capability to Debug. The major element that is missing in Notepad+.
- Feature to edit any language. Sometimes we need to write script that also include Python, Java or any other language. No issues, Visual Studio Code is capable to edit a huge list of languages.
- Timely upgrades from Microsoft.


Try downloading from below and let me know how you feel.
https://code.visualstudio.com/


Cheers!

Saturday, May 11, 2019

#92: How to forecast the time for certain task in Powershell?

This has always been a thought since I started using Windows 98. I remember the flying files avi file which used to pretend that actual file is flying from one folder to another. It used to appear as if the correct number of files are shown. Along with that it used to show how much time it will take. All in all, it was very amusing to see when I saw for the first time. I can't forget the Windows 98 themes in Plus. They all were full loaded with so much exciting stuffs into them. Under water them was the one which used to sound at every click and when application closes, it used to sound as if water went out.

Today's tip is not about Plus theme. This is all about forecasting the time which will be required to run a command. The time might vary based on situations, but you can get some guess about time. I will use measure-command cmdlet which will show you the time required to copy a file :

$SOURCE_FILE="C:\abc.zip"
$DESTINATION_FILE="D:\abc.zip"
(Measure-Command { Copy-Item $SOURCE_FILE $DESTINATION_FILE}).totalseconds

In my case, it output as :
1.540063

My file is around 50 MB and the location is same computer, so 1.5 seconds should be correct. I run the command as well and I suppose it took this much time.

This will work for all native commands only, you cannot run some other application and try to guess the time taken. Do not try to run something on SQL Server or any other application, this is good for native applications only.


Enjoy scripting!!

#112: How to handle xml document in Powershell?

 In PowerShell, you can handle XML data using various cmdlets and methods provided by the .NET Framework. Here's a basic guide on how to...