RSS

Category Archives: Automation

PowerShell – Book review of : Windows PowerShell Best Practices

Windows PowerShell Best Practices

Last week I completed PowerShell Deep Dives which got me excited again to read more about PowerShell. As such, I continued reading the next book on my reading list: Windows PowerShell Best Practices by Microsoft Scripting Guy Ed Wilson.

The book was released late January 2014 and is the most recent book about PowerShell that has been released to my knowledge. This means it includes PowerShell 4.0, Desired State Configuration DSC and references to Windows 8.1 and Windows Server 2012 R2.

In my opinion the book was very well written and contains a good mix of theory, sample scripts and “notes from the field” from many PowerShell specialists. The sample scripts are available for download at Technet Script Center.

The best practices that are described in the book are very recognizable and I had already adopted many of them based on the many great blog posts by the community. In the book they are all bundled and well explained including examples. Where the book really shines though in my opinion is that it describes how PowerShell is used in real-life, how it relates to many other processes within a company and what you need to consider.

I think this book is a must-have for anyone working with PowerShell. For those starting with PowerShell, I recommend first reading the books “Learn Windows PowerShell In A Month Of Lunches” and “Learn PowerShell Toolmaking In A Month Of Lunches” and then read this book.

Notes:

 
 

Tags: , , , , ,

PowerShell – Book review of : PowerShell Deep Dives

PowerShell_Deep_Dives

I’ve had the book PowerShell Deep Dives laying around since August 2013. I had read some parts of it because I follow many of the great PowerShell community members that contributed to it. But I hadn’t gotten to reading it completely yet until now.

The title of the book includes “deep dives” implies very deep technical content and I can assure you, this type of content is present in the book. some of the stuff I still need to wrap my head around to understand properly. On the other hand, other parts of the book are more simplistic which you might not expect from a deep dives book.

The book covers a very broad number of topics and technologies. What I liked is that the articles were written by professionals and community members that are specialized in or are very knowledgeable about this specific topic/technology.

As a result of having the broad number of topics and technologies, not all parts of the book might be relevant to you (especially as a deep dive). I found myself skimming over some parts later in the book since it is very unlikely it is or will become useful for me. This will differ from person to person though, so take a good look at the topics being covered in the table at the end of the article.

All in all it was a good read and I think I’ll use the book mainly as a reference for those times that I need the deep dive insights. The book can be ordered from by example Manning.com and all royalties go to charity: Save the Children

 

Part 1 PowerShell administration
1 Diagnosing and troubleshooting PowerShell remoting (Don Jones)
2 CIM sessions (Richard Siddaway)
3 Collecting and analyzing performance counter data (Arnaud Petitjean)
4 TCP port communications with PowerShell (Boe Prox)
5 Managing systems through a keyhole (Bartosz Bielawski)
6 Using PowerShell to audit user logon events (Mike F. Robbins)
7 Managing and administering a certification authority database with PowerShell (Cadims Podans)
8 Using PowerShell to reduce Active Directory token bloat (Ashley McGlone)
Part 2 PowerShell scripting
9 The 10 PowerShell scripting commandments (James O’Neill)
10 Avoiding the pipeline (Jeff Wouters)
11 A template for handling and reporting errors (Will Steele)
12 Tips and tricks for creating complex or advanced HTML reports with PowerShell (Jonathan Medd)
13 Using and “abusing” dynamic parameters (Bartosz Bielawski)
14 PowerShell type formatting (Adam Driscoll)
15 Scalable scripting for large data sets: pipeline and database techniques (Matthew Reynolds)
16 Building your own WMI-based cmdlets (Richard Siddaway)
17 Turning command-line tools into PowerShell tools (Jefferey Hicks)
Part 3 PowerShell for developers
18 Using Source Control Software with PowerShell (Trevor Sullivan)
19 Inline .NET code (Richard Siddaway)
20 PowerShell and XML: better together (Josh Gavant)
21 Adding automatic remoting to advanced functions and cmdlets (Karl Prosser)
22 Taming software builds (and other complicated processes) with psake (Jim Cristopher)
Part 4 PowerShell platforms
23 PowerShell and the SQL Server provider (Ben Miller)
24 Creating flexible subscriptions in SSRS (Donabel Santos)
25 Inventory database table statistics using PowerShell and SQL Server Management Objects (Robert C. Cain)
26 WSUS and PowerShell (Boe Prox)
27 Provisioning IIS web servers and sites with PowerShell (Jason Helmick)
28 Active Directory Group Management application (Chris Bellee)

 

 
1 Comment

