Thursday, June 13, 2013

What I learned at the Scripting Games - Finale!

So check out the attached event description. http://scriptinggames.org/ab31cd51bb4dff5f19a7.pdf

This one was a lot more difficult than others in the series and not just because to test your script you needed a domain to test on!

They’re handling security issues, talking to DHCP, renaming PCs and joining them to domains!

What I saw in this event was bit scary from a security point of view. Many, many scripts with usernames and passwords hardcoded, sitting there in plain text! The justification being “well the instruction was to do that, so it’s ok”. But really credentials in plaintext is NEVER ok! The line has to be somewhere and if it’s not going to be with the boss dishing out the requirements it’s got to be with the guys doing the work! Just take the time and get this stuff right, how do we win over the Bash community if we’re hardcoding credentials into our scripts?

So this was my solution;
$macs = Get-Content c:\macs.txt
$ips = @()
$i = 1

Read-Host 'Please press ENTER to supply the credentials to use on the local servers' | Out-Null
$localcred = get-credential
$localadmin = $localcred.UserName
$localpassword = $localcred.getnetworkcredential().Password

read-host "Please press ENTER to supply Domain Admin credentials" | Out-Null
$admincred = get-credential
$domainadmin = $admincred.UserName
$domainpassword = $admincred.getnetworkcredential().Password
$Domain = "company.local"
$ou = ""

foreach ($mac in $macs)
{
    $ips += Get-DhcpServerv4Lease -cn DHCP1 -ScopeId 10.0.0.0 | where {$_.clientId -eq $mac} | Select-Object ipaddress
}

foreach ($ip in $ips)
{
    $name = "SERVER"+$i
    $pc = Get-WmiObject -computername $ip.ipaddress -class "win32_ComputerSystem" -credential $localcred -Authentication 6 
    Write-Host "Renaming "$ip.IPAddress "to $name"
    $pc.rename($name, $localpassword, $localadmin)
    Restart-Computer -wait -ComputerName $ip.IPAddress
    Write-Host "Joining " $ip.IPAddress " to $Domain"
    $pc.JoinDomainorWorkGroup($Domain, $domainpassword, $domainadmin, $ou, 3)
    Restart-Computer -ComputerName $ip.IPAddress
    $i++
}

You’ll see that at the top of the script we’re asking for credentials from the user and use them in the loop for renaming machines and joining them to the domain. The way we’re capturing them is a bit clunky but this way we’re not storing credentials anywhere. Ok we’re storing them in RAM while the script runs if you want to be pedantic. This is probably one of the more secure methods that was used in Basic Event 6 and that makes me sad.

The rest is pretty self-explanatory. I hooked into WMI and used the JoinDomainorWorkGroup method and again I discovered I was doing things the hard way. There’s a powershell commandlet called add-computer that probably could have done the job.

What I’m noticing about researching things in powershell is that a lot of the blog posts that you find while googling for answers are written for powershell 1 or 2. We’re up to powershell 3 now and 4 is coming with server 2012 R2. There’s lots of new features and commands added each release so things are becoming easier but the knowledge of the “old ways” is still out there online kind of clogging up the ease of use.


The Powershell community needs to create a good way for the novices to find the quickest and easiest solutions to their scripting challenges. The Scripting Games has been a great way to do that. Not sure how well that would scale to millions of scripters but it’ll do for now!

Tuesday, June 11, 2013

Marvel Heroes thoughts after first play through

Ok so I admit it. I'm not finished with the play through. I still haven't killed Doctor Doom. It's worth doing that run a few times it's pretty spectacular. I've done it solo and I've done it in a group. Group wins hands down every time. This game is all about the spectacle!

Playing solo the game feels a bit shallow and repetitive. It's at it's best when you are surrounded by other heroes and the combined power of your team allows you all to decimate entire regiments of Goons in a the opening volley of the battle!

Cyclops blasts with eye lasers
Storm shocks with lightning
Deadpool rains bullets
Ironman launches missiles
Hulk... Smashes.

The over the top visual effects and smoke clears, you look around and everything is dead. There's just enough time for your Spirit (mana) to regen before you hit the next formation of Goons and your group collectively one-shots them all.

And on and on and on it goes.

