2007-03-12

PowerShell - The first one object(!) shell


...Microsoft Exchange Server 2007 where everything is done via command line interfaces and the administrative GUI is layered on top of those commands.
Wikipedia


Came across it by accident.
get-process | where { $_.WS -gt 1000MB } | stop-process

It's beautiful... now through pipes goes not only just text but full-fledged .NET objects, anytime and everywhere one can easily get access to a required object field. Farewell, sed and awk.

Killer feature - the possibility of creation and trying COM-object just in interpreter.
$a = New-Object -comobject Excel.Application
$a.Visible = $True
$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)
$c.Cells.Item(1,1) = "A value in cell A1."
$b.SaveAs("C:\Scripts\Test.xls")
$a.Quit()

It makes me glad that methods autocompletion works.

According to one's choise any .net build can be loaded.
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$d = [Windows.Forms.MessageBox]::Show("msg")

Аnd one can send e-mail
$Attach     = new-object System.Net.Mail.Attachment("C:\Test.txt")  
$SMTPClient = new-object System.Net.Mail.SMTPClient
$Msg = new-object System.Net.Mail.MailMessage

$Msg.Attachments.add($Attach)
$Msg.To.Add("BillGates@Microsoft.Com")
$Msg.from="Vasya.Pupkin@Mail.Ru"
$Msg.Subject="Subject"
$Msg.Body="This is body of E-Mail"

$SMTPClient.Host="SMTP.Mail.Ru"

$SMTPClient.Send($Msg)

There is a simple auto-completion of paths. There is even Far plug-in

In short, it's a practical thing for those on Windows.

I'm curious, if there were some tries of objects extension of shells under *nix?

No comments:

Post a Comment