RSS

Category Archives: Powershell

PowerShell – Book review of : Learn Windows PowerShell 3 in a month of lunches, second edition

About 6-7 years ago at school we were taught how to script using VBscript. I was really bad at it though and never really made an effort to change that. When PowerShell became more popular however I had gained some working experience and was also pleasantly surprised by the simplicity of it.

I started learning about PowerShell scripting by googling and using script examples. Disadvantages of this approach however is that:

  • You can pick up bad habits from others (without realizing it).
  • You sometimes don’t know exactly why you’re doing things a specific way.
  • You sometimes don’t know why some things are/aren’t working.

PowerShell is getting increasingly important though:

  • Even though more companies are offshoring and employees are relatively, it is still cheaper to automate instead.
  • Cost isn’t the only issue, speed is important as well. Scripting allows you to get things done more quickly.
  • PowerShell is increasingly being adopted by more companies, products and (cloud) services.
  • The number of available built-in cmdlets are increasing, which makes it even easier to automate actions.
  • For many products you have to use PowerShell to make specific settings, because only the more basic settings are available in a Graphical User Interface (GUI).
  • Changes can be applied consistently in a development, test, acceptance, pre-production, production environment.
    • Less chance of human error.
    • If done correctly, you’ll also have included a way to quickly revert the changes by script.

To make sure I didn’t miss out on too many things, I decided to start with a book that teaches the basics. Because of the good reputation of the authors Don Jones and Jefferey D. Hicks in the PowerShell community, I decided to go for their book “Learn Windows PowerShell 3 in a month of lunches, second edition” published by Manning Publications Co.

The book’s purposely didn’t try to stuff all PowerShell related information into the book. Instead it provided the reader/student with the basics needed to be able to find/discover this information themselves if needed. I personally like this approach, because otherwise there would be too much information to take in which might be demotivating and distracting.

I also liked the practical examples of common mistakes made by people who are new to PowerShell. There were a lot of examples I ran into as well when I started using PowerShell and I think this will prevent people from becoming frustrated because they understand why things aren’t working the way they might have expected.

All in all this is a great book to start learning PowerShell. This is however just the start and you should expect to continue using other resources/books to further your knowledge. The book also provides links to useful resources as well. And most importantly … start using PowerShell more so you will learn by experience.

Personally I still have these books lying around, but haven’t decided yet which one to start with next:

I’m also still considering taking a PowerShell course, but I’m a bit hesitant about the added value because it’s hard to determine the quality of a course by the description.

If you have experiences or suggestions, please let me know.

 
2 Comments

Posted by on February 27, 2013 in Automation, ICT, Microsoft, Powershell, Windows

 

Tags: , , , , , , , , ,

PowerShell – Extract specific info from multiple source winaudit files

I run Winaudit on each server/system and save it to a central location named <computername>.csv                 This way I have access to a lot of information about each system. If you need a specific subset of information for each system however, you don’t want to have to open each file manually to get this information.

This script will parse each <computername>.csv to extract specifc information and save it to one new file containing this info for all parsed separate files.

 
2 Comments

Posted by on February 25, 2013 in Automation, ICT, Microsoft, Powershell

 

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

PowerShell – Use Get-ADcomputer to get a quick overview of your AD environment

One of the tasks in ICT is maintaining an up-to-date and correct CMDB. This is also a hard task and is often not performed (properly).

Luckily however, with the PowerShell Get-ADcomputer you can get a lot of information directly from Active Directory. Try using: Get-ADComputer -Filter * -Properties *

Ofcourse if you have non-domain joined computers or non-Windows based computers you have to come up with something for that as well.

Personally, I use this command to quickly get info about my Home Lab instead of having to document it manually (with the risk of human error):
Get-ADComputer -Filter * -Properties * | select name,canonicalname,dnshostname,operatingsystem,OperatingSystemServicePack,operatingsystemversion,IPv4address | out-gridview

In the image below you can see what it looks like for me:

Get-ADcomputer

