1249 registered users!!

Today I got my 1249:th registration email for Sorlov.PowerShell library! I get about 2-3 email daily with suggestions and questions about future versions! I love it – keep it comming! And I’m wondering who will be number 1250…

To celebrate this I updated some code in the Experimental DLL. I implemented a simple wrapper on top of HtmlAgilityPack (integrated) that will allow you to pull any HTML file and convert into XML. Why is this a good idea? Well if you wan’t to quickly access/scrape a site (I assume within the legal limits) and don’t wan’t to use the ParsedHTML (slooooow) property of a fetched HTML document. This approach is very simple and very effective! The new command is Import-HTML and accepts a local file or a remote http path as argument and you will get a xml-structure back to work with!

Using PowerShell as default Win+X shell in Windows 8.1

I don’t even know why anyone would use Command Promt (cmd.exe) anymore as the default commandline Shell on the Win+X menu: However in Windows 8.1 the default commandline shell when you right-click in the bottom left corner, or hit Win+X, is just that..

But there is a easy fix: Right-click on the taskbar and select Properties in the context menu, then select the Navigation tab. Select to replace Command Prompt with PowerShell. Save and enjoy!

 

Thank you DigiCert!

Thanks to my good friends over at DigiCert I will change the certificate signing my PowerShell Library (and other binary code) with the next release of the files. So do not be alarmed if you notice the signer changing. They will now be signed by my very own Code Signing Certificate with the CN=”Daniel Sörlöv” courtesy of DigiCert.com.

Not so unexpected update…

As I released the possibility to run HTA-type applications with Invoke-HTApp yesterday you might have guessed that I would release a New-SelfHostedHTApp? Well, I did. The self-hosted HTApps can run without any of my own libraries (just as the self-hosted ps1 files you can produce with New-SelfHostedPS) as EXE, signed or not… a new video of all the self-hosting options I have will be released within a couple of days at youtube.. but while you wait download the lib and make your own self-hosted HTApp…

Do you remember HTA?

If you do you have probably been around a while. But I hope you remember how good HTA was as a quick solution to prototyping or to just make those small quick applications? Anyhow, just a few days ago I was talking to a collegue in my Company complaining about how hard it was to build small forms based applications in PowerShell. Even if there is alot of designers, helpers etc to create it still makes you need to think and now deverloperish stuff. He then said the magic words and asked if he could use PowerShell in HTA. Well you cannot, but I have created the second best thing. A Cmdlet that will parse and execute any HTApp file (kind of a HTML but with some PowerShell in them). That makes it very much easier – if you know some basic HTML you will be able to prototype any application.

The feature have been packed into a new module in my PowerShell library (Sorlov.PowerShell.HTApps). It does require that you have the Sorlov.PowerShell.SelfHosted file and also that you are NOT running on a core-install of Windows. Here is a very breif description. Also as a notice/reminder consider this module yet as NOT production stable as it has not yet been very well tested! I have attached a few very basic examples of a couple of HTApp scripts to get you started.

The HTApps file format is a HTML file. It can also contain code blocks. These are formatted just as traditional ASP-tags <% %>. They are executed BLOCK BY BLOCK so that means that code cannot stretch from one block to another currently. You can execute JavaScript freely and to interact with PowerShell from JavaScript use the PSRuntime:<method-or-prop> syntax . See examples for more information: htappDemos.zip (12.27 kb). Within the HTApp script there are some special variables, $App and $Document described below.

$App which can control the lifecycle of the application and some system events.
Properties
Int Title The window title
Int Width The width of the window
Int Height The height of the window
Int Top Placement of the topmost border of the form on the screen
Int Left Placement of the leftmost border of the form on the screen
Methods
Void Reload  Reloads the current application
Void LoadApp(string) Loads another application
Void Exit  Exits the application
Void ExitObject(object) Exits the application and returns Object on pipeline
string InvokeScript(string) Runs a statement and returns string
Void InfoMessage(string) Shows a asynchronous message (Info Icon)
Void WarningMessage(string) Shows a asynchronous message (Warning Icon)
Void ErrorMessage(string) Shows a asynchronous message (Error Icon)

