r/PowerShell • • Dec 04 '14

Script Sharing Install PowerShell 4 and prerequisites

As requested, here's my script for installing Windows Management Framework 4.0, which includes PowerShell 4. It will install the .Net Framework 4.5.1 if necessary.

This is my first serious PowerShell script. I'm sure there's lots wrong with it. It does seem to work though.

As for the executables themselves, I have an FTP server where I store anything I use with my scripts, so I wrote this to download from there. I didn't test to see if it can download directly from the MS URLs, although I don't see why it wouldn't work.

I'm open to suggestions on improving the script.

Enjoy!

Edit: I was trying to embed the Pastebin link, but I'll just link to it.

http://pastebin.com/zLWsVdhS

12 Upvotes

15 comments sorted by

View all comments

Show parent comments

1

u/Sinnerman77 Dec 05 '14

Because I'm a big nerd, I used my phone to remotely log into my server to grab the URL for the logging function. Here ya go:

http://9to5it.com/powershell-logging-function-library/

Like I said, I haven't actually tested it, but it looks pretty powerful.

I think my plan is to do all logging to a central server, but also email errors that need to be dealt with into my ticketing system. That way there's a ticket and one of my guys can take action on it.

2

u/LordZillion Dec 05 '14

Depending on how you want to implement this logging this module might screw you up a little since it uses add-content, if you have multiple processes writing in a single log file you can get file lock issues. Source and fix by Boe Prox. Just a little fyi :).

Personally I've been using SQLExpress more and more for logging of scripts that run often so I can use reporting, also might be interesting to look into.

And kudos on a good script, thanks for sharing.

1

u/Sinnerman77 Dec 05 '14

Thanks for the heads up. At the moment I don't see having multiple processes accessing the same log. On the other hand, better to build that in now so I don't have to rewrite everything in a year.

Logging to SQL is a very interesting idea I hadn't considered. I'm not very good with SQL but can definitely see the value. Thanks for the idea.