You can of course customize it and alter the output method. You could by example add the property Modified to see when it was last changed. You can also add the property Description if this makes sense for you. I did not enter descriptions myself, but for the cluster nodes it has been added automatically and says: “Failover cluster virtual network name account”.

 
4 Comments

Posted by on February 24, 2013 in ICT, Microsoft, Powershell

 

Tags: , , , ,

PowerShell – Get-GroupMemberships

This script determines the group membership of Active Directory users.

In this case, some users are member of multiple functional groups (groupname “*-core”), while the design assumes a user can only be a member a single functional group. This script helps determine the functional groups they are a member of.

Especially with a large number of users, scripting will save you a lot of time.

 

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

PowerShell – Get network adapter information for all clients in the domain

When a customer was replacing its wireless infrastructure it had to perform an inventory of the wireless network adapters in use to determine if replacements were necessary and for which systems.

To perform the inventory, this script queries active directory for clients and then queries every client for its network adapter.

Unfortunately in this case PowerShell remoting wasn’t available, but luckily remote WMI was possible.

 
Leave a comment

Posted by on February 19, 2013 in ICT, Microsoft, Powershell, Windows

 

Tags: , , , , , , , , ,

Powershell – Get WSUS clients Without Sync Or Report In X Days

One of the tasks of a WSUS administrator is to make sure that WSUS clients are up-to-date. This requires the WSUS clients to report to the WSUS server on a regular basis.

So if clients do not report to the WSUS server, you need to investigate and resolve the issue.

This script will show you which WSUS clients haven’t reported in X days:
http://bjornhouben-web.sharepoint.com/Lists/Scripts/DispForm.aspx?ID=21

Another use case would be if you manage a WSUS infrastructure with an upstream server and multiple downstream servers for each customer. If one or more 3rd parties are responsible for managing the WSUS clients, you could use this script to automatically mail them the clients they’re responsible for that haven’t reported for X days.

 
Leave a comment

Posted by on February 17, 2013 in Automation, ICT, Microsoft, Powershell, Windows, WSUS

 

Tags: , , , , , , , ,

Microsoft – Resources to get more familiar with Active Directory Federation Services (ADFS)

Nowadays more and more work, communication and collaboration involves multiple external parties. This can involve by example employees, customers, partners, suppliers, cloud providers/platforms/applications.

This means it is becoming increasingly important to have proper authentication and authorization methods in place for single sign on (SSO) so users can be more productive. Besides the ease-of-use It can also lead to better security.

Microsoft’s Active Directory Federation Services (ADFS) will make this possible. For more information on ADFS, here are some resources. Keep in mind though that while some information may be outdated, it will give you a broad idea of the concept and the inner workings. The current version of ADFS in Windows Server 2012 is 2.1 , while Windows Server 2008 uses 2.0

PS: Microsoft is moving more and more towards claims based authentication. Examples include Windows Server 2012 Dynamic Access Control and also SharePoint 2013 that has switched to claims based authentication by default now.

If you have some other resources that might be useful, please let me know so I can add them as well.

 

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

Microsoft – System Center Universe videos and presentations are available now

The System Center Universe videos and presentations are available at http://www.systemcenteruniverse.com. I’ve only been able to browse through them a bit, but it seems very promising.

Also if you’ve missed it in the past, you might also want to take a look at the NIC 2013 (Nordic Infrastructure Conference) session at http://nicconf.com/

 

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

Event – Free Microsoft IT Camps

On a regular basis Microsoft and its partners host Free IT Camps. In the past I’ve blogged about them because I really think they’re a good way to quickly get up-to-date on products and technologies. Besides that it’s also a good way to get to know other people.

On the Microsoft Events website you can see which future events are available and not just IT Camps events.

Also should you not be able to attend an IT Camp, for Server 2012 you can also use IT Camps On-Demand.

 

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

Powershell – Get GPO Report for an Active Directory domain

Sometimes you want to be able to quickly create a GPO report for an Active Directory domain. And ofcourse you can do this manually using the GUI as well, but with a PowerShell script you can automate and schedule it.

So here’s my script that will automatically save a time stamped GPO report for the current domain.