It doesn't take long to figure out that this game is not focused on fine tuned encounters or complex ability rotations. It's about fast paced action, spamming your foes into the ground with your most OP abilities and the more of the that happening around you the merrier it is for everyone, unless you are one of the poor hapless Goons on the receiving end. I don't think that would be fun at all. Why they insist on charging in and attacking the tidal wave of super-powered destruction I have no idea. Guess you don't have to be smart to be a Goon.

For now it feels exciting and fun, not sure what the end game is going be like once we're through the story and the initial infatuation wears off. I just know that if I'm feeling the urge for the joy that comes with unrepentant, destructive, mayhem; Marvel Heroes is the place to be!




Friday, June 7, 2013

Marvel Heroes - Bit of fun but a bit of a letdown

First Impressions (30 minutes in)
Marvel Heroes is fun. It's odd that the loot that you equip doesn't appear on your character. It's also odd that there are 50 Hawkeyes running around the starting zone.

I dropped $20 and got to play as wolverine right away. It was sweet!

He plays like you'd think he would... Has a charge that can really help with mobility! It costs spirit, which is what we are calling Mana in the Marvel universe.

Got lucky with some early drops and for now little Wolvie's healing factor is higher HPS than any NPC DPS! Hilarity ensues.

Thought it was going to be instanced like D3 but found an MMO style PVE zone packed full of mobs... Saw Thor running about messing stuff up. SWEET! Still a lot of Hawkeyes though!

Impressions after day 1 (10 hours)
Played it for about 10 hours yesterday. Check it out cause it's free but I don't think it's going to change face of gaming. The monetization is too "IN-YO-FACE!"

This is exemplified by some interesting items in their store, you can spend REAL money to buy a stacking buff to Treasure Find. So you can gamble actual currency for an increased chance to acquire better in game items! A CHANCE! You can't just buy the items you have to gamble with real money.

First epic item that dropped was a weapon for Spiderman. But to equip it I would need to buy Spiderman for $15... So you get the OOOH PURPLE ITEM rush... Then realise you have to spend actual currency to feel the warm glow that comes with equipping an Epic!

It's a shame really the core game is pretty good fun. It's Diablo after all. It's well animated and has a great frame rate. You can bash the baddies really hard and they go flying. It creates a great sense of momentum and the hours fly by as you chew through the levels. I certainly felt like my character was an OP cheeze fest from the first time I picked a skill point which is what playing as Wolverine SHOULD feel like.

But then there's the MMO style open world sections, where 5 wolverines, 4 hulks, 76 Hawkeyes and a dozen Ironmen run around killing thugs until a world boss spawns. It's not right and if I'm honest it's downright kooky!

They said it on Penny Arcade, these are 'Characters' and they've been built like they're 'Classes'. Wolverine is a warrior (or possibly a rogue), there can be many warriors (and rogues) but there's only one Wolverine.

Well there SHOULD only be one Wolverine, he runs around saying "I'm there best there is a what I do" and it kinda kills the illusions when there a 5 other identical guys running around saying the same thing while killing bloodless thugs and waiting for WOW style world bosses to spawn.

So a world boss spawns and you get a little UI element that points you at him. You begin to bash your way through the thugs till you find... Say Venom (a villain from Spiderman) he's got 50 superheroes wailing on him many of those are clones of the same superhero. The funky animations cease to make sense as the bosses health is whittled away like we've come to expect from MMOs. So after a few minutes of collective pounding, he dies and drops loot that you can only use by paying to unlock a different character.

Shes no wow killer that's for sure. The worst parts of an MMO combined with aggressive moentization make for a novel but un-fulfilling experience.

Friday, May 24, 2013

What I Learned at the Scripting Games - Part 3

Well the number one thing I got out of this week was that we need to raise our domain functional level to server 2008R2 (at a minimum).

I spent quite a while getting the script to work with server 2003 domain controllers. A point that seemed lost on the crowd.


There are some neat tricks in this script though and I learned a lot because I chose to make it harder on myself. Casting Types, BitWise checks, "filetime" oh and most importantly the CSS for pink mouse hovering!  Credit there must go to my boss Nathan. Well for the mouse over bit... The pink was all me!


If server 2008 was going to be the target platform we could have used something like this;

Get-ADUser | Get-Random -Count 20 | select all the stuff | ConvertTo-Html Blah blah


But I had fun none the less. The scripting games has been really fun and informative. It's really great seeing how different scripters will attack the same problem. Bring on Problem 5!

