Tag: netsh

netsh wireless password

Show Wireless Network Password on Windows 10

Today I have a simple blog post, which is more less just a note for myself. If you are join your Windows 10 device to a Wireless Network and you can’t remember the Wireless Password or Key you can recover this using the netsh command. Simply run this command to show the network key of the wireless network:

 
netsh WLAN show profile name="WirelessNetwork" key=clear

To list the wireless networks you have access to, you can use the following command:

 
netsh WLAN show profiles


Replace netsh with Windows PowerShell – Basic network cmdlets

Some days ago I made a blog post about how you can replace diskpart.exe with the new cmdlets in Windows PowerShell v3. Now my next goal was to replace netsh with PowerShell.

Microsoft offers a lot of new cmdlets for networking tasks lets see what we have here. We got a lot of new PowerShell modules which are related to networking.

get-module

Now the two modules which sound really interesting are

[powershell]
NetAdapter
NetTCPIP
[/powershell]

lets check which cmdlets are included

[powershell]
Get-Command -Module NetAdapter
[/powershell]

net-adpater module

[powershell] Get-Command -Module NetTCPIP[/powershell]

Now lets start with NetAdpater.

List all Network Adapters

[powershell] Get-NetAdapter [/powershell]

get-netadapter

Just list Wireless Network Adapters

[powershell] Get-NetAdapter -Name *Wireless* [/powershell]

get-netadapter wireless

Get more information VLAN ID, Speed, Connection status

[powershell] Get-NetAdapter | ft Name, Status, Linkspeed, VlanID [/powershell]

get-netadapter information

Get driver information

[powershell] Get-NetAdapter | ft Name, DriverName, DriverVersion, DriverInformation, DriverFileName [/powershell]

get-netadapter driver

Get adapter hardware information. This can be really usefull when you need to know the PCI slot of the NIC.

[powershell] Get-NetAdapterHardwareInfo [/powershell]

get-netadapterhardwareinfo

Disable and Enable a Network Adapter

[powershell] Disable-NetAdapter -Name “Wireless Network Connection”
Enable-NetAdapter -Name “Wireless Network Connection” [/powershell]

disable enable network adapter

Rename a Network Adapter

[powershell] Rename-NetAdapter -Name “Wireless Network Connection” -NewName “Wireless” [/powershell]

rename network adapter

Now with the NetTCPIP PowerShell module we can work with IP settings

Get IP and DNS address information

[powershell] Get-NetAdapter -Name “Local Area Connection” | Get-NetIPAddress [/powershell]

get-ipaddress

Get IP address only

[powershell] (Get-NetAdapter -Name “Local Area Connection” | Get-NetIPAddress).IPv4Address [/powershell]

get-ipaddress only

Get DNS Server Address information

[powershell] Get-NetAdapter -Name “Local Area Connection” | Get-DnsClientServerAddress [/powershell]

get-dnsserver

Set IP Address

[powershell] New-NetIPAddress -InterfaceAlias “Wireless” -IPv4Address 10.0.1.95 -PrefixLength “24” -DefaultGateway 10.0.1.1 [/powershell]

or if you want to change a existing IP Address

[powershell] Set-NetIPAddress -InterfaceAlias “Wireless” -IPv4Address 192.168.12.25 -PrefixLength “24”[/powershell]

Remove IP Address

[powershell] Get-NetAdapter -Name “Wireless” | Remove-NetIPAddress [/powershell]

Set DNS Server

[powershell] Set-DnsClientServerAddress -InterfaceAlias “Wireless” -ServerAddresses “10.10.20.1”,”10.10.20.2″ [/powershell]

Set interface to DHCP

[powershell] Set-NetIPInterface -InterfaceAlias “Wireless” -Dhcp Enabled [/powershell]

Now with this basic knowledge we can replace some of the basic netsh commands and ipconfig

netsh

[powershell]
ipconfig
netsh interface set interface “Local Area Connection” newname=”Management”
netsh interface ipv4 set address “Management” static 192.168.10.101 255.255.255.0 192.168.10.1
[/powershell]

Windows PowerShell

