Tag: cmd

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


Azure Cloud Shell

Azure Cloud Shell – shell.azure.com and in Visual Studio Code

Back in May Microsoft made the Azure Cloud Shell available in the Microsoft Azure Portal. Now you can use it even quicker by just go to shell.azure.com. First you login with your Microsoft account or Work and School account, and if your account is in multiple Azure Active Directory tenants, you select the right tenant and you will be automatically logged in. So even if you are on a PC where you can not install the Azure CLI or the Azure PowerShell module, you can still easily fire up a shell where you can run the Azure CLI, Azure PowerShell and other CLI tools like Docker, Kubectl, emacs, vim, nano, git and more.

In addition you can also open up Azure Cloud Shell directly from Visual Studio Code

Azure Cloud Shell Visual Studio Code

With that, enjoy your holidays and I wish you a good start in the new year!



Tar and Curl on Windows 10

Today Microsoft released Windows 10 Insider Preview Build 17063 which includes a lot of great new features like Timeline, Activities, Microsoft Edge, Windows Subsystem for Linux improvements and much more. But Microsoft also included something for IT Pros and Developers. After the OpenSSH client and the OpenSSH server. Microsoft brings two new command-line tools for the Windows toolchain: curl and bsdtar. These tools are very well known tools in the open source world. Including them in Windows should make Windows even a better development platform.

 

Tar on Windows 10
Tar: A command line tool that allows a user to extract files and create archives. Outside of PowerShell or the installation of third party software, there was no way to extract a file from cmd.exe. We’re correcting this behavior 🙂 The implementation we’re shipping in Windows uses libarchive.

curl on Windows 10

Curl: Another command line tool that allows for transferring of files to and from servers (so you can, say, now download a file from the internet).

Why this, so first of all you have PowerShell which has similar functionality, but PowerShell is not always available (Think about Nano Server container images where you have not the Full .Net Framework available). Secondly Developers which come from other operating systems are already familiar with these tools and they can use, as they would on their “old” operating system.

If you want to know more, check out Craig Wihite’s (Microsoft) blog post: Tar and Curl Come to Windows!

As mentioned this is included in the Windows 10 Insider Preview Build 17063 and should ship to production customers in the next Windows 10 release, which might be Windows 10 (1803).



cmd clip

Pipe cmd prompt commands into the clipboard

This is a very all but very useful command if you work with the Windows Command Prompt. This allows you to output text from commands into the Windows clipboard.

 
dir | clip

Scott Hanselman from Microsoft just reminded the community about this feature, which is available in Windows since Windows Vista.

PowerShell v5 got some similar command using Set-Clipboard and Get-Clipboard.

 
Set-Clipboard
 
Get-Clipboard


Transparent PowerShell Background in Windows 10

Transparent PowerShell Background in Windows 10

After some recent blog post, where I posted some screenshots of my PowerShell console, some people were asking about how I made the background of the PowerShell console transparent. Well this is very simple, Microsoft changes a lot on the Command Prompt and PowerShell in Windows 10.

Simply right click on the title bar of the PowerShell console or CMD console and click on properties.

PowerShell Options

Now in the Colors tap you can change the transparency of the console window using the opacity slider.

Transparent PowerShell Background in Windows 10

This also works with the command prompt (CMD) on Windows 10.



Replace Diskpart with Windows PowerShell – Basic Storage cmdlets

Windows Server 8

Last week I made a blog post about how you can create a USB drive for Windows To Go. In my post I used diskpart.exe to format the USB drive. Now we don’t live in the stone age anymore, so I did the same with the new version of Windows PowerShell coming in Windows 8 and Windows Server 8.

Now here some basic cmdlets to do some simple storage operations, like clean a disk, create a partition and so on.

Lets start simple

List all disks

[powershell]
Get-Disk
[/powershell]

get-disk

Now get all partitions

[powershell]
Get-Partition
[/powershell]

get-partition

Now get all partitions of disk 0

[powershell]
Get-Partition -DiskNumber 0
[/powershell]

get-partitiondisk

Clear a Disk

[powershell]
Get-Disk 1 | Clear-Disk -RemoveData
[/powershell]

clear-disk

Create a new partition

[powershell]
New-Partition -DiskNumber 1 -UseMaximumSize
[/powershell]

new-partition

Format this volume