Also I should being planning that domain functional level upgrade... There's a lot of powershell goodness to be leveraged!


Friday, May 17, 2013

What I Learned at the Scripting Games - Part 2


Script for event 3 has been a hit (so far)! It’s crowd score is tracking above 4 stars for now. That's a big improvement from last week!


This was the problem 

The positive reception seems to be mainly linked to the time spent making the output look pretty with some CSS. Setting the formatting so the script is super easy to read doesn't hurt either.


Script is here as an image because when you include HTML tags the blogger platform gets all huffy.

Someone pointed out that it could be more efficient. I’m doing;
Get-WmiObject win32_logicaldisk -computername $server | Where-Object {$_.DriveType -eq 3} |

Where it could be;
Get-WmiObject win32_logicaldisk -computername $server –filter=”Drivetype=3” |

Mine executes two commands (get-wmiobject and where-object) when the same result could be achieved with one. If this script was running over tens of thousands of hosts it might make a difference. Plus it’s neater with one command.

So lessons learned this week;
  • Make sure you are being as efficient as possible even if your script is only going to be run on one host today... That will almost certainly not be the case tomorrow
  • Spending a bit of effort making the output "pretty" is worth the effort
  • Spending time to make your script readable will help others comprehend what you are doing. It'll also help future you figure out what you were thinking
  • There may still a place for oddball humor in comments! 

Monday, May 13, 2013

What I Learned at the Scripting Games


I'm competing in this years PowerShell Scripting Games 

They come up with a new problem each week, we have a week to write a script to solve that problem. Our scripts are submitted and reviewed by the crowd who can post comments. I've received some great feedback already!

The first script I submitted  received a mediocre reception. Which is totally fair looking at it, there are some real rookie errors in it. It’s great though because the point of the Scripting Games is to LEARN! We've got some of the top people in the powershell community critiquing our work! it's fantastic!


My Script ended up look like this;
$servers = c:\iplist.txt
$report = @()
foreach ($server in $servers)
       {
       $temp = "" | Select Hostname, Cores, Memory
       $cores = Get-WmiObject win32_processor -ComputerName $server | Select numberofcores
       $memory = Get-WmiObject Win32_ComputerSystem -ComputerName $server | Select TotalPhysicalMemory
       $hostname = Get-WmiObject Win32_ComputerSystem -ComputerName $server | Select Name
       $temp.Hostname = $hostname.Name
       $temp.Cores = $cores.numberofcores
       $temp.Memory = $memory.TotalPhysicalMemory
       $report += $temp
       }
$report | Export-Csv c:\drscriptosservers.csv –notype


So far the feedback has been very useful and there is some great learning. This is what I've gleaned.;
  • The script is inefficient because it queries WMI more times than it needs to. We can just make one query per WMI class.
  • PowerShell is great because it’s an object-oriented pipeline. The script sends its output to a CSV, which means the output can’t be piped anywhere else. Best practice is to send output to a PowerShell object and let the user do what they want with it. If they want it in a CSV they can pipe it to EXPORT-CSV themselves
  • When we write scripts for other people we should use the full names of the commands and parameters. That just makes the script “self-documenting” and much easier for to read


Event 3 has opened up so we’ll see how that turns out next week.


Tuesday, April 19, 2011

Not an Abomination at all

There is something interesting happening in the gaming industry right now.


Valve software is using the hype around the release of Portal 2 to promote a selection of indie games available through steam.

The idea is if enough people buy and play games from the “potato sack” http://store.steampowered.com/sub/7586/ they’ll release Portal 2 early.

It’s an interesting strategy, using excitement for a long anticipated product to push 13 titles by independents.

The execution has been great. The community first got wind that something was up on the 1st of April, when they were playing these indie games and Portal 2 themed levels started popping up. They could then follow clues in those games to clues in the real world! It seems quite intricate http://forums.steampowered.com/forums/showthread.php?t=1824635

Then supposedly once enough clues we found Glados@home came online. The idea then being that if enough people played the Portal2 themed content we could reboot Glados sooner.

I must say at first I was offended that they wanted me to spend more money and time to try and get portal 2 early. But hearing the Defence Grid guy having a conversation with Glados was just too funny to miss!

It’s a very interesting promotion and reinforces Valves position as a leader in the ongoing development of gaming in an online world.

Oh yes just FYI - that title won't make sense to anyone but the person to whom it does.