New updates to PowerShell library

I have added some additional features today as requested to the core library.

* Get-SelfHostedPS is a new command to extract information from compilled versions of ps1 scripts
* New-SelfHostedPS is updated to include some more metadata when generating exe files

* Get-DesktopColor gets the color from the desktop (Windows/Aero) as a Color or Adavanced composition object
* Set-DesktopColor sets the color of the desktop (Windows/Aero) as specified

Read more and download on the PowerShell Library page, if you already have the profile installed just issue the Get-LatestVersion cmdlet. The documentation have NOT been updated yet.

New version of New-SelfHostedPS

Today I have published a new version of New-SelfHostedPS. The command still creates a stand-alone file of a PowerShell script, however some important improvements have been made to increase the usability and also the features that can be supported.

Bigger improvements:
* Can embed the Sorlov.PowerShell.Core.dll library by specifiying -EmbedCore
* Can embed ANY other module (Script OR Binary only – not snapins!). Read more about this below. Use -EmbedModule argument

Smaller improvements
* Compression are in use for all data (so files are smaller – in theory anyway)
* You can specify relative paths for source (ie .\script.ps1)
* You do not need to specify a destination name, it will guess (ie .\script.exe)
* Manifest have been implemented to make sure we can implement even more features in the future

Embedding Modules
To embed a module you must specify one or more modules (PSModuleInfo objects) as argument to the -EmbedModule argument when Calling the New-SelfHostedPS cmdlet. PSModuleInfo objects can be obtained by using Get-Module cmdlet:

The command above would include all loaded modules into the generated EXE-file. Internally the New-SelfHostedPS cmdlet uses the manifest info to decide what to include. It does support nested modules, TYPE and FORMAT definitions. However this is not a guarantee that all dependencies are satisfied. The cmdlet does not check references for dll’s etc. If they are required by the module they should be specified in the manifest information file but I have noted that many have not. So if you need to include modules I would strongly recommend to test the files first Before sending them out.

Also as a last note, instead of embedding modules I would suggest to try and import them from remote machines if possible as it reduces the size of the generated EXE-file.

Read more and download on the PowerShell Library page, if you already have the profile installed just issue the Get-LatestVersion cmdlet. The documentation have NOT been updated to reflect this change yet as I consider it to be beta untill I know that it works correctly.

Password never expires with PowerShell?

A small script to get all accounts in the forrest that have PasswordNeverExpires set. Pretty fast and very easy. Was written as a reply on technet forums.

Hidden hero: New-WebServiceProxy

Sometimes you need to communicate with a webservice. It could be the EXCHANGE webservices or SHAREPOINT webservices. I have seen many examples of code to communicate with the different sources but very seldom anyone makes use of our hero New-WebServiceProxy.

Lets start by getting some weather information for our location. We will use which are some free and easy to use example webservices.

This is now a fully usable proxy inside $service. Let’s look at it:

Which will return a list of all methods:

And lets goahead and call that method with some static info:

Which gives us the result back as XML

Now let’s handle it as XML instead of string..

Which gives the following output:

Sicne we are displaying XML we just see the root-node, so let’s clean it up:

Which gives alot nice better output:

Hopefully this have given you some inspiration to try other webservices..