Workstation Server Audit

Workstation/Server Audit

One thing I wish I had was more time to re-visit my old scripts and re-write them as I often look at my old script and it sends a cold shiver down my spine as I now know a better way of doing things.

As I was away for the weekend and had no internet connection I took my old Audit Script with me, I had a few personal objectives that I wanted to achieve by re-writing this code and I was also asked by a friend who has started to adapt the code into other formats.

So, this is version 3 of the script, you can see how much I have learnt recently as V1 of this script was over 1000 lines, V2 of this script was 847 and now with the new improved code it is a miniscule 459 lines :)

My main objectives for this version of the script were:

  1. Apply my newly learnt PS Skills to optimise the code
  2. Use a HTML format that worked in all browsers
  3. Make the code easy to follow
  4. Make the code easy for other people to produce similar reports of other systems

When you see the code and use the output I hope you will agree I have achieved each of these. The code now works with all browsers I have tested and is very easily customisable.

Check out a screenshot of the output below:


As before this script can be run in two modes, if you run it as it is you will produce an audit of your current machine or if you run it with a path to a text file it will read a list of server names and audit each machine saving a separate html file for each one.


<SMALL RANT> Someone took my last script and removed my name from the code and then posted it as their own code on a powershell site, whilst I do not mind people adjusting and re-using my code, in fact there is nothing better than seeing how other people use my code I would prefer that you at least make a reference to my site or me in your comments.

I have been under certain pressure to start charging for some of my code which I have resisted as I like contributing and making the life of my fellow admins easier, claiming my code as your own is just plain rude.</SMALL RANT>

31 thoughts on “Workstation/Server Audit”

  1. The download link above does not work and I cannot find this script in GitHub. Any ideas where I can download this?

  2. Below is a little addition you can add to give you User and Group info, i noticed someone else also requested this.

    Write-Output “..Users”

    $adsi = [ADSI]”WinNT://$Target”

    function getAdmins
    {$adsi.Children | where {$_.SchemaClassName -eq ‘user’} | Foreach-Object {
    $groups = $_.Groups() | Foreach-Object {$_.GetType().InvokeMember(“Name”, ‘GetProperty’, $null, $_, $null)}
    $_ | Select-Object @{n=’UserName’;e={$_.Name}},@{n=’Groups’;e={$groups -join ‘;’}}}}

    $MyReport += Get-CustomHeader “2” “Users”
    $MyReport += Get-HTMLTable ( getAdmins )
    $MyReport += Get-CustomHeaderClose

      1. Just in case you have a locked down environment like I do. The only way I could get this script to run without signing it was to run it as: Set-ExecutionPolicy Unrestricted
        Not the preferred method of doing things, but I got it done and I love the result. Thanks!

  3. A little help? I’m not sure what’s up here…
    Audit.ps1 is not digitally signed. The script will not execute on the system
    . Please see “get-help about_signing” for more details..
    At line:1 char:12
    + .\Audit.ps1 <<<< Servers.txt
    + CategoryInfo : NotSpecified: (:) [], PSSecurityException
    + FullyQualifiedErrorId : RuntimeException

        1. Ok then your execution policy may not have been set, did you follow the response and read more about execution policies ?

          Normally people will set their executionpolicy to remotesigned like this:

          Set-ExecutionPolicy RemoteSigned

          1. Yes, and I did it again to be sure and here is my result after running: PS C:\*****\*******\*****\PowerShell Scripts\Server Audit> .\Audit.ps1
            File C:\*****\*******\*****\PowerShell Scripts\Server Audit\Audit.ps1 cannot be loaded. The file C:\*****\*******\*****\PowerShell Scripts\Server Audit\Audit.ps1 is not digitally signed. The script will not execute on the system
            . Please see “get-help about_signing” for more details..
            At line:1 char:12
            + .\Audit.ps1 <<<<
            + CategoryInfo : NotSpecified: (:) [], PSSecurityException
            + FullyQualifiedErrorId : RuntimeException

  4. Hello again Alan, for the printers part of the script could the share name and printer driver also be added?



  5. Thanks for the script Alan. Could you also add the path for any installed software? and for the network card information could you also add the virtual network the card is attached too or its Windows label name?



  6. To run this script do the following:

    – Create a .txt file containing Server\PC names with each machine on a new line.
    – Call it anything you like and save it to the same place as Audit.ps1.
    – Run up a PowerShell Command Prompt (Start>All Programs>Administrative Tools>PowerShell)
    – Navigate to the folder where the Audit.ps1 script is
    -Type this:

    .\Audit.ps1 (your_server_txt_file).txt

    Yup that easy! and dont feel stupid, from v1 to v3 I could not work it out either until a team mate said try it. :)

    The .\ before the .ps1 file is all about permissions or somehting.

    Im not a script person im a lazy GUI Based Gen Xer

  7. Great script

    I have one problem I can’t get it to run with a text file. Can some help me. need to perform and audit.


  8. A great script.
    I’d like to modify it, but need some help.
    I would like to exclude the Event Logs part and include Members of the Administrators group.

  9. Very good script, many thanks for it.

    Is it possible to show the installed roles for w2k8 servers and also show the websites which are configured, including the portnumbers?
    A nicer display would be with more than one ip-address the subnetmasks right behind it and not on the bottum.

  10. A very very handy script, thankyou! One question though, why are you saving the file as ASCII? When auditing a Windows 2008 server, the OS name comes out with “?”s (unable to display the ® symbol) in the text. Switching it back to Unicode resolves this and I was just wondering why you chose ASCII over the default? Thanks!

  11. Great script my friend! One option which would be welcome would be limiting the number of event logs collected to some set number. Running this report in a larger environment for a client who keeps obscenely large event log files can really take a very long time :)

  12. I’m staggered that people can be such pr1cks to steal your hard word. I know you don’t want to give them credit by naming them, but I’d love to know what sites sanction this sort of behaviour. Thanks heaps for the script – very impressive, and I”m planning to use some of your ideas for an internal audit – rest assured, I’ll leave your name and details in the scrtip !!

    Thanks again.


Leave a Reply

Virtually everything is POSHable

%d bloggers like this: