Hi,
Today when i open Google.com today i saw a candle in the bottom of the Google search box.
and when i hover my mouse over it .. it said…”In the Memory of Delhi BraveHeart”
thanks Google.com to pay the tribute to the DELHI Rape Victim.
Thanks
Aman
Hi,
Today when i open Google.com today i saw a candle in the bottom of the Google search box.
and when i hover my mouse over it .. it said…”In the Memory of Delhi BraveHeart”
thanks Google.com to pay the tribute to the DELHI Rape Victim.
Thanks
Aman
Hi,
As i mentioned earlier that i am very busy in the month on October and November that’s why i was not able to write any article on Powershell, but i am little free now and will try to publish articles whenever i get free time.
Today one of my fried call me and he was having some problem understanding DO WHILE loop, I explained the working of the loop over the phone to him and i thought it is worth writing a post on it.
the working of do while loop is simple.
do { code block }
while ( condition )
for example.
do { Dancing }
while ( music is playing )
You got an idea ? isnt ?
That means do something till while condition is true. Like in above not-IT example do the Dancing till the Music is Playing
In IT world we can use it in a various ways . Lets try this ….
and type the below in the powershell console.
what is happening?
Powershell Will Ping Google.Com till the notepad windows is open.
You can notice our Notepad windows is open and we have constantly pinging Google.com and after 4 Pings it starts again.
I hope it is little bit clear now
Thanks
Aman Dhally
Hi,
I do believe in that Life is about sharing happiness with other.
Last week on 16th October 2012 god has blessed me and my wife with a beautiful Princess.
We haven’t decided the name yet for her, just for now we are calling her as “Princess”
Thanks
Aman Dhally
Hi,
In my previous post i have write a little article on how to view to see the contents of files.
As you know that i like Text files and my most of the day spent on PowerShell console so i love to do different different examples with cmdlets and command.
On my laptop i have a simple test file name as “Seen Movies.txt”, i this i mainly put the name of all movies which i have seen on my laptop and whose video files i do have stored on my NAS drive. SO when i need to get any movie i check this file to know that if i already have that movie or not. In case i have a movies entry in the file then i don’t get or purchase that Movies and if i don’t have entry of that movie then i can think of buying it if i am interested to watch that movie.
So what’s special ? “we can do the same by open the file in notepad and then we can search for that movie”.
Yes agreed but remember there are lots of way to do one thing,
To check that i have that movie or not i just run a simple command.
Get-Content FILE_NAME | Select-String “Movie Name”
Using Get-content we are getting the content of the files and the we are piping the output to Select-String Cmdlet and then selecting to show the string “Avenger”
The above command showed me that i have “The Avengers” movies in my database.
ok but what is the real use?
The real use is that you can search for specific words in log files.
Get-Content C:\Windows\Logs\CBS\CBS.log | Select-String "error"
In above command i am getting the content of C:\Windows\Logs\CBS\CBS.log and piped them to the Select-String cmdlet and asking it match everything which contain the word “Error”
If you want to do a search on case sensitive words then you can use -CaseSensitive parameter with Select-String cmdlet
Simple isn’t and this is very handy and useful cmdlet
.
Thanks
Aman Dhally
Hi,
I am very busy in October and November so you may not see much posts from me in this time period.
We love files especially if they have TEXT,Config,XML,HTML or any other kind of files those contain Text or raw text in source.
I like Text files to store simple data, the text file are small in size and they don’t need any special program to open.
As you know i do spent a lots of time on PowerShell console and some time when i need to read any text file i have use Get-Content cmdlet.
Get-Content can read txt,inf,html,csv, xml, PS1 and lots more.
Usage of Get-content is simple.
Get-Content FILE_NAME
and you can also read and see Powershell Script in the console using Get-Content.
Simple Isn't
Thanks
Aman Dhally
Hi,
Perfmon is one the favourites tools of all IT admins. Every IT admin love this tool and we love Powershell too.
As a Powershell users most of my time is spent on powershell tool and sometime there is a need arrive when you want to check few performance counters. and as you know i am quite lazy is doing stuffs and I think that laziness is a path to automation.
I don’t want to to pent RunBox and then type PerfMon and then click on OK and then add the performance counter which i needed.
In performance counters i don't care about Graphs , i do care about values.
Powershell give us a very nice and clean cmdlet to get the values of Performance counters. As i mentioned above I don’t care about the graph i do care about values and in powershell console every thing is Text and we love that texts.
To get the values of performance counter we need to use the cmdlet Get-Counter .
Lets Start.
To list all the performance counters sets use the command.
Get-Counter -ListSet *
This will show you the list and path of all Counter sets.
If you want to know what kind of Counter sets you do have in your system just piped the above command to the Select CounterSetName cmdlet
Get-Counter -ListSet * | select CounterSetName
we can also use wildcards in -ListSet parameter. I am looking for all disk related counter sets, to search all conter sets those have disk word in it i can use *Disk* argument in -ListSet parameter
Get-Counter -ListSet *disk*
I am interested in counter set Logical Disk. and i can piped the above command to show me the LogicalDisk counter set only using where-Object cmdlet.
Get-Counter -ListSet *disk* | where {$_.CounterSetName -eq "LogicalDisk" }
So now there is a little problem arise. if you want to see the detail list of counters and Paths, some how you can’t see the complete output. The whole output is truncated using … ,
We need a list of counter to use them ,the best workaround of the above problem is to save the above command in to a variable.
$DiskCounter = Get-Counter -ListSet *disk* | where {$_.CounterSetName -eq "LogicalDisk" }
we are saving the output of above command in to a $DiskCounter variable.
So now if you want to see the Logical Disk Performance counter paths we can use Dot Notation now.
$DiskCounter.Paths
if you want see the Logical Disk Counters only.
$DiskCounter.Counter
Of if you want to see the Logical Disk Performance Counter paths with instances with counters use.
$DiskCounter..PathsWithInstances
Okies Now.
I am interested in my C drive Disk Queue Length. and using $DiskCounter.PathsWithInstances i know that i have to use "\LogicalDisk(C:)\Avg. Disk Queue Length" counter.
Get-Counter -Counter "\LogicalDisk(C:)\Avg. Disk Queue Length" -SampleInterval 10
In above command we are using counter "\LogicalDisk(C:)\Avg. Disk Queue Length" to monitor the disk queue length of our C drive and using -SampleInterval parameter we are telling to get-Counter cmdlet to collect the data for 10 seconds.
if you want to see or monitor the counters you can use the -Continuous parameter.
Get-Counter -Counter "\LogicalDisk(C:)\Avg. Disk Queue Length" -Continuous
That’s all for now ,, and i think now have an idea how to use it
Thanks
Aman Dhally