Introduction to PowerShell - Part 5 - Script Flow Control

by Dmitry Kirsanov 30. March 2012 17:58

In this short video, which is rather addition to the 4th part of the PowerShell introduction videos for Windows system administrators, I am showing the basic concepts of script flow control.

This is very natural and basic for software developers, but system administrators with no prior experience in Windows PowerShell may find it very useful.

In this particular example we are connecting to the remote computer and listing it’s network adapters, to do different things depending from whether these adapters are DHCP enabled or not.

More...

Introduction to PowerShell - part 4 - Security

by Dmitry Kirsanov 23. March 2012 01:42

One of the qualities of the PowerShell, one of the scales to mark it’s success was the Security. It is also the first question asked when someone new to PowerShell is trying to run the PowerShell script.

The previous generations of scripting environments, like the Windows Scripting Host with it’s notorious VBS files sent automatically over e-mail by all sorts of worms and trojans – they cried for better security, and not only in terms of getting over the problems, but also in terms of applying newest standards and technologies.

So this video training article is about the security in Windows PowerShell. More...

Introduction to PowerShell - part 3 - Variable Scopes and Arrays

by Dmitry Kirsanov 19. March 2012 10:35

I’m continuing the series about the PowerShell for System Administrators and in this chapter we are talking about how PowerShell handles variables and the data stored in them, the life and times of variables, and ends with how to handle arrays.

More...

Introduction to PowerShell - part 2 - Pipeline, Scripts and Syntax

by Dmitry Kirsanov 25. January 2012 09:30

Introduction to PowerShellAll of a sudden I decided to spend one hour of this evening to make the second part of PowerShell introduction for Windows system administrators. I just noticed, that the previous part was made in… November, and having quite a few requests to continue I just couldn’t resist! So, this is pure improvisation, although I tried to make it as smooth as possible.

This time we’ll dig further into what system administrators do most – working with large arrays of data, such as files, ACL lists and finding objects by special parameters. You will learn about variables in PowerShell and how you can effectively use them. More...

Introduction to scripting for systems administrators - Windows Scripting Host, part 1

by Dmitry Kirsanov 20. November 2011 08:42

Some time ago, which seems like yesterday, I made an attempt to introduce Windows Systems Administrators to PowerShell. Even before doing that, I realized that professional Windows scripting is still impossible without using of VBScript, or Visual Basic Scripting Edition. And teaching someone PowerShell without at least showing the main concepts of VBScript is not right.

While I am trying to show the work with VBScript from more like practical point of view, I am also not trying to substitute the training course on the subject, so if VBScript or Windows Scripting in general is about to become your main responsibility at your company, please get yourself a reference on it, preferably something as good as VBScript bible.

However, we’ll get closer to VBScript during later sessions and cover even so exotic topics as using VBScript custom actions in Microsoft Installer packages (MSI).

Introduction to scripting for systems administrators - Windows Scripting Host, part 1

Introduction to scripting for Systems Administrators - PowerShell

by Dmitry Kirsanov 19. November 2011 21:28

There was a time, when IT specialists were mainly either systems administrators or developers. There was a time, when being Database Administrator would also mean having perfect knowledge of SQL. New generation of IT specialists don’t remember that time, and that only because technology evolved so greatly, it is considerably harder to possess the whole range of features offered by a monster product such as SQL Server 2008.

But this post is not about databases at all. It’s about how we can manage the growing complexities of enormous range of technologies that we have to use in business. More...

ExecuteAs utility

by Dmitry Kirsanov 28. October 2011 01:50

Well, yet another useful command line utility. This one is for system administrators in need to run some command on behalf of another user.

Why bother, if there is a command in Windows, called runas? Well, mainly because it doesn’t accept the password as command line parameter, and also because I wanted to add more features to such simple process.

This is the help text you get when running this program without parameters:

Syntax: executeas.exe /u:UserName /p:Password /x:Priority /d:Domain /a:Affinity /quiet /hide /noprofile /wait /t:60 [program name]
Where t is a timeout in seconds to wait for program completion.
The only required parameter is program name. You can place command line arguments after the program name.

As you can understand, UserName is the user name of target user without the domain name,
Password is his password,
Priority is the priority at which you want this program to be executed (1 – idle, 2 – below normal, 3 – normal, 4 – above normal, 5 – high),
Domain is the domain part of the user name, if needed,
Affinity is how many CPU cores you’d like to use,
Quiet won’t produce any output,
Hide will hide the target program, so it will not be displayed to user,
NoProfile means that profile of target user won’t be loaded,
Wait will wait until the target program will be completed – useful when running from batch file.

So, here it is and have fun!

As  always, .net framework is required for this program to run. This time it’s .net 3.5, which is installed by default on Windows 7 and is available as feature on Windows Server 2008.

ExecuteAs.zip (3.99 kb)

File Synchronization Utility

by Dmitry Kirsanov 26. September 2011 18:31

Yet another command line utility written to do some useful stuff in the background. This time it is about file synchronization.

It’s quite often that we need to make 2 directories in our local network in sync. For example, you may want to synchronize folders with photos, backup files or even production files of your web application between IIS web farm nodes.

This program utilizes the Microsoft Synchronization Framework, so basically it does very little apart from what Microsoft already provides. Personally, I am using it to pull backups from TFS server on daily basis and to synchronize shared folders among load balancing cluster of production web server. In  both cases utility is running as Task Scheduler task and everything happens in background.

It doesn’t require installation, just unpack it to your utilities folder and it’s ready to go. It requires .NET framework 4 Client Profile in order to run. Another dependency is Microsoft Sync Framework 2.1 (Two components required - Synchronization and Provider Services).

FileSync.rar (114.45 kb)

File Replacement Utility

by Dmitry Kirsanov 25. August 2011 06:48

Ok, here is another command line tool. This time - for developers who create software made of many components.

Imagine, you have a product which consists of main executable file and multiple dll files. And different people are working on these. And you are deploying it all on multiple machines and never know where it could be hiding. Maybe in some build directories, maybe somewhere else.

So this utility will find all instances of that file and replace with the newest one. Moreover, you can even select the older file, but all files will be replaced by the newest found. Well, there are parameters, of course.

As the searching for files is time consuming, the end result of this utility could be a batch file (.bat) which contains commands to repeat operation. It will take the same source file and put it to the same destinations as during the first run. That way, continuous replacing won't be a problem or take more than a couple of seconds.

So, here it is. Requires .net framework 3.5.

filereplace.rar (5,32 kb)


Month List