CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

PowerShell – How to display and open Control Panel items?

Usually, we open control panel items from the Control Panel. Sometimes it is required to open them through the commands or APIs and PowerShell provides useful commands to display the control panel items and allows to open them.

Note that, some control panel items will appear only when the right hardware is detected; with that, two systems may not have the same kind of control panel items.

Display control panel items

Get-ControlPanelItem cmdlet is used to get the list of control panel items on the local computer. It will display the name, canonical name, category & description of each control panel item available on the system.

Canonical Names? Yes, canonical names are used to access the control panel items from the APIs or scripts and these names are always in English only. These names will not change depending on the language selected in the system.

The below command will display the control panel items.

PS C:\> Get-ControlPanelItem

Name                              CanonicalName                            Category
----                              -------------                            --------
Security and Maintenance          Microsoft.ActionCenter                   {System and Security}
Administrative Tools              Microsoft.AdministrativeTools            {System and Security}
AutoPlay                          Microsoft.AutoPlay                       {Hardware and Sound}
........
........
........
Work Folders                      Microsoft.WorkFolders                    {System and Security}
Mail (Microsoft Outlook)                                                   {User Accounts}

We can get specific control panel items by using its’ parameters, -Name or -CanonicalName & -Category.  For example, the below command will display all control panel items with the name containing “Options”.

PS C:\> Get-ControlPanelItem -Name "*Options*"

And, the below command will display all the control panel items that are part of the given category.

PS C:\> Get-ControlPanelItem -Category "System and Security"

Note that, -Name & -CanonicalName parameters can’t be used together. Either you can use -Name or -CanonicalName at a time. Otherwise, you will see the below Error message;

PS C:\> Get-ControlPanelItem -Name "System" -CanonicalName "Microsoft.System"
Get-ControlPanelItem : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ Get-ControlPanelItem -Name "System" -CanonicalName "Microsoft.System"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-ControlPanelItem], ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.GetControlPanelItemCommand

This command will throw the below error if the control panel item we requested is not available in the system.

PS C:\> Get-ControlPanelItem -Name "Analytics"
Get-ControlPanelItem : Cannot find any control panel item with the given name Analytics.
At line:1 char:1
+ Get-ControlPanelItem -Name "Analytics"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Analytics:String) [Get-ControlPanelItem], InvalidOperationException
    + FullyQualifiedErrorId : NoControlPanelItemFoundForGivenName,Microsoft.PowerShell.Commands.GetControlPanelItemCommand

Open control panel items

So far we have discussed the PowerShell command to display the control panel items. To open control panel items, PowerShell provides Show-ControlPanelItem cmdlet. By default, it will ask for the name of the control panel item to open when no parameters are passed. For example, the below command will open the sound control panel when we enter the text Sound for the -Name parameter.

PS C:\> Show-ControlPanelItem

cmdlet Show-ControlPanelItem at command pipeline position 1
Supply values for the following parameters:
Name[0]: Sound
Name[1]:
PS C:\> 

We can also open a specific control panel item by entering its’ name or canonical name through the parameters -Name or -CanonicalName respectively. For example, the below commands will open the AutoPlay and Mouse control panel items respectively.

PS C:\> Show-ControlPanelItem -Name "AutoPlay"
PS C:\> Show-ControlPanelItem -CanonicalName "Microsoft.Mouse"

As mentioned above, either you can use -Name or -CanonicalName parameter at a time; can not be used together.

We can also pass input to this command using the pipe symbol; the below command is an example that will open a control panel item “Network and Sharing Center”, and the name comes from Get-ControlPanelItem.

PS C:\> Get-ControlPanelItem -Name "Network and Sharing Center" | Show-ControlPanelItem

[David]

PowerShell – How to display and open Control Panel items?

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top
Exit mobile version