[powershell]
Get-NetAdapter
Rename-NetAdapter -Name “Local Area Connection” -NewName “Management”
New-NetIPAddress -InterfaceAlias “Management” -IPv4Address 192.168.10.101 -PrefixLength “24” -DefaultGateway 192.168.10.1
[/powershell]


Install and configure IPv6 on Windows Server 2003

On Microsoft Windows Server 2003 there is no GUI to configure IPv6. So this article should show you how to configure IPv6 on a Windows Server 2003.

  1. Install the IPv6 Protocol in the Network Adapter Properties or Control Panel
  2. Open the console
  3. Type “netsh” this is a command line program to configure network adapters
  4. Here are some demo configurations

int ipv6
reset
add dns interface=”<Interface Name>” address=<IPv6 primary DNS IP Address>
add dns interface=”<Interface Name>” address=<IPv6 secondary DNS IP Address>
add route prefix=::/0 interface=”<Interface Name>” metric=0 nexthop=<IPv6 Gateway IP Address>
add address interface=”<Interface Name>” address=<IPv6 IP Address>

int ipv6
reset
add dns interface=”Local Area Connection” address=fec0:0:0:0:ffff::1
add dns interface=”Local Area Connection” address=fec0:0:0:0:ffff::2
add route prefix=::/0 interface=”Local Area Connection”metric=0 nexthop=fe80::1
add address interface=”Local Area Connection” address=fe80::2

int ipv6
reset
add dns “Local Area Connection” fec0:0:0:0:ffff::1
add dns “Local Area Connection” fec0:0:0:0:ffff::2
add route ::/0 “Local Area Connection” fe80::1
add address”Local Area Connection” fe80::2



Cheatsheet: Configuring a Server Core installation #1

After setting up my new hardware for my LAB, I thought about installing my Hyper-V Servers as Server Core installations. After reading two minutes in some blogs and the Microsoft TechNet I decided to use the Core Editions.

Basically the setup is the same as the none Core Edition or GUI Edition. But after the installation you have to configure the server without a GUI, your only way to do the basic configuration is the command promt. Btw if you close the command prompt, you can easily recover the prompt by pressing CTRL-ALT-DELETE, click Start Task Manager, click New Task and type cmd.exe.

Windows Server 2008 R2 Core

To do the basic configuration of your Windows Server 2008 (R2) Core, you need the following commands:

Checkout the existing Hostname / Computername:

hostame or ipconfig

Change the Computername / Hostname:

netdom renamecomputer <ComputerName> /NewName:<NewComputerName>

Change the Computername / Hostname without writing the old name:

netdom renamecomputer %computername%   /NewName:<NewComputerName>

Show network interfaces:

netsh interface ipv4 show interfaces

Set Static IP Address, Subnet Mask, and Default Gateway (ID is the shown number in the Idx column when you show your network interfaces):

netsh interface ipv4 set address name="<ID>" source=static address=<StaticIP> mask=<SubnetMask> gateway=<DefaultGateway>

Set DNS Server (index= is the priority of the DNS Server):

netsh interface ipv4 add dnsserver name="<ID>" address=<DNSIP>index=1

Join a Domain:

netdom join <ComputerName> /domain:<DomainName> /userd:<UserName> /passwordd:*

Add a Domain User to the local administrator group:

net localgroup administrators /add <DomainName>\<UserName>

Change or set the product key of your server:

slmgr.vbs –ipk<productkey>

Active the server licence:

slmgr.vbs -ato

If activation is successful, no message will return in the command prompt

Configure the firewall:

netsh advfirewall

netsh advfirewall firewall set rule group="Remote Administration" new enable=yes

Enable Remote Desktop:

cscript c:\windows\system32\scregedit.wsf /ar 0

Restart the Computer:

shutdown /r /t 0

Open Task Manager with the command prompt:

taskmgr

List event logs:

wevtutil el

Find something in the event log:

wevtutil qe /f:<text>

List running services:

sc query

or

net start

List running tasks:

tasklist

to active Powershell type:

powershell

For the most of this simple tasks there is also a configuration tool, which makes it very easy to do your first configuration with Windows Server 2008 Core Edition. The Tool is called sconfig, and its very simple, just start the program with the following command:

sconfig.cmd

Now this will open the following configuration utility:

Windows Server Core Sconfig.cmd