So what does this mean ?
- I am now using a string to store all the html code as I build it up through the script as blogged by Jeffrey here
- I am now using $env:computername rather than localhost - Thanks to Jeffrey Hicks, your right it does look better !
- I am breaking from my switch statements correctly (schoolboy error on my part)
- I am now using a terminating error where needed
- I have changed the keyboard map switch statement into a hashtable
- The code is now over 100 lines shorter and now fits into http://poshcode.org (Cool)
Jeffreys parting comment was:
It would be a lot faster as well.
Again - awesome script!
Cheers.
Jeffrey Snover [MSFT]
Unfortunatly although I will agree with the awesome script part when I ran some tests to see if the script ran faster, which I was convinced it would, mainly due to only writing the content out at the end rather than one line at a time I had some supprising results:
PS C:\Audit> measure-command {& "C:\Audit\OldAudit.ps1"}
Days : 0
Hours : 0
Minutes : 0
Seconds : 14
Milliseconds : 57
Ticks : 140570477
TotalDays : 0.000162697311342593
TotalHours : 0.00390473547222222
TotalMinutes : 0.234284128333333
TotalSeconds : 14.0570477
TotalMilliseconds : 14057.0477
PS C:\Audit> measure-command {& "C:\Audit\Audit.ps1"}
Days : 0
Hours : 0
Minutes : 0
Seconds : 18
Milliseconds : 480
Ticks : 184803922
TotalDays : 0.000213893428240741
TotalHours : 0.00513344227777778
TotalMinutes : 0.308006536666667
TotalSeconds : 18.4803922
TotalMilliseconds : 18480.3922
Can anyone shed any light on this as frankly I'm baffled ?!
Thanks again for all the comments on the script and the new version is below:
A sample of the output can be viewed here (best viewed in Internet Explorer):