SSH on Windows 10 with Fall 2017 Update!

Featured

It has come to my attention that you can now install SSH on Windows 10 version 1709 “Fall Creators Update” (OS Build 10.0.16299). To find what version of Windows 10 you are currently running, hit Windows Key + R and type winver.


windows-10-1709.png

Installing OpenSSH on Windows 10 is done inside the Optional Feature section. You simply have to type in Manage Optional Features into the Windows 10 Search. Open the result. That is a lot of manual work, but it can be done with PowerShell or CMD line, located at the bottom of this post.

2017-11-28 14_03_09-.png

Once the window is open click on Add a Feature. Here you will see OpenSSH Client (Beta) and OpenSSh Server (Beta). Select the OpenSSH Client (Beta). It will install in a matter of seconds.

You will need to do a reboot, but soon as you are back into your system you can simply open up PowerShell or the Command Prompt and type ssh. This is because openSSH client binaries have been appended to the System Environment Variables PATH.

OpenSSH is still in beta and therefore has limitations, but this is still a great feature to have on Windows 10. Working with a lot of Linux distributions in the Public Cloud offerings use to be a hassle. No more PuTTY, PSEXEC or WinRM!

You can simply do it with PowerShell as well:

get-windowsoptionalfeature -online //This list all optional features
get-WindowsOptionalFeature -Online -FeatureName "*OpenSSH*" //This only find the feature with OpenSSH
Enable-WindowsOptionalFeature -Online -FeatureName "*OpenSSH*Client*" -All //This install OpenSSH Client

//Disable the Optional Feature by
Disable-WindowsOptionalFeature -Online -FeatureName "*OpenSSH*"

Or with command-line

<span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start"></span>
dism /online /get-capabilities | findstr /i "OpenSSH.Client"
Advertisements

PowerShell: Connecting to Azure!

Here comes the Azure PowerShell module!
To automate the provisioning and management of Window Azure, you’ll need the Azure PowerShell module. The Azure team makes this module available as a free download, and this module provides approximately 180 Windows PowerShell cmdlets for automating Azure storage, virtual machines, virtual networks, and other cloud services.

To get started, you’ll need the following prerequisite items:

An Azure subscription – If you don’t currently have a paid subscription, you can sign-up for a FREE trial subscription on the Azure account site.
Azure PowerShell module – Download and install the Azure PowerShell module on a PC running Windows PowerShell 2.0 or Windows PowerShell 3.0.
After you satisfy these prerequisites, you’ll be prepared to follow along with the rest of this post.

Connect PowerShell to your Azure subscription.
After downloading and installing the Azure PowerShell module, you need to perform the following initial steps from Windows PowerShell to configure connection information for your Azure subscription. After you perform these steps the first time, the configuration is saved locally, and you do not need to perform these steps again.

1. Set the Windows PowerShell script execution policy to RemoteSigned:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

2. Import the Azure PowerShell module:

Import-Module Azure

After you complete the steps in this section, Windows PowerShell is configured to connect to your Azure subscription. To test this connection, enter the following cmdlet to connect to Azure and enumerate your subscription information:

Get-AzureSubscription

#Install AzureRM Module
Install-Module AzureRM
http://aka.ms/webpi-azps

# To log in to Azure Resource Manager
$cred = Get-Credential -Credential Domain\User
Login-AzureRmAccount -Credential $cred

# To view all subscriptions for your account
Get-AzureRmSubscription | Select-AzureRmSubscription

# To select a default subscription for your current session.
$subscription = "NAME OF YOUR SUBSCRIPTION GOES HERE"
Get-AzureRmSubscription -SubscriptionName $subscription | Select-AzureRmSubscription

PowerShell: GUI to manage service of your choice

Today we will be going over how to stop and start a service using GUI with popups. We will be using the Get-Service, Stop-Service, and Start-Service cmdlets. To provide the popups we will be using a wscript.shell.

First we start by grabbing the list of services that are running using the cmdlet Get-Service with the following pipeline expressions where {$_.status -eq 'running'} | Out-GridView -OutputMode Single. Out-Gridview expression with the single outputmode switch will allow the user to only select one Service at a time. This is handy when restarting a service for a program during an upgrade.

$Service=Get-Service | where {$_.status -eq 'running'} | Out-GridView -OutputMode Single

We will also need to setup the popup menu

To add some error handling we will ask the user if the service they picked is correct:

if ($Service.Status -eq "Running"){
$ServiceName=$Service.DisplayName
$Yes_Cancle = $GUI.popup("Do you want to turn stop $ServiceName ?", `
0,"Manage Service",3)
}

If the wrong service was selected we will notify the user that it will not be stopped.

else {
$GUI.popup("You decided to cancel. $ServiceName will not be stopped")
Start-Service $ServiceName
cls
}

How long doe we want to stop it is based on the script, but we will say 5 minutes or 300000 millisecond. We will also notify the user once the service has stopped and started again. I understand that something could have came up during the update or you need more time. The service will not actually start until you it OK!. If the update or anything you are doing requires a restart. Depending on the service setting to manual or auto will bring that service back online, once the machine is rebooted.

If ($Yes_Cancle -eq 6) {
Stop-Service $ServiceName 
$GUI.popup("$ServiceName service has been STOPPED and will START again in 5 minutes, soon as you hit OK")
start-Sleep -s 300000
$GUI.popup("Time is up! $ServiceName service will now start as soon as you hit OK")
Start-Service $ServiceName
cls
}

The complete code is listed here:

Function ManageService{
$Service=Get-Service | where {$_.status -eq 'running'} | Out-GridView -OutputMode Single
$GUI = new-object -comobject wscript.shell
if ($Service.Status -eq "Running"){
$ServiceName=$Service.DisplayName
$Yes_Cancle = $GUI.popup("Do you want to turn stop $ServiceName ?", `
0,"Manage Service",3)
If ($Yes_Cancle -eq 6) {
Stop-Service $ServiceName 
$GUI.popup("$ServiceName service has been STOPPED and will START again in 5 minutes, soon as you hit OK")
start-Sleep -s 300000
$GUI.popup("Time is up! $ServiceName service will now start as soon as you hit OK")
Start-Service $ServiceName
cls
}
else {
$GUI.popup("You decided to cancel. $ServiceName will not be stopped")
Start-Service $ServiceName
cls
}}}
cls
ManageService

Hope you all enjoyed this PowerShell: Managed Service GUI. See you next time.