Blogroll

Search

Silverlight IDE possiblities for DekiScript, Javascript, PowerShell, Ironpython, Ironruby and above.

July 8th, 2010 by Karl

I’m a huge fan on Mindtouch, it’s awesome RESTful Web Orientated Architecture with Dream that makes REST a pleasure but also in a powerful and performant manner with a great async coroutine architecture, and their main product has a build in language Called Dekiscript and i wanted to through together a proof of concept editor for it and that is what is below, but read also afterwards about the possibilities beyond a niche language for one product albiet a great product.

Here is a Link to where i have the interactive demo

Here is a screenshot

and

Here is a Link to where i have the interactive demo
PowerShell

A PowerShell web front end that can talk to the backend using ShellTools PowerShell Job Server , or PoshBoard or PowerGui Pro. With intellisense data coming from your servers, as well as abilities to use Siverlight isolated storage for script repositories/snippets or get hook up to a web based service for that whether it be Evernote, google docs or such?

HTML
Imagine it as an altnerative editor for the SOURCE version, whether for your CMS, with CKeditor, WordPress or such? a nice editor, with rich features, and code completion?

Javascript
A javascript editor that runs real in the browser. where code completion is running against the real life objects you are working with. the ability to quickly run and prototype javascript right there and then, or maybe even include it as an optional interface inside a firefox plugin or firebug or such?

IronRuby , IronPython, Script for .Net , Jint and other DLR languages
With various techniques and gestalt bring other languages into the browser and actually enjoy the code sculpting process right there in the browser without a second class citizen experience typical of web editors. Also with IronRuby and the like you could have macros and all running right there and then and with

Here is a Link to where i have the interactive demo

Posted in Powershell | 2 Comments »

PowerShell running in Dotnet 4

June 26th, 2010 by Karl

Back in the Dotnet 4, VS.NET 2010 Beta days i threw together a PowerShell console host compiled against dotnet 4 but really didn’t do anything with it. It seems that there is a bit of demand for it. So here it is. You can download it and start using it.

It at least allows you to interact with dotnet 4 code in-process. Its not going to turn PowerShell into a dotnet 4.0 citizen as really PowerShell is in what I call “Dotnet 1.9″ style. Its going to be very awkward to interact with Dotnet 4 dynamic objects without some nice helpers but at least it IS possible.

Also I very much doubt that this will be able to be used as a remoting server. However you could have a dotnet 2, PS V2 runspace call this to do some processing. Tedious but at least possible.
Background jobs also aren’t going to run in Dotnet 4, though they possibly may if you manage to rename the original powershell.exe and put this one in its place. I know on windows 7 the ability to do is locked down, but it might be possible on other OSes.

All Command line options should work other than Console files.

Download NOW!!!

Notice the CLR version above?

Download NOW!!!

Just download it, and if with IE make sure you “unblock” the zip, then unzip it and run it anywhere you have PowerShell V2 installed. Enjoy.

Thanks to @jstangroome on twitter to helping motivate me get this out.

Karl Prosser / ShellTools LLC.

Posted in Powershell | 1 Comment »

Portable PowerShell with Portable PowerShell ISE.

June 16th, 2010 by Karl

After a long fight we finally conquered making PowerShell ISE portable also.

Portable ISE

A new Beta of Portable PowerShell should be out by the end of the week that has ISE support and to celebrate we will open up the Beta group to another 100 users.

Go to http://groups.google.com/group/portable-powershell-beta to sign up to the google group. However be aware that the introduction words contain old info , and some bug in google groups is preventing me from updating it, however we’ll send out emails with the relevant information in it.

Posted in Portable PowerShell, Powershell, Shell Tools | No Comments »

DSLs / DSVs in PowerShell – Presentation at LangNet 2009

May 14th, 2010 by Karl