Posted by on June 7, 2014 in Automation, ICT, Microsoft, Powershell, Windows

 

Tags: , , , ,

Introduction to PowerShell – Also relevant for NON Microsoft administrators

Today I had the privilege that many colleagues of mine from Open Line decided to sacrifice their free time and attend my session: “Introduction to PowerShell – Also relevant for NON Microsoft administrators”

The goal of this session was to:

  • Inform people of the advantages of scripting/automation in general.
  • Inform people of the advantages of PowerShell over CLIs and other scripting languages.
  • Inform people that PowerShell is not just for Microsoft administrators.
  • Teach people about the PowerShell basics.
  • Inform people about the many possibilities with PowerShell.
  • Provide people with a lot of practical resources to increase their knowledge and skill.

I really enjoyed the session and got a lot of interactivity and positive feedback. Next up is a follow-up session which will be more of a workshop style.

I’ve uploaded the presentation in PowerPoint and PDF format here:
https://bjornhouben-web.sharepoint.com/Lists/Files/DispForm.aspx?ID=22

Please share this so that others can benefit from it as well.

Notes:

  • I’ve included many useful resources as notes in the PowerPoint presentation, which makes the presentation also interesting to people who are not PowerShell beginners.
  • Also if anyone has suggestions to make the presentation better, please let me know.
 
 

Tags: , ,

PowerShell – Using PowerShell 5 to automate the installation of your favorite Windows applications

In this blog post I will explain why to automate installations of Windows applications and how you can do this.

Why automate the installation of applications?

But first, why is this useful? Well this depends on your situation and there are probably many good reasons. For me though, it basically boils down to this:

  1. I often reinstall my computers with new (preview) versions of Windows operating systems and having to install applications each time is a waste of time. Also sometimes you forget to install some things.
  2. On a regular basis, friends and family either want me to install or upgrade their PC and I want to provide them with a standard set of programs that most people need/want without having to spend a lot of time on it. By example virus scanner, burning program, media player, codecs, etc.
  3. I want to update existing installed applications to the latest (and hopefully more secure and feature packed) versions.
  4. When installing applications, there are often checkboxes enabled to install other applications (you generally don’t want to install). Automated solutions using packages generally prevent these additional unwanted applications from installing.

Which tools to use to automate the installation of applications?

Before PowerShell 5 preview was released, I used both Ninite and Chocolatey to perform to automate installations. They both have their advantages as described on this wiki page.

The PowerShell 5 preview version of OneGet installs and searches software from Chocolatey repositories, but support of additional repositories will come in subsequent versions.

How to automate the installation of applications using PowerShell 5 preview?

To automate the installation of applications a couple of things are required:

  1. You need to determine which applications you want to install automatically.
  2. You need to determine the package name that Chocolatey uses for this application. Options include:
    -Using a browser to browse the Chocolatey packages
    -Using PowerShell and a part of the name of the application you’re looking for. By example if you’re looking for Irfanview, use:
    Find-Package -Name “fan”
  3. Store the package names to install somewhere (e.g. in a .txt file on OneDrive for easy access). My .txt file by example includes:
    AdobeReader
    Directx
    ffdshow
    Flashplayerplugin
    GoogleChrome
    Imgburn
    IrfanView
    Javaruntime
    Keepassx
    Mp3tag
    mpc-hc
    PDFCreator
    Silverlight
    TeamViewer
    Totalcommander
    Winrar
    greenshot
  4. Use the Install-Package cmdlet to install all the packages whose name is in the file from step 3.
    Install-Package -Name (Get-Content C:\OneDrive\AppsToInstall.txt) -Confirm:$False
  5. Wait for the programs to install

My opinion

It’s great to be able to use PowerShell to install my list of favorite applications similar to like I did with Chocolatey and I’m also looking forward to see what benefits the additional repositories will bring in the future.

I did encounter some errors however while trying to install some applications like Firefox and dotnet3.5. But since it’s still a preview, this will probably be fixed.

