Thursday, April 16, 2009

First Powershell Script

Windows Powershell is another attempt from Redmond to provide powerful windows scripting language to IT professionals. But this time, I would say that it is a successful attempt by Microsoft.

Windows Powershell is often being compared with Unix Bash Shell. But it actually does more than what you may expect. Unlike its Unix counterpart, the PowerShell pipeline is an object pipeline; that is, the data passed between cmdlets are fully typed objects, rather than byte streams. A cmdlet, pronounced "command-let" is same as what you call "shell script" in Unix. So don’t get confused with cmdlets

I have read more reviews on Powershell and excited to see Powershell in action. I'm posting all my learning as I learn so it could be useful to everyone.

Click here to download Windows PowerShell 2.0 Community Technology Preview (CTP)

So Here is your first simple “Hello World” script:


PS C:\Documents and Settings\jagadish.g> Write-Host "Hello World"
Hello World
PS C:\Documents and Settings\jagadish.g>

Write-Host cmdlet is similar to echo in Unix. You can specify separator, background color, foreground color and more.


PS C:\Documents and Settings\jagadish.g> Write-Host (10,10,12)
10 10 12
PS C:\Documents and Settings\jagadish.g> Write-Host (10,10,12) -Separator "+"
10+10+12
PS C:\Documents and Settings\jagadish.g> Write-Host (10,10,12) -Separator "+" -ForegroundColor Green -BackgroundColor Black
10+10+12
PS C:\Documents and Settings\jagadish.g>


Now we will go through some simple cmdlets.

Get-Process
    Gets the processes that are running on the local computer or a remote computer


PS C:\Documents and Settings\jagadish.g> Get-Process | Select-Object -First 3

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
32 2 780 2708 28 0.05 1296 acrotray
107 5 1168 3524 32 0.03 2712 alg
203 7 3584 6648 43 0.36 3724 btdna

PS C:\Documents and Settings\jagadish.g>

Get-Service
    Gets the services on a local or remote computer


PS C:\Documents and Settings\jagadish.g> Get-Service | Select-Object -First 3

Status Name DisplayName
------ ---- -----------
Stopped Alerter Alerter
Running ALG Application Layer Gateway Service
Stopped AppMgmt Application Management

PS C:\Documents and Settings\jagadish.g>


If you have any questions on Powershell, please post them in the below comments section

