Enable Network Discovery In Windows 10 Without Using the netsh Command In PowerShell

#Enable Network Discovery In Windows 10 Without Using the netsh Command In PowerShell

#It is as simple as enabling  the pre-configured rule in Windows Firewall to enable Network Discovery in Windows 10 but using netsh is the old fashion way.

#Run just this one command in an elevated PowerShell prompt to enable Network Discovery

Get-NetFirewallRule -DisplayGroup 'Network Discovery'|Set-NetFirewallRule -Profile 'Private, Domain' -Enabled true -PassThru|select Name,DisplayName,Enabled,Profile|ft -a

#The Longer Story…

#Enabling the Network Discovery services it what makes the Network icon (formally My Network Places) work properly. These commands all work in both PowerShell and PowerShell Direct.

#Get Firewall rules for Network Discovery

#This command shows the individual rules and the network connection profiles that  are explicitly enabled and disabled for Network Discovery.

Get-NetFirewallRule -DisplayGroup 'Network Discovery'|select Name,DisplayName,Enabled,Profile|ft -a

#Enable Network Discovery for Private and Domain network profiles

#Enable the Network Discovery service for the Private and Domain network profiles by applying the preconfigured Windows Firewall group rule called Network Discovery by typing this:

Get-NetFirewallRule -DisplayGroup 'Network Discovery'|Set-NetFirewallRule -Profile 'Private, Domain' -Enabled true -PassThru|select Name,DisplayName,Enabled,Profile|ft -a

#▲It will look like that in the GUI setup when Network Discovery is enabled.

#Set Network Connection Profile to Private.

Set-NetConnectionProfile -NetworkCategory Private -PassThru

#Disable Network Discovery for all network profiles

#Run this command to disable Network Discovery on all network profiles if you do not wish to keep the service available.

Get-NetFirewallRule -DisplayGroup 'Network Discovery'|Set-NetFirewallRule -Enabled false -PassThru|select Name,DisplayName,Enabled,Profile|ft -a

#▲It will look like that in the GUI setup when Network Discovery is disabled.

Open Elevated PowerShell Prompt Here From Right-Click Context Menu Instead Of Command Prompt Here As Administrator In Windows 10

#Open Elevated PowerShell Prompt Here From Right-Click Context Menu Instead Of Command Prompt Here As Administrator In Windows 10

#Run these commands to enable an elevated Elevated PowerShell Prompt Here also known as PowerShell Here as Administrator when right clicking on a folder in Windows Explorer. These commands all work in both PowerShell and PowerShell Direct.

#Just the code:

New-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas -Verbose -Force|ft -a
Get-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas|Set-ItemProperty -Name '(default)' -Value 'Elevated PowerShell Prompt Here' -Verbose -PassThru|fl
Get-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas|Set-ItemProperty -Name Icon -Value 'C:\\Windows\\System32\\imageres.dll,-78' -Verbose -PassThru|fl
New-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas\command -Verbose -Force|ft -a
Get-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas\command|Set-ItemProperty -Name '(default)' -Value '"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoExit cd "%1"' -Verbose -PassThru|fl

#The Long Story…

#HKCR: does not work in this example and you do not need to mount first. This method accesses the registry directly. Many instructions say to use New-PSDrive to mount HKCR: first and use that convention to access it to do many things but none of that is needed.

#Get-PSDrive will show you what is mounted.

Get-PSDrive

#▲As you can see there is no HKCR:

#Moving on…

#If done properly launching Elevated PowerShell Prompt Here will trigger a UAC prompt. This is normal and good. Create all the keys and values by typing the following commands in order:

New-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas -Verbose -Force|ft -a

Get-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas|Set-ItemProperty -Name '(default)' -Value 'Elevated PowerShell Prompt Here' -Verbose -PassThru|fl

Get-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas|Set-ItemProperty -Name Icon -Value 'C:\\Windows\\System32\\imageres.dll,-78' -Verbose -PassThru|fl

New-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas\command -Verbose -Force|ft -a

Get-Item Registry::HKEY_CLASSES_ROOT\Directory\shell\runas\command|Set-ItemProperty -Name '(default)' -Value '"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoExit cd "%1"' -Verbose -PassThru|fl

#This works when right-clicking only on folders in Windows Explorer and not drives or drive letters.

#Create the User’s file folder (from the Desktop Experience feature) on the Desktop of all new and current users

#Run this to create the User’s file folder (from the Desktop Experience Feature) on the Desktop of all new and current users. After that you will always have a folder nearby to single right-click on to launch an Elevated PowerShell Prompt Here session.

# Since HKLM is mounted already I can use the short path to manipulate the registry entries.

Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel|Set-ItemProperty -Name '{59031a47-3f72-44a7-89c5-5595fe6b30ee}' -Value 0

user folder created with registry change using microsoft powershell should appear on your Desktop after using F5 to refresh or on log off /reboot. Use the commands above to right-click and launch an elevated PowerShell prompt starting with the selected folder as a starting point.