Whenever I work with Active Directory and I want to use pretty complex LDAP Filter to search for objects I’m after I’m tempted to use line break here and there to make whole thing easier on eyes of future reviewer (even if the only person to read the code is me “few weeks later”).
Tag Archives: Scripting Techniques
Quick tip: regex groups and ‘-split’
If you use –split as often as I do you probably had occasional issue with understanding why certain splits work as expected, and some produce results different from what you anticipated. Recently one of MVPs, Oisin Grehan, shed some light on the reason why this is the case. I thought it might be worth sharing in case you’ve had this issue and you are pulling your hair trying to figure out what’s going on.
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.
Event 5: My notes…
We are very close to the end of Scripting Games 2013. But before we finish with event 6, time to say few words about event 5… This time I will focus on things I liked, and things I didn’t like, without paying too much attention to category where I’ve seen either.
Event 5: My way…
It looks like I missed another deadline. Luckily, I’m not participating this year, so the only negative outcome of it is the fact that I will post my solution after most of you already seen entries done by others. I haven’t (I promise!) so you can expect many mistakes you’ve avoided by giving it second, third or fourth thought. I also had no chance to test it on some “real” material like some participants did (yes, I’ve seen your tweets and I’m sure you did it better, thank you for sharing! ). Wonder how I could improve it… Surely – will find out soon. One note: I decided to focus on IPv4. Mainly because I started so late, and didn’t wanted to spent too much time on handling IPv6 addresses, that are less obvious to match with regular expression (IMO).
Event 4: My notes…
Active Directory is one of those things I just love to work with. That’s why I was looking forward to the entries in this particular event. I found out few things I was not aware of while reading some of the entries, but also seen some mistakes that I would like to highlight. As always: I will start with Beginner category “positives”, and move on until I get to “negatives” in Advanced category.
Event 4: My way…
I’m bit behind the schedule with this event. That happens: life sometimes interferes plans.
Also, today I wanted to focus on two parts of assignment: 20 random users, translating Active Directory date into nice (DateTime) format.
Event 3: My notes…
Time to summarize 3rd event of Scripting Games 2013. I must admin – I learn few new tricks while reading entries for this event. But I still see some things I really can’t stand. Especially in beginner category, where many people decided that putting everything in one line makes it “special”. It doesn’t. If you still think it does – read this article by Richard Siddaway. If you still think line break is cursed – read it again. Repeat.
Event 3: My way…
Looks like we just passed mid-point in Scripting Games 2013, at least for fun part: writing scripts. I must say that I really couldn’t find anything that I’ve seen as “learning experience” in this one – we already did more complex WMI reporting in previous event. We were requested to create very basic HTML report, and we have cmdlet for that. So… I guess I just went lazy with this one. No real error checking, because design claims all have been taken care of. Sweet.
AST ‘splatting’ with static methods.
Have you ever wanted to use splatting outside it’s normal use with PowerShell commands? Splatting is great to pass (named) parameters to commands, but there are other elements that have named parameters. Perfect example: static methods that exist on .NET types. Unfortunately, in current version of PowerShell we can’t extend splatting concept to other language elements. But I guess a lot of people would agree with me: it would be great to be able to do something like:
$ToSplat = @{ format = "Using 'splatting' hashtable: {0:N2} and {1:N3}" args = [math]::PI, [math]::E } [string]::Format(@ToSplat)
It may happen one day, but can we do anything about it now? Well… sure!