At LangNet 2009 last year i presented on DSLs in PowerShell. I wrote up a couple example ones . One which the presentation is in a kind of mini PowerPoint and another where i automated the awesome MindManager mind mapping product with COM to dynamically produce Mind Maps with a PowerShell DSV. Also I presented fellow MVP Jaykul’s awesome and extensive PowerBoots DSL that is one of the best and pithy ways to produce powerful interactive UIs in a scripting language ever.

Here is a link to the Silverlight version of the Video, and to the WMV (95MB) version. The Video is about 12 minutes and audio doesn’t kick in for 30 seconds.

Would anybody like me to post the code to the examples i presented?

-Karl

Posted in Powershell | No Comments »

Passing true dotnet nulls for strings to APIs from powershell

May 7th, 2010 by Karl

There is an issue that can basically prevent you from calling certain dotnet apis.

Basically the trick is just to make a class that’s .tostring() returns a null, and then when you pass that to an api through powershell that takes a string powershell will convert the class to a string() thus calling your code that returns a null..

namespace testnullD
{
public class nulltest
{
public nulltest(){}
public override string ToString() {return null;}
}
}

Here is a complete example you can use.

$a = @"

using System;
namespace ClassLibrary1
{
#proof of concept
public static class Class1
{
public static string Foo(string value)
{
if (value == null)
    return "Special processing of null.";
else
    return "'" + value + "' has been processed.";
}
}
}
"@

$b = @"
using System;
namespace testnullD
{
public class nulltest
{
public nulltest(){}
public override string ToString() {return null;}
}
}
"@
add-type $a
add-type $b
$psnull = new-object testnullD.nulltest
add-type $a
[ClassLibrary1.Class1]::Foo($null)
[ClassLibrary1.Class1]::Foo($psnull)

Posted in Gotchas Etc, Powershell | 1 Comment »

Reflections on iPhoneOS Terms of Service 3.3.1 and Steve Job’s open letter to Adobe. (First Draft)

May 6th, 2010 by Karl

Warning this will be a long post.

I normally don’t get heated about things but the fiasco with the new iPhone developer terms of service has kept my attention for the last few weeks and I suppose it’s because I have skin in the game and like many have developed applications in other languages for the iPhone that until a few weeks ago were perfectly acceptable but now are barred with a few key presses of a lawyers keyboard.

As a caution I haven’t ventured into my iPhone developer portal to view the new terms of service since this fiasco began but here is the excellently crafted offensive clause as reported by the mainstream media.
**************************************************************
3.3.1 — Applications may only use Documented APIs in the manner prescribed by Apple and must not use or call any private APIs. Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine, and only code written in C, C++, and Objective-C may compile and directly link against the Documented APIs (e.g., Applications that link to Documented APIs through an intermediary translation or compatibility layer or tool are prohibited).
**************************************************************

Breaking Down 3.3.1

The above clause is very carefully worded. It bans a lot, more than just adobe flash. A large number of iPhone games are made in C# using a game engine called Unity 3d. There is a C# to native iPhone compiler called MonoTouch.(MonoTouch is where this affects me directly.)  I believe there are some ruby to native compilers and Pascal as well. The “originally written in” part is a killer because though these languages compile directly to native machine code, they could just as easily compile down to Objective-C . This also effectively bans any kind of metaprogramming techniques or code generation tools. (In fact I recently wanted to store data in source code and I used PowerShell on windows to generate the objective-C to include into my application, which could technically invalidate my objective-C app).

Also “the JavaScript as executed by the iPhone OS WebKit engine”clause  could imply that novel uses  of JavaScript outside of the browser, such as with PhoneGap or Appcelerator Titanium which uses JavaScript not so much to control HTML but to bridge native COCOATOUCH GUI interfaces is banned also.

And the final clause prohibiting any “intermediary translation or compatibility layer” between the application code and the iPhone APIs , in its strictest sense would prohibit your own classes which wrap up some functionality for reuse, to any third party or open source library that makes reuse and certain functionality easier or more consistent (in the “real” or rather wider programming world this is VERY common”) and game engines (including C, C++) almost certainly always have a LARGE abstraction layer between the game code and the underlying platform.

