Saturday, August 30, 2014

Documentation–documenting variables in a script/function

A few weeks ago, I gave a PowerShell course during which the issue of documentation came up. The point I made was documentation is a good thing – and the more the better. The delegates really liked the comment based help approach. But it often does not go quite far enough.

One additional thing you can do is to document individual variables. Each variable object lives in the Variable: drive. Variables are , like everything PowerShell, an object. When you get child items of a variable, the variable is returned of the type System.Management.Automation.PSVariable. There are some special PowerShell variables (QuestionMarkVariable, LocalVariable, SessionStateCapacityVariable, and NullVariable). All of these objects have a Description property which enables you to describe each variable.

So you could do this:

$I = ‘10.0.0.100’
(dir variable:I).description  = ‘the new IP address for the new server’
$iold = ‘10.0.1.200’
(dir variable:iold).description  = ‘the new IP address for the new server’
Dir Variable: | Format-Table name,description –a

I’ve not used this approach much, but I probably do so in the future for production scripts at least!

Friday, August 29, 2014

Azure Machine Learning – What is it and Doing it In Azure

Azure Machine Learning is another of those features of Azure I've not gotten around to playing with. Andrew Fryer of Microsoft has produced a couple of good articles on the subject, both in general and Azure specific.

Machine Learning appears to be the new marketing buzzword previously known as data mining. Given enough data, you can mine it to find gold is the basic concept. In his first article, Fryer looks at what Machine Learning (ML) is and some of the basic tasks. In the second article, Fryer looks at exploring and evaluation of the technique to see if it's of value to an organisation.

Desired State Configuration Resource Kit–Wave 6

The PowerShell team has just released an update to the DSC resource kit – bringing the total number of DSC resources to over 80! While the bulk of the resources in the resource kit are ‘experimental’ – they seem to me to be very stable (continuing the PowerShell team’s ability to ship rich, useful, and reliable beta code).

And even better, the PowerShell team seem to have gone back to their old roots in terms of time to market. They appear to be releasing as they develop (and long may this continue). Thus, the new SafeHarbor DSC resource, this was finished after Wave 5 was released but before Wave 6 was ready so the PowerShell team published it separately, then publish it (with updates and bug fixes) a few weeks later in the Wave 6 drop. I can’t tell you how good this feels after so long under the cone of silence.

This latest drop has some very interesting resources, including the xChrome and xFirefox resources that help to deploy these two browsers. The Group resource shipped with PowerShell 4 is updated to provide support for cross-domain account lookups as well as for UPN-formatted names. The new xRemoteDesktopAdmin resource enables. Additionally, Wave 6 has a number of bug fixes to earlier waves. Again – the ability to get these fixes quickly is both useful and much appreciated. 

The  DSC story is slowly coming clearer with both the July drop and these continuingly improving resources. And with Chef integrating with DSC, DSC’s future looks very rosy.  If you are looking to find out a bit more about DSC – I’ll be covering the basics on the PowerShell PowerCamp event in October.

Synchtoy–a free utility from Microsoft

I just stumbled across an interesting utility, called SyncToy. Version 2.1 of this tool is available, free, from Microsoft at: http://www.microsoft.com/en-us/download/details.aspx?id=15155. This is the latest version of this tool, which was first published in 2009, so it’s not really new.

This highly customisable tool synchronises files and folders between file locations, kind of like a robocopy designed just to synch your files between two locations. You could use this to sync files such as photos, music files etc. with other computers. This might be easier than worrying about backup for these files.

To find out more about Synchtoy, or to ask questions – see the synch toy forum at: http://social.microsoft.com/Forums/en-US/home?forum=synctoy.

del.icio.us Tags:

Tuesday, August 26, 2014

PowerShell V5 July 2014 Preview

As promised by Jeffrey Snover at TechEd US, Microsoft has released a new and updated pre-release version of PowerShell V5. Oddly, I can’t find too many references to it, but here is where you can get the preview:

Note that these versions only install on Windows 8.1 and Server 2012 R2. My main workstation runs Windows Server 2008 R2 and while I know it needs upgrading, I am dreading the upgrade. For now, I’m running this update on just my laptop. Sadly – as this update has a lot of new features.

The new features, described in more detail in the release notes, include:

  • Generation of Cmdlets based on an Odata Endpoint - Export-ODataEndpointProxy is a cmdlet that will generate a set of Windows PowerShell cmdlets based on the functionality exposed by a given OData Endpoint. This feature is still not quote complete as it’s still under development – but this looks a great idea to open up OData to wider use.
  • Manage .ZIP files with new cmdlets – finally two new cmdlets to manage zip files: Compress-Archive creates a new zip file while Expand-Archive allows un-zipping. At long last!
  • DSC authoring improvements in Windows PowerShell ISE. Several new features are added to the ISE to simplify authoring of DSC resources, including the ability to list all the DSC resources within a configuration block (use Ctrl+Space) and lots of improvements to autocomplete/tab complete.
  • Changes in how the DSC Local Configuration Manager is installed.
  • Partial DSC configurations – this, for me, was a missing piece to DSC. Partial DSC Configuration enables you to deliver configuration documents to a node in fragments. This is, for me, a great simplification in how you deploy DSC configurations.
  • Cross-Computer Synchronisation – this improves the built in WaitFor DSC resources. This is highly important for complex multi-node configuration scenarios where you need to sync several systems in order to properly configure them.
  • New DSC cmdlets – there are several new cmdlets, including Get-DSCConfigurationStatus, Compare-DNSConfiguration, Publish-DSCConfiguration and Update-DSCConfiguration.
  • The new Detailed Script Tracing feature enables detailed tracking and analysis of Windows PowerShell scripting use on a system. After you enable detailed script tracing, Windows PowerShell logs all script blocks to the ETW event log, Microsoft-Windows-PowerShell/Operational. If a script block creates another script block (for example, a script that calls the Invoke-Expression cmdlet on a string), that resulting script block is logged as well. I can see this being very, very useful!
  • The *-item cmdlets are extended to enable creation of symbolic links. Yet another cmd.exe feature now with PowerShell parity. YEAH!
  • And of course the latest WMF includes the cool features added to earlier versions, including OneGet, PowerShell Get, Network Switch management

PowerShell V5 is shaping up to be a pretty significant release, with a slew of really cool and, IMHO, important new features. I just hope there will be a version of PowerShell V5 for Windows 7/Server 2008 R2 so I can avoid the OS upgrade on my primary workstation.

Once I have this new update installed on my laptop, I’ll provide some additional feedback. I am looking forward already not only to playing with this new release, but in seeing what else Redmond and the PowerShell team have up their sleeves.

del.icio.us Tags: ,

Tuesday, August 12, 2014

Azure PowerShell DSC Extension

The PowerShell team have just published a new DSC extension to cater for Azure. You can find more information from the PowerShell team's blog post. he blog post shows yow you can use this extension. Before you use these cmdlets, you will need to have the Azure PowerShell SDK (0.8.6 or later) installed. See here to download the SDK.

del.icio.us Tags: ,,