Wednesday, September 26, 2012

Get the Time of remote Offices Locations using Powershell script.


If you are working in an MNC and you are multiple remote office then one thing is sure that you are visiting few TIME ZONES sites or have some WORLD clock installed on your System.

we have some remote offices and they all are on different geographical locations and on different time zones too, i can use any free World Clock software but my laptop already have too many software installed so i don’t want to install any more on it.

To solve this i decide to write a small script which can show me the Time of my all remote offices.

I created a small script which shows the time of “Local, Delhi, Dubai, Singapore and Manchester”.

You can download the script from this link :

Screenshot of the script:
26-09-2012 00-06-00
Script Logic:

   1:  $RemoteTIme = New-Object -TypeName Psobject
   2:  $Dubai = (Get-Date).ToUniversalTime().AddHours(4).ToShortTimeString()
   3:  $RemoteTIme | Add-Member -MemberType 'NoteProperty' -Name Dub -Value $Dubai

The script logic is quite simple.

First i have created a new PS Object Named as $RemoteTime.

Then i created a variable for every country and in value i am converting  GET-Date to Universal Time and then i am adding hours and minutes according to the desired countries TIME offset with GMT.

Third i am adding members to our PSobject which we have create.

Note: I haven’t figure out yet how to automatic do the DST things. Will update you when i know that. In case you want to added the country which use DST setting , you need to manually add or subtract the HOURS accordingly.

Download  link :


Aman Dhally

join aman on facebook Join aman on Linkedin follow aman on Twitter

Tuesday, September 18, 2012

Get Network Information of local and remote Computers using PowerShell.


Last Sunday one of my friend come to visit me at my home, he is a SQL Administrator and we were talking about Powershell, and he told me that he is facing a problem, he said that in their environment they have approx. 500 Servers and they want to know the network configuration of all of them and specially they needed the SUBNET mask information, because their SUBNETMASK are based on geographic locations.

For him i wrote a simple script which can query multiple server using WMI.
You can download the script from this link :

Download Link  : 

18-09-2012 12-52-23
You need to add computer names separated by commas in the front of the script.

Make sure that you run this script as ADMINISTRATOR if you want to run this script for remote computers.

Download Link  :

Aman Dhally
join aman on facebook Join aman on Linkedin follow aman on Twitter

Thursday, September 13, 2012

Find Folders Using PowerShell

I my previous post i wrote about “How to search for files using Powershell” .
In this post i am writing about “How to search folders” in Powershell.
The logic and command are almost same ,the only difference is in Files we were using
$_.PSIsContainer -eq $false

and for searching Folders we need to use

$_.PSIsContainer -eq $true

Simple Smile 

You can download the script from this link :

Download Link :

13-09-2012 11-50-20

Aman Dhally
join aman on facebook Join aman on Linkedin follow aman on Twitter

Find Files Using Powershell.

This seems a easy Topic, but as you know in my articles i always tries to cover tasks rather then techniques.  The main benefits of these kind of articles is they help in quick learning.

The more you use the more you learn.

Today i was looking for some files  and when i open Windows Search and see that few of my Drives are not indexed by windows Search, and it is taking a time to give the results.

And at that time i think , lets try to use Powershell to search for a file. 

and i used the below command to achieve my target.

Get-ChildItem -Recurse d:\ | Where-Object { ($_.PSIsContainer -eq $false) -and ( $_.Name -like "*Active*" )}

13-09-2012 12-25-55
In Above Command . Using Get-ChildItem -Recurse i am searching for all folders and subfolders in D Drive and then we are piping the output to Where-Object Cmdlet and we are we are defining two conditions here. one the PSIsContainer should be $false that means this should be a file and after that we are defining the name of the  File which we want to search,

I converted the above in to the script,  you can download the script from below link.

Download Link :

In this script i added read-host , so when you runt he script it ask you for FILE path to search and the File name to search and after that i will give you the result.

13-09-2012 11-50-44

Download Link :
Aman Dhally
join aman on facebook Join aman on Linkedin follow aman on Twitter

Friday, September 7, 2012

Let’s Play with DATE using Powershell.


In scripts the DATE is very useful, in my most of the scripts i always use $DATE variable. This became very handy when you want to save the output of the script to a file name and the file name contains the date as name.

There are few tricks which i always used with Get-Date. let me show few of them,

  1. When i want to add dates in Registry entries or keys, i always tried to convert then to the String

      $date = (Get-Date).toString()

      07-09-2012 12-24-51

2. When i want to specify a one week old date , i use .AddDays Method, You can add days or use minus days in current day.

  • $OneWeekOldDate = (Get-Date).AddDays(-7)

  • 07-09-2012 12-28-13

  • $OneWeekFutureDate = (Get-Date).AddDays(7)

  • 07-09-2012 12-36-25

3.  If we want a customise output of the date as per our requirements we can use a -Format parameter.

    • $dateFormat1 = Get-Date -Format 12-42-37
    • $dateFormat2 = Get-Date -Format dd_mm_yyyy

    • 07-09-2012 12-43-29

    • $dateFormat3 = Get-Date -Format dd-mm-yyyy

    • 07-09-2012 12-44-30

that’s all for now Smile

Happy Playing with the TIME ;o)

Happy Weekend …


Aman Dhally

join aman on facebook Join aman on Linkedin follow aman on Twitter

Wednesday, September 5, 2012

Powershell and Active Directory: Get Your Active Directory Forest and Domain Information using Powershell.


Sometime a situation comes when you want to know about your Active Directory Infrastructure.  That what is your AD Forest Name is, how many replica server do you have in your company,how many domain sites do you have  etc. etc.

When you get Answers you want to document all the above things for your future reference. Today a situation arise that i want to know answers about the above questions.

I know i can get all the answers by using Active Directory Module. But then i think if someone else need the same information, then what he will do?,he will do the same or he ask someone else in his team and waiting for their replies.

Then i think, why not to script it, so that everyone can get benefitted from it,.

So i write a simple script to done this task. Before running the script make sure you have RSAT tools installed.

Download Link: 

This script generates a HTML formatted Report file in your desktop folder.
That reports contain the information on :
  • Forest Name
  • Forest Mode
  • Forest Domains
  • Domain Naming Master
  • Schema Master
  • Global Catalog Servers
  • Forest Domain Sites
  • Domain Name
  • Domain NetBios Name
  • Domain Mode
  • PDC Emulator
  • InfraStructure Master
  • Replicated Servers
Screenshot of the script.
05-09-2012 15-40-18
Download Link: 

Aman Dhally
join aman on facebook Join aman on Linkedin follow aman on Twitter