Friday, September 27, 2013

Accessing Control Panel with Powershell

There are always new things to discover in Powershell, no matter what your current level knowledge is. And the things you are going to learn will make of you both a better Windows User and a better Windows asdministrator. Take me for instance. Some days ago I was on Twitter and talking with some of my fellows, and one of them (@p0w3rsh3ll) told me about a new cmdlet: Show-ControlPanelItem "Windows Update". My first thought was "hey, what is that?" and immediately went to test it. I was positively impressed by this new-cmdlet that has been introduced in Powershell V3 (so with Windows 7).

There are two cmdlets whose noun is ControlPanelItem and they are:
PS C:\> Get-Command -noun controlpanelitem

CommandType  Name                 
-----------  ----                 
Cmdlet       Get-ControlPanelItem 
Cmdlet       Show-ControlPanelItem
The first one is used to get a list of the items specific to your current system and should return something similar to:

For instance the items present on my test Windows 2012 server are:

  • Action Center
  • Administrative Tools
  • AutoPlay
  • Color Management
  • Credential Manager
  • Date and Time
  • Default Programs
  • Device Manager
  • Devices and Printers
  • Display
  • Ease of Access Center
  • Folder Options
  • Fonts
  • Internet Options
  • iSCSI Initiator
  • Keyboard
  • Language
  • Mouse
  • Network and Sharing Center
  • Notification Area Icons
  • Phone and Modem
  • Power Options
  • Programs and Features
  • Region
  • RemoteApp and Desktop Connections
  • Sound
  • System
  • Taskbar
  • Text to Speech
  • Troubleshooting
  • User Accounts
  • Windows Firewall
  • Windows Update

The last one is the one we have already seen. This is what it does:
PS C:\> Get-ControlPanelItem "windows update" | select Description

Check for software and driver updates, choose automatic updating settings, or view installed updates.

PS C:\> show-ControlPanelItem "windows update"

You could think of using Show-ControlPanelItem Personalization to present your desktop user the interface to choose a theme, as described by @powerschill on his blog.

The advantage of having such cmdlets is limited by the effort required to learn them by heart. Nonetheless if you are a skilled Windows admin working on a large environment, it could be good for you to learn some/most of them to increase your efficiency on the long term.

I hope you learned something from this post. If it's the case remember to +1. Nice weekend everybody.
Related Posts Plugin for WordPress, Blogger...