$Document which is the standard HTMLDocument (as described in http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.aspx) for the application currently loaded.

As always the library installer can be found here: http://sorlov.azurewebsites.net/page/PowerShell-Projects.aspx

Sorlov.PowerShell – v4.0.0.0

Code have been split into several modules again due to popular demand (let’s you minimize size and use only the parts of the library that you wan’t). The installer will only install Sorlov.PowerShell.Core and others can be downloaded using Get-LatestVersion. Probably this will have some improvements over the near future with some “add-remove-feature-feature”. All versions have been harmonised to 4.0.0.0 to make it simple to determine the state of components. Release-notes will be written on a per-product basis. Documentation is in progress meanwhile some cmdlets may be moved around pending it’s final structure, expect additional modules to be released soon (moved from Core that is)

Sorlov.PowerShell.Core – The core parts, common code etc. Must always be present.
Sorlov.PowerShell.SelfHosted – Lets you create and package stand-alone exe files from .ps1 files
Sorlov.PowerShell.MicrosoftOffice – Create and manipulate word and excel documents
Sorlov.PowerShell.Security – For now certificate management (much more planned around PKI)
Sorlov.PowerShell.SCSClient – Supports the Script Server repository for powershell (Experimental)

To install just run the installer, if you are moving from a older version you must run the Get-LatestVersion two times with restart in-between as a very old error was made visible and made the upgrade stop if performed in one step. The installer and older documentation can be found on the “PowerShell Projects” in the right-side menu.

 

 

Microsoft MVP!

 

 

 

There are times you are more happy than others. Today is a very happy day! I got a email about 10 minutes ago..

Dear Daniel Sorlov, Congratulations!

We are pleased to present you with the 2013 Microsoft® MVP Award! This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others. We appreciate your outstanding contributions in PowerShell technical communities during the past year.

I on the other hand would like to thank everyone who listens to my sessions, who help me with events and everything else. I could not have done it without you all.

 

More updates to Sorlov.PowerShell (v3.0.0.1)

Now supporting New-Certificate to make a new certificate either for self-signed or standard X509 certificate and also a simple utility in Find-Certificate that will locate a certificate based on some standard search terms. During the next couple of day you will see parts for CodeSigning and for Timestamping =).

Updates to Sorlov.Powershell (now v3.0.0.0)

It’s vaccation time but some refactoring have been done.

Loads of small tweaks and fixes, and much better errorhandling and overall stability. About 200 minor fixes logged.

* Changed: Integrated all auto-start functionallity of PSLoader library (now only one DLL!!)
* Changed: Prompt and colors are by default set, persistance is not set automatically and needs to be enabled manually from this release (in the data section of the psd1 file). If you have old version and upgrade your settings will not be migrated and you will need to redo them! If the psd1 is not present all intialization will be skipped just to make sure that the system will work under most circumstances.
* Changed: Initialize-PSEnvironment removed and always called on load of the module (and now more error resistant)
* Changed: Save-PSEnvironment renamed to Exit-PSEnvironment and is ALWAYS called automatically but can be called also to manually force a save of persistance data to disk if configured.

Good Hyper-V router

Tried to install DD-WRT today as a router for my virtual environment in Hyper-V.
Worked very well and does not require very much resources so sharing some very simple steps:

 

1. Download Phydiskwrite bundle with GUI from http://m0n0.ch/wall/physdiskwrite.php
2. Download Community version of DD-WRT from http://www.dd-wrt.com/routerdb/de/download/X86/X86///dd-wrt_public_vga.image/3744
3. Create and mount an empty VHD of 50mb from within the DiskManagement MMC console.
4. Start the PhydiskwriteGUI with admin privs. Write the image file to the virtual disk (make sure to select right disk!!) by right clicking the virtual disk and selecting to write image. When you browse for image you must select *.* as filter as it is by default setup for *.img not *.image
5. Unmount the VHD
6. Create a virtual machine with 1 cpu, 64mb ram, attach the VHD and two legacy network adapters (1 to external and one to the host-internal network)
7. Start the VM. It will now have a dhcp running so connect to 192.168.1.1 and configure.
8. Done!