For regular users, I think they are better off sticking to by example Ninite because they’re often afraid of anything that involves a CLI.

Blog posts by other people about OneGet

Some other people have also blogged about the OneGet module and have gone in more technical detail, so be sure to take a look at their posts as well:

More information about PowerShell 5 Preview including a download link

Windows Management Framework v5 preview, includes also Desired State Configuration (DSC) improvements and NetworkSwitch commandlets to manage network switches that pass the Certified for Windows Program. For more information including a download link, you can read the initial blog post. : Windows Management Framework V5 Preview

 

 

 

Tags: , , , , , , , ,

LazyWinAdmin – a great powershell script for more efficient Windows management

The last couple of months I’ve been playing around a lot with PowerShell and I’ve also been trying to make some nice GUI versions for my script using PowerShell Studio 2012 from Sapien Technologies Inc. While looking for more information how to best use PowerShell Studio 2012 I came across LazyWinAdmin.

LazyWinAdmin is a great tool created by Francois-Xavier C that will save you a lot of time. It provides you with most of the commonly used tools and commands in a very structured and easy to access way. In the picture below you can see what I mean.

For more info on the tool, take a look at the website and be sure to download and test it yourself.

If you want to take a look at other useful tools I’ve found in the past, take a look at my applications list.

 
 

Tags: , , , , , , , , , , , ,

Home LAB Setup guide – 07 Make your lab available over the internet

In the first part of this LAB setup guide, I described the hardware selection process.
In the second part, I described the hypervisor selection and installation.
In the third part, I described VM guest considerations and preparations.
In the fourth part, I described Configuring Server 2012 VM as DC with DNS and DHCP using PowerShell
In the fifth part, I described easily creating (many) proper AD users with PowerShell
In the sixth part, I described creating a local PowerShell v3 Help Repository with PowerShell

In this post I will describe how you can make your lab available over the internet.

When you’ve created your home LAB, you want to be able to use it anywhere. Depending on your situation, one of these options probably best meets your needs.

Examples include the use of:

  1. Remote desktop connection to your server
    + Easy to configure (enable on server and configure NAT forwarding if appropriate)
    – On many enterprise or public networks TCP3389 is blocked by the firewall.
    – Connects only to specific server. Even though you access the rest of the network from there.
  2. VPN connection to your network
    • Using your hardware router
      + Connection to network, not just a server.
      – No dependency on Windows Server
    • Using Windows Server 2008 / 2012
      + SSTP VPN (TCP443), is generally not blocked on enterprise/public networks.
      + Connection to network, not just a server.
      – Dependency on Windows server.
      – Requires more configuration.
      – The root CA certificate for the certification authority (CA) that issued the server authentication certificate needs to be into the store Local Computer\Trusted Root Certification Authorities. For a self-signed certificate, this means that you need to have local admin permissions to add it.Note: DirectAccess is a great feature, but it requires the client to be a member of the domain. And in my case this would limit where I can connect from, therefore I don’t plan to use it. For other situations it might be a better solution though.
  3. Using 3rd party tools like logmein, teamviewer or VNC
    + Connects only to specific computer.

Since I want to be able to connect from within enterprise environments as well, I chose to use SSTP VPN in Windows Server 2012. The basic steps you have to perform, include:

  1. On the server, you have to install and configure the VPN service.
  2. On the server or your own PKI, you would want create and install a machine certificate. You can create a Certificate Signing Request and request a 3rd party public certificate. Alternatively you can create a certificate using your own Certificate Authority, or you could create a self-signed certificate, For creating the self-signed certificate you can use the great PluralSight SelCert tool.
  3. On the client, you have to make sure the created certificate will be trusted. This means you have to add the certificate to local system\trusted root certificate authority if you’re using a self-signed certificate, which requires local administrator permissions on the client.
  4. On the client, you have to set-up the VPN connection to the server. Preferably you want to connect by DNS name. For your home lab you can also utilize dynamic DNS services like by example no-ip.com or alternative solutions.

For some more information, you can also take a look at this:

 

Tags: , , , , , , , , , , , , , , , , , , ,

 
Follow

Get every new post delivered to your Inbox.

Join 866 other followers

%d bloggers like this: