Event 6: My notes…

I must say it feels like it was ages ago when we started games, but we are almost at the finish line. I have no idea who is going to win the whole thing, but I have few candidates in mind that did wonderful job and quite frankly: I was learning from them, not other way around. Looks like I’m getting rusty with whole this “scripting” thing. Puszczam oczko

Continue reading

Event 6: My way…

I must say I was a little puzzled when reading description for this event. For me the main issue in this even is the lack of information about DHCP server. I assumed this is Windows 2012 (same as Hyper-V host), but I can’t find it anywhere in event description (I may be tired though and simply missed it). To be honest: we are not event told that DHCP server runs on Windows. Puszczam oczko

Continue reading

Quick tip: break a code, differently.

This tip may be helpful to most of people, but is specifically targeted for people who share code on blogs and any similar media where width is issue at times.

So far I had two solutions, depending on the pipeline “type”:

  • multi-command pipeline – breaking on the pipe symbol
  • single-command pipeline – splatting

I avoid backtick (`) as hell, because single whitespace added by potential user after it and whole code becomes broken.

Continue reading

RSAT on Windows 8 works (but fails).

RSAT-is-new-Server-Manager

Today – less PowerShell-ish topic, although PowerShell was both used and was main reason I started this journey. Few days ago Windows 8 RSAT RTM went out. Like many other admins I jumped on this wagon as soon as possible. I’ve installed the package and… nothing happened. I haven’t seen any errors yet tools that are part of RSAT where not present on my box. What I did? Obviously, I went to google and asked for solution. But found only few other folks that had the same issue, and many others who installed this package without any issues at all. Something had to be different, but I had no idea – what?

Continue reading

Gotcha: GUID for Session Configuration

I’m currently working on a small project that will use constrained remoting endpoints together with RunAs credentials. It all went fine until I decided to change part of configuration for a moment to test something. I’m using PSSession Configuration Files all the time, so I decided I will create a new one, different from the one used before and just change configuration of endpoint using Set-PSSessionConfiguration cmdlet.
Read more…

OutputType–why would you care?

WMF 3.0 RC is awesome. It was great in CTPs, even better in beta, but it improves with each following version. One of my favourite additions in RC depends on thing that existed in PowerShell 2, but it was ignored because we could not see any value in it.

The reason for that was simple: it was just a metadata. Unless you would look closely at any command, including self-defined functions, you would never notice it’s there. It changes with version 3. Now knowing in advance what command will output can give authoring tools and hosts ability to act on this information.
Read more…

“Format-{0}”–f ‘List’

Today I would like to write few words about why you shouldn’t work too hard with creating output when PowerShell can do the work for you.

Scripting, as I see it, is a way of taking stuff that “is there” and force it to do my job in a way I want it to be done. If there is something that will do job for me – I will use it. If not – I will create it. So my role is just to build the bridges, not whole road next to the old one.

Obviously, at times you do not know that road already exists. That’s where stuff like Scripting Games help a lot. I for one learned few neat tricks already. But if you fail to see highway and claim to be advanced scripter – be warned, I won’t praise your rocky road that you’ve created next to it. To the point.

Read more…

PowerShell vNext: AST.

What is that?

There is one addition in PowerShell vNext that I look really forward to. In v2 we have parser available. It makes work with PowerShell code easier. But PowerShell team haven’t stopped there. AST (Abstract Syntax Tree) is new concept (at least – to me) and it makes parsing code more interesting: instead of stream of tokens (which is still there with AST and is also more accurate than v2 precedents) we get tree of syntax: from Script to single Statement. Browsing thru that tree may be very hard at first. I tried to use view that seems natural for that kind of complex structures: Format-Custom. The problem that I went into was the fact, that each AST contains “Extent” and “Parent” property. And those properties keep whole code which makes Format-Custom lengthy and impractical. So my first step was to create .ps1xml files to make format and object themselves bit different. I hidden two properties I think are not very useful. You can still access them using psbase on each object – and that exactly the information you get if you try to access them directly. Next step I took was to create simple function that would wrap .NET call to System.Management.Automation.Language.Parser static methods (ParseInput, ParseFile) and make use of them more natural and PowerShell-ish. Then I packed it all in the module, so that I could paste it somewhere and let others use it and complain about things I did wrong (like using global scope to store tokens/ errors).

Read more…

CTP1 to CTP2 gotcha… :)

Ok, CTP2 is out. This is a great news, and a lot of things to play. Newer ISE, finally fixed “killer TAB” in console, Update-Help that picks up data from network and more.

There is one thing you need to be aware of: CTP1 and CTP2 both installed at the same time is a really bad idea. Trust me, you don’t want to see it (any command results in pages and pages of errors, tab does not work, highlighting syntax in ISE is total disaster).

Read more…

PowerShell CTP – Care To Play? :)

PowerShell CTPs are great. When I started to use PowerShell on a daily basis it was already v2 CTP2. And that is the main reason why I know very little about v1 Puszczam oczko It was just so much better experience… Same happens now with v3 CTP1. Once I saw it’s coming – I started to look for a way to get all requirements on my primary machine. I haven’t really played with stuff that is new in version 3 – like workflows. What I concentrate on is stuff that got improved from version 2. And from my perspective there are few I simply could not ignore.

Read more…