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:

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”.
Tags: CMDB, Configuration Management Data Base, documentation, Get-ADcomputer, Powershell
This script will create an event in an existing event log or a new event log.
This can be useful to keep track of what happens in your script either locally or using monitoring tools like SCOM. You can also use it to test if custom event monitoring you’ve configured is working as expected.
Or run a task in response to a given event as explained here.
Tags: create-event, Event, event log, event monitoring, eventlog, Powershell, SCOM
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: Active Directory, Active Directory Directory Services, AD User, ADDS, automate, Directory Services, group, group membership, groups, ICT, Microsoft, Powershell, Script, user, users
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.
Tags: compatibility, ICT, inventory, Microsoft, network adapter, nic, Powershell, wi-fi, wireless, wireless network adapter
This script renames a redirected printer and sets it as default.
The reason this needs to be done, is because some older programs require a specific (short) printer name and will not work otherwise. With SAPlpd by example the printer name may only consist of x characters, no spaces, etc.
By default however with Remote Desktop Services in Server 2008 R2, a redirected printer will show as “<printername> (redirected <session ID>)” by example “Lexmark X1100 series (Redirected 2)”.
Note:
-Renaming a redirected printer is not supported.
-The script assumes there’s only one redirected printer that matches the comment filter.
All the hard work of determining what had to be done was performed by my colleague Peter Scheilen. I just converted it to PowerShell.
Tags: ICT, Microsoft, Powershell, printer, rdp, RDS, redirected printer, SAP, SAPlpd, Server 2008R2, Terminal Services, Windows, Windows Server 2008R2
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.
Tags: Powershell, report, Script, sync, Windows, WSUS, WSUS client, WSUS infrastructure, WSUS server
In a previous blog post I’ve already shown this script that use PowerCLI to get the percentage of physical and virtual servers from your VMware environment for each Virtual Center server. This script however only took into account ESX hosts and VM’s in each Virtual Center server separately.
This means that:
- The UCS blades weren’t taken into account as physical servers.
- No percentage was being calculated for each physical location.
This new script automates determining for each location the number of physical and virtual servers in VMware vSphere and Cisco UCS.
PS: You can get more detailed information from the script, but it has been disabled using comments by default.
Tags: automation, Cisco, Cisco UCS, Cisco Unified Communication System, corporate social responsibility, CSR, Green IT, Microsoft, PowerCLI, Powershell, Script, Scripting, UCS, virtual center, virtual infrastructure, virtualcenter, virtualisation, virtualization, VMware, VMware vSphere, vSphere, Windows
With the current focus on Corporate Social Responsibility (CSR) including Green IT, it might be important to know what percentage of servers has been virtualized.
This script I made will use PowerCLI to get the percentage of physical and virtual servers from your VMware environment for each Virtual Center server. You can specify multiple Virtual Center servers if desired.
Tags: automation, corporate social responsibility, CSR, Green IT, Microsoft, PowerCLI, Powershell, Script, Scripting, virtual center, virtual infrastructure, virtualcenter, virtualisation, virtualization, VMware, VMware vSphere, vSphere, Windows
In yesterday’s post I described how you could extract Office 2003 updates. When they are extracted however, they still need to be slipstreamed into the package. I also created this script to automate the slipstreaming.
Basically for each extracted patch (.msp) file, it runs msiexec with the correct parameters. So if you have other msi packages that need multiple patch (.msp) files applied to it, you could use this script as a foundation as well.
Tags: automation, extract, msi, msieexec, msp, Office 2003, patch, patch file, Powershell, Script, Scripting, slipstream