I could go into detail now and rant about those clauses in depth right now, but I will resist and rather dig into Steve Job’s open letter ranting about Adobe and flash and try to break down the fallacies he portrays and deal with things as they really are. First of all I am not a flash fan boy. As a democoder who wrote optimized 3d assembly code and whose friends tried to succeed with “better” animation browser plugins but couldn’t compete with Flash’s pervasiveness I despised flash, yet I respect that its animation capabilities (putting video aside for now) are sufficient and better than the emerging HTML5 and it has a history and is established and successful for reasons good and bad.

Before we go into the “Flash on Mobile” or not argument lets separate two things which Steve Jobs has grouped together -Flash as a Browser Plugin versus the Flash “Packager” for Iphone.

Flash as we know it in a browser runs in a browser and has one set of content (SWF files) that runs the same on every platform. It can’t interact with the computer outside of its browser context, and it runs any programmatic behavior in interpreted action script (with interpreted code being SIGNIFICANTLY slower than compiled code (such as Objective-C or C++). Many of Steve’s argument against Flash and its performance and CPU usage here in the context of a mobile device are valid, albeit misdirected.

From what I understand mobile safari doesn’t even have a browser plugin model, and I DON’T THINK APPLE SHOULD HAVE TO MAKE ONE AND PROVIDE A WAY FOR FLASH TO WORK IN MOBILE SAFARI. However I don’t believe that apple should even be able to ban flash. If Adobe was to work with Opera’s Iphone Browser then that should be fair game. Maybe flash will run slow on it, and the experience wouldn’t be as good for video as H.264 on safari but it would be an option. The market should be able to choose. Also Adobe should even be able to take the open source Webkit engine and make their own browser plugin model and bring their own browser to the iPhone if they wish. Sure the browser may be slower and resemble more the browser experience on android but that should be their prerogative.

Anyhow the Packager for Iphone  in Adobe Creative Suite 5 is a totally different beast, and should be treated differently and most of Steve’s arguments don’t even apply to it technically. The packager for IPhone is more like a 3d game engine. It talks directly to the iPhone APIs (most likely the OpenGLES graphics libraries) for its UI and builds a UI on top of that will code most likely written in C++ that is as finely tuned and engineered for graphical performance as any game engine. Also unlike many existing iPhone games that have somehow managed to shirk an existing apple prohibition on interpreted languages (3.3.2) and use languages like LUA for their game logic , the flash packager, like MonoTouch, compiles its language into native assembly code that statically binds with the iphone libraries, the same as Objective-C does. This last part is very important and really nullifies any justification apple could legitimately have against the flash packager or tools like MonoTouch.

However even 3.3.2  is draconian and the market should be able to decide, and good developers can make applications in interpreted languages run well, and they should have the flexibility to be allowed to. Also in the case of games, game engines are finely tuned and well-engineered, so even if the game logic is written in a slow interpreted language 95+% of execution time isn’t spent there but rather inside the C++/assembler game engine and the 3D graphics drivers from the vendor. If game developers who focus on performance like a religion are able to with good engineering creatively use interpreted languages to be more productive in writing game logic then that innovation and productive toolset should be allowed, as should even the flash packager and other frameworks.

Addressing Steve Job’s open Letter

So let’s breakdown Steve’s misinformation in his Thoughts of Flash letter.

Open Vs Closed

First he brings up the Open versus Closed. Yes flash is proprietary but it’s much more open that the IphoneOS. Adobe doesn’t police who makes what to run on flash. Developers can make any type of flash animation, application of video that they please, and they don’t even have to use Adobe tools to do so. Its open enough, unlike IphoneOS , that third party tools such as Swish can produce Flash content, and even many metaprogramming tools can generate Flash content on the fly. The only closed aspect of Flash is the player, just as say Internet Explorer is closed, yet though I’m uncertain, a third party could likely implement a SWF flash player if they choose to invest in that just like Mozilla and Apple both chose to invest in many web browsers that rendered HTML.

Web Standards

Next Steve started evangelizing open standards on the web. This is hypocritical and misguided on many fronts. First of all this can be applied to flash as a browser plugin, but not the flash packager, as like monotouch and Apple’s own xcode and objective-C . That isn’t the web that is an IPHONE application. In fact many of the applications that would have been developed with the flash packager would have nothing to do with the internet. many would have been standalone casual games that run totally offline. If he criticizes that for not being Open Web Standards, then there should neither be any appstore and objective-C applications and everything on the iPhone should be web apps.

Also apple’s stance on standards is quite a charade. They criticize Microsoft for not being standard compliant (while many of the standards derive from Microsoft’s own proprietary innovations to the browser over the years), while implementing nonstandard webkit-this and webkit-that extensions left right and center such as webkit-min-device-pixel-ratio. They do this  with the audacity of calling those extensions “emerging standards”.  This is no different than Microsoft’s own vector based enhancements and directX effect additions like filter:Alpha(style=2) . I actually have NO PROBLEM with apple doing this, nor did I with Microsoft. I just have a problem with Apple claiming one thing and doing another. The fact is innovation requires this. There are things of the traditional web that didn’t work well on the small screen and didn’t interface well with touch, and it is fine for Apple to innovate here.

Later in the letter Steve labels Flash as a kind of technology that is the Lowest Common Denominator. This is something that I say is true of Browsers, and also standards in general. Standards though with their value inhibit innovation. If this wasn’t the case then there would be no need for native iPhone applications and 3d games and top grade applications on the iPhone would be able to be made easily in a browser and would run fast.

As for his third point on reliability security and performance, I really can’t comment about flash as a web plugin, especially on a mobile device. Let’s come back in a year or so and see how it’s gone on Android. However as previously explained this is a moot point for Adobe’s native Flash compiler.

Battery Life, H.264 and animation performance.

Now for battery life. I don’t have any benchmarks, but based on my understanding the native applications shouldn’t wear any harder than an objective-C application. UI with rich animations will likely utilize the graphics hardware and that uses battery a lot faster. I notice all the time that my iPhones battery goes dead a lot faster playing games than using simple UI applications and this makes sense technical whether it’s being driven by Objective-C , flash or MonoTouch. Graphical intense applications use the graphical hardware as well as use the CPU more intensively than applications that are idle waiting for user input. He also compares flash rendering using CPU versus iPhones rendering using hardware And the battery life is hugely different. However flash on iPhone rendering H.264 would also use the hardware and the battery usage would be comparable.

On the H.264 front. Adobe had implemented that as its preferred high quality codec before the iPhone even came on the scene so I don’t know what Steve is referring to when he says “recently”. Also on the open standards front  Browsers (and apple) are choosing to use the non-open H.264 codec for video. This requires licensing and in the future even royalties (though that has recently been deferred for about half a decade). H.264 isn’t for everything either. Other codecs that flash uses are suitable for smaller sized videos with a lower frame rate.

Flash is more than just for playing videos. It’s for animation, and the speed of flash animation is FAR MORE PERFORMANT than the speed of HTML5 animation. There have been many tests done with simple to advanced animation that show this. A simple animation that may get 30 odd frames per second in flash compares to the best written HTML5 version with about 2 frames per second. So out of HTML or FLASH, which is the lowest common denominator?

Touch Touch Touch

Next up is the issue of Touch. Oh yeah Touch, it’s the reason I love my iPod touch and my iPad. Yes its true there is a lot of flash content that works with hovering and dragging. Hovering doesn’t work with touch, and dragging is something that the IphoneOS chooses to take control of and not pass through to the browser directly as it manages it for scrolling itself. This isn’t a flash problem this is content for one medium working on another medium. You have the same problems with a lot of Web content. Rich web application often use dragging and dropping, and hovering has been a mainstay of web design for many years. I’ve been frustrated on my iPad not being able to interact with standard compliant web pages that depend on hovering from showing things to interacting with menus. The truth is to work in a desktop and touch world developers of apps and webpages alike have to adapt and you can bet your bottom dollar that developers will update their flash apps to be touch friendly.

This is even truer for the iPhone packager. With that people are designing applications specifically for the iPhone and iPad and Adobe has exposed the touch functionality to be as flexible and as natural as any iPhones application. It’s true that these apps will have to be rewritten but why do that then instead of using “modern” technologies like HTML and JavaScript?

There are a few reasons. One you may only need to rewrite 5 to 10% of your application to make it an excellent touch application tuned specifically for the iPhone and running well on the iPhone compared to rewriting 100% to convert it to a web app, where the web app wouldn’t be in the app store, and it wouldn’t be able to use the full power of the Iphone, and as mentioned above its animation would be second rate. Besides Flash’s Action script is a close cousin to JavaScript and on the iPhone has the advantage of rather than being interpreted like JavaScript in Safari is, it is compiled to native code like Objective-C or C++ or C# with MonoTouch.

Third Party Layer argument. (API/SDK/Library/Engine)

Next is the last argument and the clincher but also flawed to its core. Steve argues that a third party layer ultimately results in sub-standard applications. Here I’m going to talk about tools and platforms and languages that go far beyond flash

First I’d like to separate “third party layer” from Language. Flash has a language ActionScript that gets compiled,

And then it will have its own libraries with its own UI layer, that basically just wants a surface to draw on, not unlike a HTML5 canvas, or a OpenGL surface that games use. It is not likely using Cocoa for its UI, because Cocoa isn’t the appropriate API for animation. OpenGL is. With existing iPhone applications  Some use CocoaTouch while others use the drawing APIs of the IPhone and others use OpenGL. Games typically use OpenGL. Some small applications that are little more than a pretty effect may call openGL directly and others especially games with have one or more layers in between. Graphical drawing engines, and game engines. Some of these game engines will have a higher level of abstraction and be larger and have more layers than flash will. This is just how complicated software is made and engineered and it’s ridiculous for Apple to prohibit this, and if they do they need to be consistent and pull the majority of games from the app store also.

In preventing flash, with 3.3.1 Apple is also incurring much collateral damage, whether intention or not. Frameworks like MonoTouch actually don’t have such a third party layer as they are designed to integrate naturally and effectively with CocoaTouch directly yet they are penalized because the “original language” before compilation happens to be something other than apple’s pet language – Objective-C.

There are many substandard applications in the App store currently , not because they use a third party layer, but because they don’t have the well luxury of having an engineered and tested third party layer already doing the difficult things for them. These applications crash and have memory leaks as web developers who may have experience in design tools like flash and html, and who can tinker some in a forgiving language like JavaScript come crash bang up against a systems programming language like Objective-C.

Objective-C is a language that stagnated for more than 20 years after losing the “C replacement” battle to C++. Don’t get me wrong I actually enjoy Objective-C and though adept at C++, I’d much rather writes Objective-C with COCOA than doing C++ with COM on windows. However restricting developers to languages and tools that don’t have the innovation and growth of programming languages over the last 20 years is ludicrous. There has been much innovation (such as memory management) and the truth is for certain types of applications it costs experienced developers more time and thus money to build the same thing with different languages, and time is money. Imagine if all web pages on the internet had to be made in Objective-C?

Steve also says that cross platform languages don’t let any one particular platform shine, and this is true to a point and will happen regardless. Certain sized developers will only put in enough effort to get their application running and won’t tweak it to take advantage of the unique aspects of each platform, but in a competitive world it doesn’t end here.

Let’s use games as an example. Large game companies put a lot of effort in building and tweaking their 3d engines and game engines for each platform they are on. They spent years and millions of dollars doing this and they want their games to utilize the unique features of each platform and push each platform to the limit. This may not be the case with casual games, but it is the case with major games. So do they write each game from scratch in a different language on each platform? No they don’t they write whatever is unique for each platform , and abstract their engine into one of these “third party layers” and have the bulk of the game be the same on each platform. They do go and add special features and tweak things per platform (and sometimes on PC per graphics card) to get things just right.

So let’s say I’m to write an application, if allowed using C# with Monotouch on Iphone OS, and I’m also going to write the same application for Android and Windows Phone 7. The common “business logic” and non-specific and non UI code I would write in C# classes that would be able to be reused on each version; however I’d write different UI for each. On iPhone I would use CocoaTouch, on Windows Phone 7 I’d use its Silverlight based UI and on Android I’d use something , I don’t know what but something different than the two of those. The UI coding may be about 20% of the development effort, but rather than having to make inferior applications but rewriting 100% of each platform, I have extra time and budget to tweak the app for the platforms I care about such as the iPhone. Also my application would really like to run in the background. Easy on Android, but for iPhone I’d write special code to use the new iPhone OS4 background abilities, and write special code for whatever mechanism Microsoft Releases for its mobile OS. I would do this because I want my app to be good and competitive. If I can’t do this, then I’d probably end up having to rewrite my app fully in Objective-C and do a half-baked job.

Challenging Steve’s conclusions.

Steve said that Flash is from the PC error era and for PCs and Mice. I think that was the context it was in, but you could say many aspects of the iPhone OS were from a unix server error and designed for servers. It’s a ridiculous point. CS5 Flash packager proves it can do touch and do it well, as can other languages and toolkits. Steve please don’t stifle our innovation, our creativity and our livelihoods. Steve also says that the mobile era is about Open Web Standards yet reality shows otherwise, it says it’s about proprietary native applications, whether for iPhone, android or windows mobile 7. How many iPhone targeted webapps are there compared to app store apps? How much time do iphone users spend in native apps compared to webapps (other than just generate website browsing)? Steve makes so many points against Adobe that just don’t stack up to reality or which could be thrown back in Apple’s own hypocritical face.

Class Action Lawsuit

I don’t know much about class action lawsuits nor what groups they can be based but it doesn’t seem that it would be right or legal for Apple to affect so many companies’ livelihoods and investments on a whim. I don’t know how many millions of dollars Adobe put into R&D for Flash Packager nor how much investment Novell put into MonoTouch , or their customers have put into building applications with MonoTouch. I know unity3D has invested years of R&D into their excellent game engine with great tools targeting the IPhones ecosystem with their many customers who have invested untold money and time building their games for the iPhone OS. Then there is the phoneGap, and Titanium companies and customers. the total sum of these developers , and companies compounds to significant losses and damages, and on top of that you can add the losses of their customers who bought applications on the app store which now probably won’t be allowed to be updated so people invested in apps via the appstore that are forced to not have a future. Maybe a class action lawsuit could be extended to appstore denials for many of the other arbitrary reasons why 1000s of apps have been denied or removed. Maybe the biggest anticompetitive aspect is the locked down app store and lawsuits could force apple to allow alternative or open methods of application delivery to the IphoneOS just as other operating systems like windows allows application distribution without approval (though vendors can choose to get windows  logo certified or such) through the internet, and various installer technologies, from usb sticks, from CD roms etc.

Antitrust Violations

Some people question antitrust as in that Apple isn’t a monopoly in the smartphone industry, but the thing is the iPhone ecosystem is large and is an industry in itself. If a company was a monopoly in say cable television you couldn’t say it wasn’t such because it’s not a monopoly in broadcasting and it actually only has a small share of the whole broadcasting industry. As such Microsoft is clearly a monopoly or near monopoly in the OS realm (and some other realms) but not in the computer software industry as a whole.

I’m glad to see that the government is at least looking into this. Which seems triggered by an Adobe complaint.

Another clause 3.3.9  (read about it at wired news ) which I wasn’t paying attention to but is in the same vein may be extra fodder against Apple in antitrust matters as again with the stroke of a pen they crush an already blossoming industry with players like admob that were valued at > $750 million . Individual apps or ad networks suddenly have a huge part of their existing product feature set (being able to analyze whether people clicked on their ads or not) disallowed so that apple’s new iAd platform can have exclusive dibs.

Final thoughts

A huge aspect is how will Apple (and others)  interpret this & how consistently will it be enforced, however as software development companies we can’t trust such risks based on the mood of Apple from one day to the next.

and by the way , i don’t really personally care if flash packager gets accepted on iphone. I don’t think i will develop for flash again, but i am fighting for the freedom for all developers to be able to use the tools of their choice that work and the freedom to not have your livelihood threatened by companies like Apple abusing their position but changing rules on their whim. This is professional software development not a 1st grade playground where a bossy kid just keeps changing the rules of the game so they are the only winner.

This is only a draft and I’m sure I’ve made many spelling and grammatical errors and probably a few times missed a word negating my meaning entirely. All comments and corrections are welcome.

Also here i want to gather a list of links to all good commentary on this issue. Links and suggestions would be appreciated. I’ll start with a few

Steves Letter – http://www.apple.com/hotnews/thoughts-on-flash/
Miguel De Icaza – http://tirania.org/blog/archive/2010/Apr-28.html

More links to come, i need to get to bed for now.

Karl Prosser

Posted in Powershell | 9 Comments »

SQL Order By with Nulls at the end.

April 27th, 2010 by Karl

I wanted to order a column alphabetically however NULLS show up first. I want the items will null, but i want them after the rest so i applied this like quick and dirty order by clause.

order by isnull(displayname,’zzzzzzz’)

it effectively puts nulls at the end. If you know a cleaner and just as pithy way I’d love to hear it.

Posted in SQL | 3 Comments »

Collate IP information in PowerShell with WMI

March 20th, 2010 by Karl

This uses my AS function to make the expression more declarative but basically its a wrapper around win32_networkadapterconfiguration that projects and flattens the data in a nice Pscustomobject that is easy to use in scripts and export to csv files or whatnot. I use this to do inventory on IP settings over our whole network

function get-ipinformation
{
process {
    (Get-WmiObject Win32_NetworkAdapterConfiguration -computer $_ ) | ? { $_.IPenabled } |
    select (AS Server , __server,
        DNSHostName ,  DNSHostName ,
        Mac , Macaddress,
        Description, Description,
        DNSDomain , DNSDomain,
        FirstIPAddress ,{ ($_.IPAddress) | select -first 1 },
        IPAddressAll , { [string] $_.IPAddress} ,
        IPSubnet , {($_.IPSubnet) | select -first 1 } ,
        IPSubnetall , { [string] $_.IPSubnet },
        DefaultIPGateway, { ($_.DefaultIPGateway) | select -first 1 } ,
        DefaultIPGatewayALL, { [string] $_.DefaultIPGateway },
        DHCPEnabled , { [bool] $_.DHCPEnabled },
        DHCPServer,  DHCPServer,
        PrimaryDNSServer , { ( $_.DNSServerSearchOrder)[0]  },
        SecondaryDNSServer , { ( $_.DNSServerSearchOrder)[1]  },
        AllDNSServer , { [string] $_.DNSServerSearchOrder },
        WINSPrimaryServer , WINSPrimaryServer,
        WINSSecondaryServer , WINSSecondaryServer,

        #random ones
        DomainDNSRegistrationEnabled , DomainDNSRegistrationEnabled,
        FullDNSRegistrationEnabled , FullDNSRegistrationEnabled,
        DNSDomainSuffixSearchOrder, DNSDomainSuffixSearchOrder,
        WINSEnableLMHostsLookup , WINSEnableLMHostsLookup
       )
    }
}

#requires the follow function
function new-selectexpression
{
if ($args.count -eq 1) { $theargs = $args[0] } else {$theargs= $args }
if ($theargs.count -gt 1)
{
for($loop=0;$loop -lt ($theargs.count-1);$loop+=2)
 {
  @{Name=$theargs[$loop];Expression=$theargs[$loop+1]}
 }
}
if (!($theargs.count % 2) -eq 0) {@{Name=$input[$input.count-1];Expression= invoke-Expression "{}" } }
}

Posted in Powershell | No Comments »

ShellTools Releases Pop Connector

March 11th, 2010 by Karl

ST POP Connector for Exchange server is designed as a replacement of the POP3 Connector in Small Business Server,
but can be used with any Exchange or SMTP server.  ST POP Connector provides the following benefits over the default POP3 Connector in SBS

  • Download email as often as once per minute
  • Supports leaving emails on the POP server for a specified number of days or indefinitely
  • Ability to only download emails from the POP server from a particular point in time, preventing emails that have already been downloaded from from being duplicated (This is very helpful if the POP state file is lost and you are setting up the mail accounts for a second time or if you are transitioning from using Outlook to download the POP email and keeping a copy on the server)
  • Ability to archive messages
  • Supports all versions of Exchange or any SMTP server
  • Supports downloading from GMail, Hotmail, Yahoo and other online accounts with POP access
  • Supports SSL connections
  • Detailed logging and debugging viewable in a log file and Event Viewer
  • Large attachments

popconn1

There are also very interesting possibilities and uses used in conjunctions with a product like Gmail for your domain where you can have Google for your domain being the main place email is landing, giving you a free “online backup” as well as not requiring an enterprise grade always on internet connection for your SMB exchange server, and also not having to waste incoming bandwidth of the 90% of mail traffic which is spam. Using this you’d also get free spam protection from Google mail. However you still will be using exchange and outlook thus getting the best of both worlds, having that enterprise quality exchange/outlook business experience.

popconn2

We are providing ST POP Connector for FREE for up to 3 mailboxes and
the full version is free for Microsoft MVP’s.  Just email us with a link to your MVP profile to info at shelltools dot net.

To read more or to Download it go to http://www.popconnector.com

Posted in Powershell | 1 Comment »

Interesting Effect (bug) with Consoles and Processes.

February 11th, 2010 by Karl

I was having an odd behavior with Portable PowerShell where if i started it from CMD it would take turns between giving a CMD.exe prompt and a PowerShell Prompt and take turns running them.

image

So in this test app, you can see we are first in CMD, then we run this application then after than its alternating between CMD and PowerShell Prompts and you see the expression 1 worked in PowerShell while having a problem in CMD.EXE

So i hear you say what’s the source code for this little demo? – I’m glad you asked

class Program
    {
        static void Main(string[] args)
        {
            var p = new System.Diagnostics.ProcessStartInfo("powershell");
            p.UseShellExecute = false;
            System.Diagnostics.Process.Start(p);
        }
    }

So why is this happening. Well normally when a console application calls another and they run using the same console window the first one is effectively paused while the 2nd one is running, then when the 2nd one exits it resumes.

so the flow here if it were working would be

CMD –> TESTAPP –> POWERSHELL

CMD naturally is waiting for testapp to exit, then in the sample code TESTAPP starts powershell, but i forgot to waitfor powershell to exit before proceding, so TestApp and PowerShell are sharing the same console for a split second then TestAPP Exits, and when TestApp exits CMD regains control of the console.. Now you have too totally separate programs CMD and POWERSHELL competing and using the same physical console window.

The fix is really simple.

.

class Program
    {
        static void Main(string[] args)
        {
            var p = new System.Diagnostics.ProcessStartInfo("powershell");
            p.UseShellExecute = false;
            var proc = System.Diagnostics.Process.Start(p);
            proc.WaitForExit();
        }
    }

 

Not really a biggie, but i thought it would be an interesting thing to share, and probably the cause of a bit of hair pulling  by many.

Posted in Portable PowerShell, Powershell | No Comments »

« Previous Entries