How to show "This PC" or "Computer" on desktop in Windows Server 2012 (PowerShell)
Introduction
This PowerShell script sample shows how to show "This PC" or "Computer" on desktop in Windows Server 2012.
Scenarios
Although Windows has provided File Explorer, users and IT Pros used to use computer (This PC) on desktop. However, it is not convenient to show the icon through GUI in Windows server 2012 or later version. This script is used to show This PC on desktop easily.
Script
Step 1: Right click script and select Run with PowerShell.
Step 2: Then after the script finishes execution, you need to press F5 to refresh the desktop.
Here are some code snippets for your reference.
#Registry key path
$path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel"
#Property name
$name = "{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
#check if the property exists
$item = Get-ItemProperty -Path $path -Name $name -ErrorAction SilentlyContinue
if($item)
{
#set property value
Set-ItemProperty -Path $path -name $name -Value 0
}
Else
{
#create a new property
New-ItemProperty -Path $path -Name $name -Value 0 -PropertyType DWORD | Out-Null
}
write-host "Operation done! But you need to refresh your desktop."
cmd /c pause
#Registry key path
$path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel"
#Property name
$name = "{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
#check if the property exists
$item = Get-ItemProperty -Path $path -Name $name -ErrorAction SilentlyContinue
if($item)
{
#set property value
Set-ItemProperty -Path $path -name $name -Value 0
}
Else
{
#create a new property
New-ItemProperty -Path $path -Name $name -Value 0 -PropertyType DWORD | Out-Null
}
write-host "Operation done! But you need to refresh your desktop."
cmd /c pause
Windows Server 2012
Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.