11 comments:

  1. Hi Jagadish,

    I am new to this power shelll can i have any doc/pdf to learn from the scratch.Please send me to this id-->iampraveen6@gmail.com


    thanks
    praveen

    ReplyDelete
  2. Praveen,

    I have sent you some pdf documents for your refernce

    Best of luck !

    ReplyDelete
  3. Hi Jagdish You are right that Windows Powershell is powerful windows scripting language to IT professionals.The example you provided here is simplest.Can you share some links for study related to this

    ReplyDelete

  4. Your blog is very useful for me.I really like you post.Thanks for sharing.
    goldenslot
    gclub casino

    ReplyDelete
  5. World-class casinos The mind of the player as well.
    viva9988Is a web g club One of the world's leading online gambling houses, the world's leading online gambling provider, is thriving online gambling that is free of thought and imagination. The system of online casino web site. A new system that allows gamblers to access and play online gambling in all forms, just dare to open your mind to play online gambling games only, risky people can join the fun and challenge. Efficiency in Online Gambling Betting on GClub Website Our online casinos and online gambling games offer you more fun. Since every time you beat online casino games, you can make money from playing online gambling games there. The fun of playing online gambling games happens whenever you can beat online gambling. Every time a risky player wants to play online gambling games. Do not forget to choose our online casino site for great fun channels, open 24 hours a day, when you want to play online gambling games simply by clicking the web. จีคลับ

    ReplyDelete
  6. Channels to win a continuous entertainment.
    GclubIt is a channel to win online games that customers have fun at any time with your favorite online games. With online gambling games, the advantage of gambling is that gamblers can bet on. Our online gambling games are risky on the internet. With a variety of fun and gambling with all the credibility of gambling. What is the latest online gambling game? They are gambling. Due to not only entertain the players only. You can also make money from online gambling online gambling games because it allows anyone to gamble on all online gambling games. Online gambling games that are ready to entertain you at any time. Come play a variety of online casinos with our website continuously. No matter what you want to gamble online, we are ready to open the service. Various types of online games and the best online casino games are popular. Have fun with various types of gambling online, which is a great way to gamble at every click. Royal1688

    ReplyDelete
  7. Online gambling games fascinating.
    คาสิโนIs a web g club Casinos allow people around the world to play online gambling along the way for online gambling. Online gambling is another new way to play online gambling. Every form of interest, it is also up if the player is another person who loves and is passionate about playing gambling games, then gambling online is another new channel. Which allows you to gamble online full. Nowadays, internet signals, online gaming, online betting are just as easy as you are with a smartphone or a notebook attached to you, so you can play online at any time your bettor can choose. Play all online gambling games on the G-Club website. Our online casino. Another chance for new players to bet on the online casino games that all players want. You can join in the fun and play all online gambling on the web page g club. Our online casino at the website Sbobet

    ReplyDelete
  8. 30% new member bonus
    Gclub Slot It is a website that is open for gaming, gambling through computer network. With an immediate enduring service You will find many casino games. And the games are broadcast live. Direct to your residence every day, such as casino games that are popular in the present time, slots, roulette, poker, slots, slots, online. And many others, which you will be able to play baccarat online. And other games can be delivered directly to live. Or wherever you go, you can play games anywhere. With the perfect design for everyone. Make it easy to use and let you enjoy every minute. Get a simple minutes per minute. Ensure the persistence of your eyes to the way we are unmistakably. Come and join us for fun with our computer network betting site today. Get instant bonus bonus for the new team 30 percent of the minimum book open from 500 baht up to 15000 baht best way to do this is not fast enough to join us on the site. คาสิโนออนไลน์

    ReplyDelete
  9. Online Casino Games Make you rich
    รอยัล1688One of the most popular online casino games of the industry. Nowadays, casinos are one of the popular and well known. Today, many gamblers love to play fast, so playing fast online casino games is another good way to play online gambling games in each. This is an interesting and important form today. Online casino games in each format can also be played both domestically and internationally, with the Internet as a medium for connecting the enjoyment. The style, excitement and challenge make online gambling a very popular in Asia. Any favorite passion for gambling and betting able to attend a joy to bet online. It is not difficult because of the gamble, online gambling is based on the Internet and mobile 1. Only Just you have these two things. Bets can be played on any online casino games that players like the webviva3388

    ReplyDelete
  10. Online gambling industry's famous.
    Gclub SlotIt is a site that offers online gambling services that are famous for the fun and fun for more than 10 years to make the casino known and accepted in just a short time. For playing online gambling games, it is one of the starting points of the rich. Anyone can join and start wealth. Because of the online gambling games in each way, the player or ordinary person becomes the highest paid person in the country and the highest in the world because of the revenue generated from playing online gambling games. The story is very simple. Since every time a player overcame an online gambler, the gambler can make an income from playing online casino games as well. Just bettors join in the fun and gamble online gambling. With casino site If you want to know how much money is spent on playing online gambling games, then you can earn money by playing online gambling games with gamblers around the world. Bets can be challenged by the players themselvesHoliday Palace

    ReplyDelete
  11. Healthy seas
    คาสิโนออนไลน์ Our website says enough summer has arrived. It is a promise that we must go to the sea. Most people like to go to the sea in the summer. We will go to the sea, we will benefit from the sea for our health.
    The benefits of sea water. Water is a great source of minerals and vitamins. We are soaked in water. It helps us to cure skin diseases. To kill bacteria on the skin well. It also relieves inflammation of the wound, heals the skin and can heal faster with it.
    The benefits of air. Good weather in the seaside will have higher oxygen content in the city. In the city to go to the beach to breathe air. It will help to purify the blood. It can transport nutrients better.
    The benefits of sand Every time we use our feet to step on the sand. Our brain produces serotonin. Let us know automatically relax. In addition, the fine granules remove old skin cells, we leave it out. We do not know at all and do not be afraid to skin abrasion.
    The benefits of sunlight. Sunshine of the Sun Rich in vitamins that are beneficial to the bone. It also helps to cure depression that is not easy. But please be reminded that the benefits of sunlight are not related to sunbathing at noon. At least we should find a lotion with a sunscreen with me. It may be more fruitful than the benefits of the article. คาสิโนออนไลน์

    ReplyDelete