Change ‘Unidentified network’ from Public to Work in Windows 7
There isn’t an easy way to set the category of an Unidentified network in Windows 7 RC+ builds. By default, an Unidentified network will be set to Public for security. Often, the Unidentified network is setup intentionally (e.g. two machines connected via a hub; a network TV tuner, etc.). In these cases, Home/Work is a better category to allow common network tasks to succeed.
Below is a Powershell script to change the category from Public to Work (identical to Home, except Homegroup won’t be started up). You need to be already connected to the ‘Unidentified network’ prior to running this script.
#
# Name: ChangeCategory.ps1
# Copyright: Microsoft 2009
# Revision: 1.0
#
# This script can be used to change the network category of
# an 'Unidentified' network to Private to allow common network
# activity. This script should only be run when connected to
# a network that is trusted since it will also affect the
# firewall profile used.
# This script is provided as-is and Microsoft does not assume any
# liability. This script may be redistributed as long as the file
# contains these terms of use unmodified.
#
# Usage:
# Start an elevated Powershell command window and execute
# ChangeCategory.ps1
#
$NLMType = [Type]::GetTypeFromCLSID('DCB00C01-570F-4A9B-8D69-199FDBA5723B')
$INetworkListManager = [Activator]::CreateInstance($NLMType)
$NLM_ENUM_NETWORK_CONNECTED = 1
$NLM_NETWORK_CATEGORY_PUBLIC = 0x00
$NLM_NETWORK_CATEGORY_PRIVATE = 0x01
$UNIDENTIFIED = "Unidentified network"
$INetworks = $INetworkListManager.GetNetworks($NLM_ENUM_NETWORK_CONNECTED)
foreach ($INetwork in $INetworks)
{
$Name = $INetwork.GetName()
$Category = $INetwork.GetCategory()
if ($INetwork.IsConnected -and ($Category -eq $NLM_NETWORK_CATEGORY_PUBLIC) -and ($Name -eq $UNIDENTIFIED))
{
$INetwork.SetCategory($NLM_NETWORK_CATEGORY_PRIVATE)
}
}
- Save the script locally as ChangeCategory.ps1 (say under c:\)
- Launch an elevated Powershell command window
- Change your execution policy to allow the script to run (if not already changed)
PS> set-executionpolicy remotesigned - Run the script
PS> c:\ChangeCategory.ps1
At the end of this, the category for the Unidentified network will show as Work in Network and Sharing Center. This setting is not persisted across re-connects and you will require to run the script again to change the category. Be sure to run the script only for networks that you trust since this affects the firewall profile that will be used.
Comments
Anonymous
June 30, 2010
Powershell requires # as a comment indicator, not // - this needs to be fixed in order to run this scriptAnonymous
August 16, 2010
Not working for me, running windows 7 ultimate 64bitAnonymous
August 24, 2010
Works just fine in 2008 R2 Enterprise in an elevated PS window after setting the policy. Just follow the instructions and your unidentified network will go from public to private, swiftly and easily. Thank you!Anonymous
September 04, 2010
@tim: it works, just replace // with #, because the comment indicator is wrong. I've tested it my self :)Anonymous
September 12, 2010
On Windows Server 2008 R2, this setting can be permanently changed using Administrative Tools > Network List Manager Policies > Unidentified Networks > Properties. See here for more info: blog.kazmarek.com/.../change-default-behavior-for-unidentified-network-in-vistawindows-server-2008windows-7Anonymous
September 15, 2010
does windows 7 has direct cable connection program?Anonymous
September 15, 2010
does windows 7 has drect cable connection program?Anonymous
November 05, 2010
I just did this on my machine and this worked
- Start –> run –> MMC –> press enter
- In MMC console , from menu file select Add/Remove Snap-in
- Select Group Policy Object editor –> Press Add –> select Local computer –> press OK –>press OK
- Open Computer configration –>Windows Settings –>Security Settings –>select Network list manager policies on the right Side you will see options for : double click –>Unidentified networks Then you can select the option to consider the Unidentified networks as private and if user can change the location except I set this to User can change Network Location This worked for me.!
- Anonymous
November 23, 2010
I'm getting a Missing '>' in method call At C:ChangeCategory.ps1:2 char:37
- $NLMTYPE = [Type]:GetTypeFromCLSID< <<<< ‘DCB00C01-570F-4A9B-8D69-199FDBA5723B’> + CategoryInfo : ParserError: <CloseParenToken:TokenId> [], ParseException + FulluQualifiedError : MissingEndParenthesisInMethodCall
- Anonymous
November 23, 2010
I'm getting a Missing '>' in method call At C:ChangeCategory.ps1:2 char:37
- $NLMTYPE = [Type]:GetTypeFromCLSID< <<<< ‘DCB00C01-570F-4A9B-8D69-199FDBA5723B’> + CategoryInfo : ParserError: <CloseParenToken:TokenId> [], ParseException + FullyQualifiedError : MissingEndParenthesisInMethodCall
Anonymous
December 02, 2010
GPO worked for me... don't forget to apply the policy... gpupdate.exe /forceAnonymous
January 12, 2011
In the script, apart from changing the // to #, you need to use double quotes for the GetTypeFromCLSID string ‘DCB00C01-570F-4A9B-8D69-199FDBA5723B’Anonymous
March 04, 2011
Thanks for the comments pointing out the comments and the quotes issue in the script. The script is now updated.Anonymous
June 01, 2011
After two days of frustration I found RSOLY777's fix above. It worked perfectly for me. I can see files on both networked machines, and I can connect to the internet from both machines. I have a USB modem attached to a Dell XPS 9100 with Windows 7 64-bit, and D-Link DIR-655 router, and a NetGear N150 wireless USB adapter on the second PC. Thank you so much.Anonymous
July 04, 2011
RSoly777 is a star. Worked a treat!Anonymous
September 24, 2011
@RSoly777 There is no Group Policy Object editor in add or remove snap-ins. Please help.Anonymous
November 20, 2011
i found that GPO is not in Win 7 home, it's only in Pro or Ultimate version.Anonymous
December 15, 2011
The comment has been removedAnonymous
November 21, 2012
yes its working now...but as work network not home network. Home & work netwok are one and the same thing. JUST REMEBER if change the security policy like this....every unidentified network will be a work network! Better invest in a good firewall.......Anonymous
March 07, 2013
@RSOLY777 Worked great for myself and a colleague, many thanks!Anonymous
December 04, 2013
I ran the script and the network type changed from Public to Work but is still "unidentified network", therefore not internet acccessAnonymous
February 22, 2014
Quotes, double quotes, or( this format ) throws me an unexpected token error (see below). Any ideas, anyone? Unexpected token 'GetTypeFromCLSID' in expression or statement. At C:UsersSteveDesktopChangeCategory.ps1:19 char:34
- $NLMType = [Type]GetTypeFromCLSID <<<< ("DCB00C01-570F-4A9B-8D69-199FDBA5723B") + CategoryInfo : ParserError: (GetTypeFromCLSID:String) [], ParseException + FullyQualifiedErrorId : UnexpectedToken
- Anonymous
June 03, 2014
Nice going RSOLY777! Changed from public to work! Kudos to you!
"1. Start –> run –> MMC –> press enter 2. In MMC console , from menu file select Add/Remove Snap-in 3. Select Group Policy Object editor –> Press Add –> select Local computer –> press OK –>press OK 4. Open Computer configration –>Windows Settings –>Security Settings –>select Network list manager policies on the right Side you will see options for : double click –>Unidentified networks Then you can select the option to consider the Unidentified networks as private and if user can change the location except I set this to User can change Network Location"
Anonymous
January 19, 2015
It works, thank you :-) Just a "problem" again : the network category icon is still public icon. Is it possible to change that ? For example $INetwork.SetIcon or another function like that ?Anonymous
May 05, 2015
It worked...until I unplugged the ethernet cable then plugged it back in and it returned to public :( Any ideas? They are laptops so will be unplugged oftenAnonymous
August 04, 2015
- Start –> run –> MMC –> press enter
- In MMC console , from menu file select Add/Remove Snap-in
- Select Group Policy Object editor –> Press Add –> select Local computer –> press OK –>press OK
- Open Computer configration –>Windows Settings –>Security Settings –>select Network list manager policies on the right Side you will see options for : double click –>Unidentified networks Then you can select the option to consider the Unidentified networks as private and if user can change the location except I set this to User can change Network Location This worked for me.! TOOOOOOOOOOO. THANKS Very much