[powershell]
Get-Partition -DiskNumber 1 -PartitionNumber 1 | Format-Volume -FileSystem NTFS
[/powershell]

format-volume

Create new partition and format it with the label “USB”:

[powershell]
New-Partition -DiskNumber 1 -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel USB
[/powershell]

format-volume1

Change driveletter

[powershell]
Set-Partition -DriveLetter E -NewDriveLetter T
[/powershell]

set-partition

Set a partition active

[powershell]
Set-Partition -DriveLetter T -IsActive $true
[/powershell]

set-partition1

Remove a partition

[powershell]
Remove-Partition -DriveLetter T
[/powershell]

remove-partition

Bring a disk online

[powershell] Set-Disk 1 -isOffline $false [/powershell]

Remove Readonly flag

[powershell] Set-Disk 1 -isReadOnly $false [/powershell]

Initialize Disk with GPT

[powershell] Initialize-Disk 1 -PartitionStyle GPT [/powershell]

online disk

This is some basic knowledge about the storage module in PowerShell v3. Lets see how we can change the commands from using diskpart to Windows PowerShell.

Diskpart.exe

[powershell]
select disk 1
clean
create partition primary
format fs=ntfs quick
active
assign letter=e
[/powershell]

PowerShell:

[powershell]
Get-Disk 1 | Clear-Disk -RemoveData
New-Partition -DiskNumber 1 -UseMaximumSize -IsActive -DriveLetter E | Format-Volume -FileSystem NTFS -NewFileSystemLabel USB
[/powershell]

replace-diskpart



Windows Server Core

Commands for Windows Server Core & Hyper-V Server

For some KTSI projects I have been working a lot with Windows Server Core or Hyper-V Server. Now I had to do a lot of automation, so I made this little connection of commands. If you configure the server manually you can do the most important things with the sconfig utility.

Windows Server Core

Networking

Set Hostname
[powershell]netdom renamecomputer %COMPUTERNAME% /NewName:<NewComputerName> [/powershell]

Join Domain
[powershell]netdom join %COMPUTERNAME% /domain:<DomainName> /userd:<UserName> /passwordd:*[/powershell]

Remove Domain
[powershell]netdom remove[/powershell]

Rename Network Interface
[powershell]netsh interface set interface name=”old name” newname=”new name”[/powershell]

Configure IP Address
[powershell]netsh interface ipv4 set address name=”<Interface Name>” source=static address=<IPAddress> mask=<SubnetMask> gateway=<DefaultGateway>[/powershell]

Configure DNS Servers
[powershell]netsh interface ipv4 add dnsserver name=”<Interface Name>” address=<DNS Server IP> index=1[/powershell]

Disable Firewall (not recommended)
[powershell]netsh advfirewall set allprofiles state off[/powershell]

 

Remoting

Enable PowerShell Remoting
[powershell]Enable-PSRemoting[/powershell]

Enable Remotedesktop
[powershell]netsh advfirewall firewall set rule group=”remote desktop” new enable=yes[/powershell]

Enable Remote Administration
[powershell]advfirewall firewall set rule group=”Remote Administration” new enable=yes[/powershell]

Enable Remote Firewall Administration
[powershell]netsh advfirewall firewall set rule group=”Windows Firewall Remote Management” new enable=yes[/powershell]

Enable ICMP (Ping)
[powershell]netsh firewall set icmpsetting 8[/powershell]

Enable Remote Disk Management
[powershell]netsh advfirewall firewall set rule group=”Remote Volume Management” new enable=yes[/powershell]

 

Licensing

Enter License key
[powershell]slmgr.vbs -ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX[/powershell]

Activate Windows
[powershell]slmgr.vbs -ato[/powershell]

 

Windows Update

Enable automatic updates
[powershell]cscript C:’Windows’System32’Scregedit.wsf /au 4[/powershell]

Disable automatic updates
[powershell]cscript C:’Windows’System32’Scregedit.wsf /au 1[/powershell]

 

Roles & Features

Get availibale features & roles
[powershell]Dism /online /get-features /format:table[/powershell]

Enable feature & roles
[powershell]Dism /online /enable-feature /featurename:<featurename>[/powershell]

 

Basics

Change Administrator password
[powershell]net user administrator *[/powershell]

Restart Computer
[powershell]shutdown /r /t 0[/powershell]

Logoff
[powershell]logoff[/powershell]

More information about Server Core: TechNet