JAGKK

              ..The people writing all this must have a fully intact
              and functional crystal ball and not one like I dropped
              in the driveway that no longer accurately predicts the
              future.

              I asked the darned ball to cook me up a mojo on which
              horse was going to win the 5th race at Saratoga today
              but the response was silent.

              https://freddysmidlap.com/2019/08/23
                /help-my-crystal-ball-is-broken/

## TIPS AND LINKS (JA9-JAG)

Финский симулятор электронных схем

  http://sol.gfxile.net/atanua/

JAG

Problems with starting VirtualBox after android simulator (Hyper-V)

  https://forums.virtualbox.org/viewtopic.php?f=6&t=92260

Run CMD > bcdedit /set hypervisorlaunchtype off
then reboot host machine.

  https://github.com/MicrosoftDocs/windowsserverdocs/issues/2074

  https://4sysops.com/archives
    /installing-openssh-on-windows-10-1803-and-higher-and-server-2019/

JAG

14 Best emulators for Android

  https://www.androidauthority.com
    /best-android-emulators-for-pc-655308/

Open local file in Chrome

  https://superuser.com/questions/39544
    /how-to-open-a-local-file-in-google-chrome

For Windows and Linux, you can use ctrl+O. This does not seem to be referenced anywhere in the application, so you can feel special about using it.

JAF

Visual Studio Emulator for Android (Turns Hyper-V on during install)

  https://visualstudio.microsoft.com/vs/msft-android-emulator/

Visual Studio Emulator for Android

  10.1 Marshmallow (6.0.0) XHDPI Tablet
  API Level 23 (Marshmallow 6.0.0) 1GB
  Similar to Samsung Google Nexus 10

Enable Storage for the Browser

  https://appslova.com
    /how-to-fix-unfortunately-browser-has-stopped-error-in-android/

  + Go to Setting >> Go to Application Setting (In some devices application setting is named as Apps).
  + Now Click on Browser >> App permissions
  + Then Enable Storage option.

Allow Install from Unknown Sources

  Settings -> Security -> Unknown Sources

Google: plcladdersimulator2 apk

PLC Ladder Simulator 2

  https://apkpure.com/plc-ladder-simulator-2
    /com.casdata.plcladdersimulator2

How to access Android 6.0 Marshmallow's native file manager

  https://www.cnet.com/how-to
    /how-to-access-android-6-0-marshmallows-file-manager/

  Launch the Settings app.
  Tap on Storage & USB.
  Scroll to the bottom and select Explore.

  Tap Download Section.

Google: terminal emulator apk

  https://www.apkmirror.com/apk/jack-palevich/terminal-emulator
    /terminal-emulator-1-0-70-release/terminal-emulator-1-0-70-
    android-apk-download/

What Is Hyper-V & How Do You Use It? A Beginner’s Guide

  https://www.cloudwards.net/hyper-v/

  CMD# DISM /Online /Enable Feature /All /FeatureName:Microsoft-Hyper-V

  Hyper-V Manager: Connect to Server -> Local computer

  https://www.groovypost.com/howto
    /migrate-virtual-box-vms-windows-10-hyper-v/

Computer Chronicles (transcript, translate)

  https://www.youtube.com/watch?v=cHkdQ5CG0PY

in VirtualBox Export desired machine to ova OVF2.0 format. Result in C:\Users\<user>\Documents. Convert to VHD.

JAF

PLC Ladder Simulator 2
by Sergio Daniel Castañeda Niño

  https://plcladdersimulator2.weebly.com/
  https://apktada.com/download-apk/com.casdata.plcladdersimulator2

Current Version   1.032
Requires Android  6.0 and up

Android-x86 8.1

  https://forums.virtualbox.org/viewtopic.php?f=6&t=92683

Don't know if you're still watching this, but I found a solution to this issue tonight. I'm using 64-bit, but the same solution should work in 32-bit.

Shut down the Android VM if it is running. Then open up the settings for the VM in VirtualBox. On the Display tab, the Graphics Controller dropdown is likely set to VMSVGA. Change this to VBoxVGA, and check Enable 3D Acceleration. Click OK to save settings.

Now restart the Android VM. Be patient, after it shows the command prompt, it should eventually clear, switch to graphics mode and show the Android desktop. This can take anywhere from 10 to 30 seconds, depending on the speed of your CPU and system.

This worked for me, anyway. I didn't think of it, but found the suggestion by searching.

Network:

  https://forums.virtualbox.org/viewtopic.php?f=7&t=91201

  VirtualBox: Parvirtualized adapter (VirtoNet)
  Android: Connect to VirtWiFi.

Google: PLCLadderSimulator 2 apk

  https://apkpure.ai/plc-ladder-simulator-2/download
  Settings: allow install from unknown sources

Upgrade Galaxy 7.7 to Android 6.0

  https://www.theandroidsoul.com/galaxy-tab-7-7-gets-marshmallow-
    android-6-0-update-via-omnirom-as-cm13-wait-goes-on/

Samsung dropped the updates for the tablet way a long ago, and you cannot expect an OEM to update a device after two years.

However, if you have some guts, and can install custom recovery like TWRP, you can install the Marshmallow ROM we got here, and update your Tab 7.7 to latest Android 6.0. update now.

JAF

Add to PS Cookbook

1. Copy file over WinRM

  https://kimconnect.com/how-to-transfer-files-via-ssh-or-winrm/

2. good introduction to working with strings.

  https://docs.microsoft.com/en-us/previous-versions/windows/it-pro
    /windows-powershell-1.0/ee692804(v=technet.10)?redirectedfrom=MSDN

3. Check MD5 hash

  https://sysadmin.ru/articles/kak-proverit-md5-xesh-summu-fajla-v-windows#i-3

     certutil -hashfile C:\Users\Admin\Downloads\Setup.exe MD5

JAE

Серийный номер жесткого диска или SSD, на котором установлена ОС – (11);
BIOS-идентификатор — (9);
Процессор -- (3);
Интегрированные IDE-адаптеры – (3);
Адаптеры SCSI-интерфейса – (2);
Сетевой адаптер и MAC-адрес – (2);
Звуковая карта – (2);
Объем оперативной памяти – (1);
Разъем для подключения монитора – (1);
CD/DVD-привод – (1).

Лицензию Windows 10 Digital Entitlement получают пользователи, которые успели бесплатно обновиться до «десятки» с лицензионной Windows 7, 8 и 8.1 или установили ее самостоятельно и активировали с помощью ключа от «старой» версии, а также те, кто приобрели апдейт в Microsoft Store. Помимо них цифровой идентификатор достался участникам программы Windows Insider (предварительная оценка ОС).

Запустите «Параметры» (через меню «Пуск» или клавишами «WIN+I»)
Перейдите к разделу «Обновление и безопасность». В боковой панели откройте вкладку «Активация». Напротив одноименного пункта будет указан тип активации операционной системы -- цифровая лицензия Windows 10 активирована с помощью цифровой лицензии или любой другой вариант.
  https://lumpics.ru/what-is-digital-license-windows-10/


## ANNEX A. HOW TO USE SSH CLIENT AND SERVER ON WINDOWS 10
   Written on May 31, 2019 by Dr Donald Kinghorn

  https://www.pugetsystems.com/labs/hpc
    /How-To-Use-SSH-Client-and-Server-on-Windows-10-1470/

Table of Contents

    Introduction
    Documentation and Links
    Enable ssh and ssh server on Windows 10
    Using ssh on Windows 10
    ssh from Windows 10 to Linux
    ssh From Linux to Windows 10
    ssh from Windows 10 to Windows 10
    scp Secure Copy
    Conclusions


# Introduction

Secure Shell (ssh) is a standard tool included on most "network" operating systems i.e. Linux, UNIX, MacOS, etc.. In the past Windows required a 3rd party application to get even a usable ssh client. For users who needed to connect securely to the rest of the world with a command line interface PuTTY has been a common addition. After several decades Microsoft finally has a native ssh client AND server on Windows! Both the client and server are standard (and in stable versions) on Windows 10 since the 1809 "October Update".

For a developer or researcher it's not unusual to be working with several machines at the same time. Connecting remotely to servers or other workstations in a mixed OS environment is a common need. You can now connect from a Windows 10 system to Linux servers or workstations easily and you can go the other direction too. You can "ssh into" a Windows 10 machine from Linux or other Windows machines. For me personally this kind of connectivity is essential. I may be using 3 or 4 different machine at the same time and I always have several terminal's open. I typically work with Linux and Windows 10 (locally or remotely) at the same time. The interoperability between Linux and Windows 10 has become very good.

This post is a setup guide and introduction to ssh client and server on Windows 10. I'm doing this partly as a reference for other posts that I'll be doing where this functionality will be utilized.


# Documentation and Links

I am not going to cover much detail about using ssh. If ssh is new to you then note that Microsoft ssh is a native port of the widely used standard OpenSSH client and server. That means that most information about using ssh that you find online will apply even though those sources will likely be references from Linux, UNIX or MacOS. The official documentation for components of OpenSSH is the standard reference.

  https://www.openssh.com/index.html

The Windows Server documentation has a section titled "OpenSSH in Windows"

  https://docs.microsoft.com/en-us/windows-server/administration
    /openssh/openssh_overview

The normal suite of of functions are included with the Windows 10 port,

  + ssh.exe, which is the SSH client used from the user's local system
  + sshd.exe, which is the SSH server that accept connections from other systems
  + ssh-keygen.exe generates, manages and converts authentication keys for SSH
  + ssh-agent.exe stores private keys used for public key authentication
  + ssh-add.exe adds private keys to the list allowed by the server
  + ssh-keyscan.exe aids in collecting the public SSH host keys from a number of- hosts
  + sftp.exe is the service that provides the Secure File Transfer Protocol, and- runs over SSH
  + scp.exe is a file copy utility that runs on SSH

The user applications that you will use most frequently are:

  + ssh (secure shell), for connecting to other systems
  + scp (secure copy) for for copying files and directories back and forth with remote systems.


# Enable ssh and ssh server on Windows 10

I am using a fresh install of Windows 10 Pro 1903. I have done this on Windows 10 Home too.

The simplest way to setup ssh and ssh server is to use PowerShell. After all you do want to use the command-line, right?

You need administrator privileges to enable services so open Powershell as Administrator, (right click on the Powershell icon in the application menu)

  Run as Administrator

The following command will show you the name and state of OpenSSH on your system,

  Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'

You should see something like,

  Name : OpenSSH.Client~~~~0.0.1.0
  State : Installed

  Name : OpenSSH.Server~~~~0.0.1.0
  State : NotPresent

That is telling you that the ssh client is installed. (It's ready to use by default in recent Windows 10 builds.) The server is not setup yet.

Add the OpenSSh server component,

  Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

That command will download the server component and install it. Output will look like,

  Path :
  Online : True
  RestartNeeded : False

Note: If for some reason your systems showed "NotPresent" for the client too then you would do the same command above but using "OpenSSH.Client~~~~0.0.1.0"

You now have the ssh server installed but it is not running. The next command will start the service,

  Start-Service sshd

That will start silently. You can see that it is running with Get-Service,

  PS C:\Windows\system32> Get-Service sshd

  Status Name DisplayName
  ------ ---- -----------
  Running sshd OpenSSH SSH Server

You could stop it with, you guessed it, "Stop-Service sshd"

Note: the name of the ssh server application is "sshd". This is a typical naming convention from UNIX. The "d" means "daemon". Services in Linux/UNIX are called daemons. Now you understand the meaning of the BSD UNIX mascot "Beastie" which you may have seen before.

In order to avoid having to manually start sshd you can do the following to have it start on boot.

  Set-Service -Name sshd -StartupType 'Automatic'

The last thing to check is the firewall setting for sshd. It by default uses the port number 22. Enabling the service automatically created the following firewall rules,

  PS C:\Windows\system32> Get-NetFirewallRule -Name *ssh*

  Name                  : OpenSSH-Server-In-TCP
  DisplayName           : OpenSSH SSH Server (sshd)
  Description           : Inbound rule for OpenSSH SSH Server (sshd)
  DisplayGroup          : OpenSSH Server
  Group                 : OpenSSH Server
  Enabled               : True
  Profile               : Any
  Platform              : {}
  Direction             : Inbound
  Action                : Allow
  EdgeTraversalPolicy   : Block
  LooseSourceMapping    : False
  LocalOnlyMapping      : False
  Owner                 :
  PrimaryStatus         : OK
  Status                : The rule was parsed successfully from the store. (65536)
  EnforcementStatus     : NotApplicable
  PolicyStoreSource     : PersistentStore
  PolicyStoreSourceType : Local

Note: If you enable sshd you are creating an "open port" for port 22. (Otherwise you wouldn't be able to connect to it.) If your system is exposed to the outside world then that might bother you. You can do things to tighten up security like disallowing passwords and requiring only "public-key" access. I'm not going to cover any of that here. If you are on a private LAN you don't have too much to worry about, but always be security conscious and use good passwords!

Now that you have the server up and running you should close the Powershell that you were running as Administrator. Start another Powershell as your normal user for the examples below.


# Using ssh on Windows 10

Now the fun stuff.

The basic connection command (on any OS) for ssh looks like,

  ssh user-name-on-remote-sys@ip-address-of-remote-sys

If your user name on the system you are connecting from is the same as your user name on the system you are connecting to, then you can leave out the "user-name-on-remote-sys@" part. There are a lot of options for ssh, to dig deeper look at the docs

  https://man.openbsd.org/ssh.1

If you are on a network with "name resolution i.e. DNS" then you can use the name for the machine rather than it's ip address.


# ssh from Windows 10 to Linux

For this example I'll go through the details you see when connecting to a Linux machine. I'm using Powershell on Windows 10.

The following shows my Powershell command prompt with my user name "don". I'm connecting to one of my Linux systems on a local network. My user name is "kinghorn" on that machine.

  PS C:\Users\don> ssh kinghorn@192.168.3.70

When you first connect to a machine that you haven't accessed before you will see something like,

  The authenticity of host '192.168.3.70 (192.168.3.70)' can't be established.
  ECDSA key fingerprint is SHA256:(a bunch of stuff...).
  Are you sure you want to continue connecting (yes/no)? yes

Saying "yes" adds a key entry to your ".sshknown_hosts" file. The next time you connect ssh will check that key and will either silently connect or give you a scary message if the key doesn't match. [A key mismatch can happen if you reinstall the remote system and it still has the same ip address. It will have a new ssh key. To fix that you will need to remove the old key from the "known-hosts" file.]

After your first connection with ssh look in your user directory and you should see a new directory named .ssh There is a lot of configuration options that can be set in various files in that directory but you usually don't need to do anything in there unless you start doing "public key exchange" for connecting to systems securely without passwords.

  fig# ssh directory

Here's an example Powershell session "ssh-ing" into a Linux system,

  PS C:\Users\don> ssh kinghorn@192.168.3.90
  The authenticity of host '192.168.3.90 (192.168.3.90)' can't be established.
  ECDSA key fingerprint is SHA256:(a bunch of stuff...).
  Are you sure you want to continue connecting (yes/no)? yes

  Warning: Permanently added '192.168.3.90' (ECDSA) to the list of known hosts.

  kinghorn@192.168.3.90's password:
  Welcome to Ubuntu 19.04 (GNU/Linux 5.0.0-15-generic x86_64)

  ...
  then a long default login message from Ubuntu...
  ...

  Last login: Tue May 28 09:27:03 2019 from 192.168.3.105

  kinghorn@U19:~$ ls
  anaconda3  bin  Desktop  Documents  Downloads  Music  Pictures  projects  Public  snap  Templates  tmp  Videos

From there I am securely connected to my Linux system with a command prompt ready for what ever I need to do.


# ssh From Linux to Windows 10

Since we have the OpenSSH server running on the Windows 10 system we can ssh into that now too.

You might not think you wouldn't do that much but I actually do that fairly often. Right now I have 3 Windows 10 machines running and 3 Linux machines including one at a remote location that I am doing testing on. I can connect from any of these machines to any other with ssh. I am writing this post on a Linux machine and I just used the "scp" command (part of the ssh bundle) to copy a directory of screen shots from a Windows 10 machine here. And, I didn't even have to go near the Windows machine to do that.

Here is a session where I log into my Windows 10 laptop from an Ubuntu 19.04 machine.

When you connect to the ssh server on Windows 10 you are given a CMD shell (the old DOS like shell). From there I started Powershell and then started bash on Ubuntu 18.04 using WSL (Windows Subsystem for Linux). The interoperability between Windows 10 and Linux is getting very good!

  kinghorn@U19:~$ ssh don@192.168.3.105
  don@192.168.3.105's password:

  Microsoft Windows [Version 10.0.17763.529]
  (c) 2018 Microsoft Corporation. All rights reserved.

  don@DLAP C:\Users\don>powershell
  Windows PowerShell
  Copyright (C) Microsoft Corporation. All rights reserved.

  PS C:\Users\don> bash
  kinghorn@Dlap:/mnt/c/Users/don$

Note: On that laptop I am using a Microsoft account so my password was for that account.


# ssh from Windows 10 to Windows 10

This works the same as any other combination of OS's. From Windows 10 you can use Powershell or CMD to run ssh. [If you have WSL installed you can use that too.] By default when you ssh to a Windows 10 machine you will login to CMD, it doesn't matter what you use to connect from.

In this example I am connecting to the the Windows 10 machine that I used for the ssh setup testing. I'm connecting from the laptop I connected to in the example above. (I'm not anywhere near that laptop.)

  don@DLAP C:Usersdon>ssh don@192.168.3.111

Microsoft Windows [Version 10.0.18362.116]
(c) 2019 Microsoft Corporation. All rights reserved.

  don@DESKTOP-Q36DH26 C:Usersdon>

No big surprises here, it just works. It's basically the same connecting from any OS to another. The main difference is the "shell" command that you connect from and the shell you connect to.


# scp Secure Copy

One of the most useful tools in the ssh suite is "scp". This gives you a simple to use encrypted remote copy capability. It uses ssh as a "tunnel" for the copy.

The basic usage of scp for a single file copy to a remote machine is

  scp file1  username@machine-ip:path-to-directory

The important thing to note here is that after "machine-ip" ( : ) is the top level directory of the machine. The path-to-the directory should use the syntax of the machine you are connecting to i.e. for Linux the directory separator is (/) for Windows it's (). Also, on Linux (~) is shorthand for the login users home directory. Connecting to windows you have to give the full path. And, on Linux when accessing Windows you have to quote (") the username and path because of the backslashes.

To copy a file from a remote machine to your local machine it's,

  PS> scp  username@machine-ip:path-to-file(/or)file1 `
           path-to-directory-on-local-machine

You can use dot (.) to indicate the current directory on the local machine.

To copy directories use, -r (recursive)

  scp -r director-on-local-machine `
         username@machine-ip:path-to-directory

or

  scp -r username@machine-ip:path-to-remote-directory `
         path-to-directory

That may be confusing so here are some real examples.

Copy a directory named "ssh-images" from Windows 10 to Linux starting on the Windows machine with Powershell.

  PS C:Usersdon> scp -r ssh-images kinghorn@192.168.3.90:~/tmp/

That put the ssh-images in "tmp" in my Linux home directory.

Now the same thing but starting from the Linux machine (using dot (.) for the current directory)

  scp -r "don@192.168.3.111:Usersdonssh-images" .

Note the full path and quotes.


# Conclusions

I hope this guide is helpful to both Windows and Linux users who want better interoperability. I also hope this is encouraging for user who may have never used ssh. I think it's great how easy it is getting to be to work productively in a mixes OS environment. Microsoft, much to their credit, keeps making Windows more useful for mixed environments. I'm looking forward to the terminal application they will have out soon and to the release of WSL2. With those 2 application in place windows will be nicely interoperable and will be much improved as a solid developers system.

One of the main reasons I wrote this post is because I want to refer to it in a post about using Python Jupyter notebooks remotely between machines with different OS's. Expect to see that post soon. I may also write about using WSL and an Xwindow server on Windows 10.

Happy computing! --dbk @dbkinghorn


## ANNEX B. HOW TO SETUP WINRM IN A WORKGROUP NON DOMAIN ENVIRONMENT ###

########## NOTE: ADOPTED, HEAVILY EDITED, 102 COLUMNS ##########

  https://www.paulligocki.com
    /how-to-setup-winrm-in-a-workgroup-non-domain-environment/

December 7 by paulligocki

TODO. Try this with busterGW Gateway: VirtualBox, NAT+Internal

# Disclaimer:

This will create a very basic unsecured/not encrypted connection. This should only be done in a test lab environment. This is being setup in a Non Domain/Work group setting.

There is no certificate or DNS infrastructure in place. The connections will be going over TCP 5985. This is the Default TCP Port for not encrypted WinRM connections.

# Environment:

  2 x Windows 10 Virtual Machines on the same subnet.

WinRM1

  PS> hostname
  BARBIE

  PS> Get-NetIPAddress -InterfaceAlias Ethernet | ft -AutoSize

  ifIndex IPAddress                   PrefixLength PrefixOrigin SuffixOrigin AddressState PolicyStore
  ------- ---------                   ------------ ------------ ------------ ------------ -----------
  4       fe80::b094:651b:57c7:4a79%4           64 WellKnown    Link         Preferred    ActiveStore
  4       10.0.2.10                             24 Dhcp         Dhcp         Preferred    ActiveStore

WinRM2

  PS> hostname
  BURATINO

  PS> Get-NetIPAddress -InterfaceAlias Ethernet | ft -AutoSize

  ifIndex IPAddress                   PrefixLength PrefixOrigin SuffixOrigin AddressState PolicyStore
  ------- ---------                   ------------ ------------ ------------ ------------ -----------
  4       fe80::a182:d9d6:7330:e16c%4           64 WellKnown    Link         Preferred    ActiveStore
  4       10.0.2.11                             24 Dhcp         Dhcp         Preferred    ActiveStore

## Prerequisites:

# Set Network Category to Private:

All network adapters should be set to “Private” or “DomainAuthenticated”.

If even one network adapter is set to Public, the firewall rule will NOT be added.

Since we are in a workgroup setting, the adapters will be set to “Private”

To Check what the network adapters Network Category is set to, run the following PowerShell command.

  PS> Get-NetConnectionProfile | Select InterfaceAlias,NetworkCategory

Output:

  InterfaceAlias NetworkCategory
  -------------- ---------------
  Ethernet                Public

As can be seen above by default this is set to Public.

If you try to enable WinRM using this powerShell command

  PS# Enable-PSRemoting -force

You will get similar error message to this:

  WinRM is already set up to receive requests on this computer.
  Set-WSManQuickConfig ..S_O_M_E_T_H_I_N_G   R_E_D

No Firewall exceptions have been made because at least one network adapter has its Network category set to “Public”


# How to Fix This:

A quick and insecure way to change all network adapters to “Private” can be done via the following powershell command.

  PS# Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private

Output:

  InterfaceAlias NetworkCategory
  -------------- ---------------
  Ethernet               Private


## Enabling WinRM:

On each Device run the following powershell command:

  PS# Enable-PSRemoting -force

This time you should see:

  WinRM is already set up to receive requests on this computer.
  WinRM is already set up for remote management on this computer.
  PS#


# Check if WinRM is listening for Connections:

To check if the service is listening use the following PowerShell command

  PS# Get-NetTCPConnection | Where-Object -Property LocalPort -EQ 5985

You should see something like.

  LocalAddress   LocalPort RemoteAddress   RemotePort State    AppliedSetting   OwningProcess
  ------------   --------- -------------   ---------- -----    --------------   -------------
  ::             5985      ::              0          Listen                    4

At this stage we are still unable to establish a connection as the “Remote/Destination” device is not in our Local devices “TrustedHosts List”, as we do not have DNS available IP Addresses will be used.

If we try to establish a PSSession to the other Device we will get the following error.

  PS# $Session = New-PSSession -ComputerName 10.10.10.12

You should see something like.

  New-PSSession : [10.0.2.11] Connecting to ....S_O_M_E_T_H_I_N_G   R_E_D

Remote Host not in Local Trusted Host List


# Adding Trusted Hosts:

Run the following command to add the other Device into the TrustedHosts List.

  PS# winrm set winrm/config/client '@{TrustedHosts="10.0.2.10, 10.0.2.11"}'

Output:

  Client
      NetworkDelayms = 5000
      URLPrefix = wsman
      AllowUnencrypted = false
      Auth
          Basic = true
          Digest = true
          Kerberos = true
          Negotiate = true
          Certificate = true
          CredSSP = false
      DefaultPorts
          HTTP = 5985
          HTTPS = 5986
      TrustedHosts = 10.0.2.10, 10.0.2.11

fig# Remote Host Added to Local TrustedHost List.

Both servers have been added in the command above so that it is obvious how to add in multiple hosts


## Making a connection:

Now lets attempt a connection from from WinRM1/10.0.2.10 to WinRM2/10.0.2.11

  $Session = New-PSSession -ComputerName 10.0.2.11

It works!

  BURATINO

  FIG# WinRM Verify PSSession is Working.


## Inspect the port being used:

  PS# Get-NetTCPConnection | `
      Where-Object -Property RemotePort -EQ 5985 | `
      ft -AutoSize

Output:

  LocalAddress LocalPort RemoteAddress RemotePort State       AppliedSetting OwningProcess
  ------------ --------- ------------- ---------- -----       -------------- -------------
  10.0.2.10    49777     10.0.2.11     5985       Established Internet       7004
  10.0.2.10    49776     10.0.2.11     5985       Established Internet       7004
  10.0.2.10    49775     10.0.2.11     5985       Established Internet       7004

  fig# RinRM Inspect TCP Port it is running on


## The Script the Code:

Below is the essential commands needed to get WinRM up and running between the two Non Domain/Workgroup Windows Devices: BARBIE 10.0.2.10, BURATINO 10.0.2.11

  #Run this on both devices
  #Set all network adapters to Private

  Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private

  #Enable PSRemoting

  Enable-PSRemoting -force

  #Add Trusted Hosts

  winrm set winrm/config/client '@{TrustedHosts="10.0.2.10,10.0.2.11"}'


### HOW TO RUN POWERSHELL COMMANDS ON REMOTE COMPUTERS ###

Chris Hoffman
 @chrisbhoffman
July 20, 2017, 12:28am EDT

  https://www.howtogeek.com/117192
    /how-to-run-powershell-commands-on-remote-computers/

PowerShell Remoting lets you run PowerShell commands or access full PowerShell sessions on remote Windows systems. It’s similar to SSH for accessing remote terminals on other operating systems.

PowerShell is locked-down by default, so you’ll have to enable PowerShell Remoting before using it. This setup process is a bit more complex if you’re using a workgroup instead of a domain -- for example, on a home network -- but we’ll walk you through it.


# Enable PowerShell Remoting on the PC You Want to Access Remotely

Your first step is to enable PowerShell Remoting on the PC to which you want to make remote connections. On that PC, you’ll need to open PowerShell with administrative privileges. (In Windows 10, press Windows+X and then choose PowerShell (Admin) from the Power User menu.)

In the PowerShell window, type the following cmdlet (PowerShell’s name for a command), and then hit Enter:

  PS# Enable-PSRemoting -Force

  FIG#

This command starts the WinRM service, sets it to start automatically with your system, and creates a firewall rule that allows incoming connections. The -Force part of the cmdlet tells PowerShell to perform these actions without prompting you for each step.

If your PCs are part of a domain, that’s all the setup you have to do. You can skip on ahead to testing your connection. If your computers are part of a workgroup -- which they probably are on a home or small business network -- you have a bit more setup work to do.

Note: Your success in setting up remoting in a domain environment depends entirely on your network’s setup. Remoting might be disabled—or even enabled—automatically by group policy configured by an admin. You might also not have the permissions you need to run PowerShell as an administrator. As always, check with your admins before you try anything like this. They might have good reasons for not allowing the practice, or they might be willing to set it up for you.


## Set Up Your Workgroup

If your computers aren’t on a domain, you need to perform a few more steps to get things set up. You should have already enabled Remoting on the PC to which you want to connect, as we described in the previous section.

RELATED: What’s the Difference Between Private and Public Networks in Windows?

  https://www.howtogeek.com/245982
    /whats-the-difference-between-private-and-public-networks-in-windows/

Note: For PowerShell Remoting to work in a workgroup environment, you must configure your network as a private, not public, network. For more on the difference -- and how to change to a private network if you already have a public network set up -- check out our guide on private vs. public networks.

Next, you need to configure the TrustedHosts setting on both the PC to which you want to connect and the PC (or PCs) you want to connect from, so the computers will trust each other. You can do this in one of two ways.

If you’re on a home network where you want to go ahead and trust any PC to connect remotely, you can type the following cmdlet in PowerShell (again, you’ll need to run it as Administrator).

  PS# Set-Item wsman:\localhost\client\trustedhosts *

The asterisk is a wildcard symbol for all PCs. If instead you want to restrict computers that can connect, you can replace the asterisk with a comma-separated list of IP addresses or computer names for approved PCs.

After running that command, you’ll need to restart the WinRM service so your new settings take effect. Type the following cmdlet and then hit Enter:

  PS# Restart-Service WinRM

  FIG#

And remember, you’ll need to run those two cmdlets on the PC to which you want to connect, as well as on any PCs you want to connect from.


# Test the Connection

Now that you’ve got your PCs set up for PowerShell Remoting, it’s time to test the connection. On the PC you want to access the remote system from, type the following cmdlet into PowerShell (replacing “COMPUTER” with the name or IP address of the remote PC), and then hit Enter:

  PS# Test-WsMan COMPUTER

This simple command tests whether the WinRM service is running on the remote PC. If it completes successfully, you’ll see information about the remote computer’s WinRM service in the window -- signifying that WinRM is enabled and your PC can communicate. If the command fails, you’ll see an error message instead.

  FIG# Test-WsMan COMPUTER Output


# Execute a Single Remote Command

To run a command on the remote system, use the Invoke-Command cmdlet using the following syntax:

  Invoke-Command -ComputerName COMPUTER `
                 -ScriptBlock { COMMAND } `
                 -credential USERNAME

“COMPUTER” represents the remote PC’s name or IP address. “COMMAND” is the command you want to run. “USERNAME” is the username you want to run the command as on the remote computer. You’ll be prompted to enter a password for the username.

Here’s an example. I want to view the contents of the C:\ directory on a remote computer with the IP address 10.0.0.22. I want to use the username “wjgle,” so I would use the following command:

  Invoke-Command -ComputerName 10.0.0.22 `
                 -ScriptBlock { Get-ChildItem C:\ } `
                 -credential wjgle

  FIG# Dialogue!

# Start a Remote Session

If you have several cmdlets you want to run on the remote PC, instead of repeatedly typing the Invoke-Command cmdlet and the remote IP address, you can start a remote session instead. Just type the following cmdlet and then hit Enter:

  Enter-PSSession -ComputerName COMPUTER -Credential USER

Again, replace “COMPUTER” with the name or IP address of the remote PC and replace “USER” with the name of the user account you want to invoke.

  FIG# Session.

Your prompt changes to indicate the remote computer to which you’re connected, and you can execute any number of PowerShell cmdlets directly on the remote system.


# ANNEX C. WHAT ABOUT WINRM? (width 102)

  https://kimconnect.com/how-to-transfer-files-via-ssh-or-winrm/

We also have those commands here:

To copy a file from Local to Remote while logged into Local

  Copy-Item –Path C:\Source\file1.txt –Destination '\\Remote\c$\destination'

To copy a file from Remote to Local while logged into Local

  Copy-Item –Path \\Remote\C:$\Source\file1.txt –Destination 'C:\destination'

Wait-a-minute... This Copy-Item command is reliant on SMB (port 445). This defeats the purpose to being able to copy over the secure ports such as HTTPS/443 that WinRM should be running on. Ignoring the copying speed trade-off, here are some methods to transfer files using only WinRM ports.

Method 1: Copying from Local to Remote

  $session = New-PSSession –ComputerName REMOTE
  Copy-Item –Path C:\Source\file1.txt –Destination 'C:\Destination\' –ToSession $session
  $session | Remove-PSSession

Method 2: Copying from Local to Remote with 1-line

  Copy-Item -Path C:\Source\file1.txt `
            -Destination 'C:\Destination\ `
            -ToSession (New-PSSession -ComputerName SERVER1)

Here’s an even cooler PowerShell function, written by adamtheautomator.com guy.

function Send-File
{
	<#
	.SYNOPSIS
		This function sends a file (or folder of files recursively)
		to a destination WinRm session. This function was originally built
		by Lee Holmes (http://poshcode.org/2216) but has been modified to
		recursively send folders of files as well as to support UNC paths.
	.PARAMETER Path
		The local or UNC folder path that you'd like to copy to the session.
		This also support multiple paths in a comma-delimited format.
		If this is a UNC path, it will be copied locally to accomodate
		copying.  If it's a folder, it will recursively copy all files and
		folders to the destination.
	.PARAMETER Destination
		The local path on the remote computer where you'd like to copy the
		folder or file.  If the folder does not exist on the remote
		computer it will be created.
	.PARAMETER Session
		The remote session. Create with New-PSSession.
	.EXAMPLE
			$session = New-PSSession -ComputerName MYSERVER
			Send-File -Path C:\test.txt -Destination C:\ -Session $session
		This example will copy the file C:\test.txt to be C:\test.txt
		on the computer MYSERVER
	.INPUTS
		None. This function does not accept pipeline input.
	.OUTPUTS
		System.IO.FileInfo
	#>
	[CmdletBinding()]
	param
	(
		[Parameter(Mandatory)]
		[ValidateNotNullOrEmpty()]
		[string[]]$Path,

		[Parameter(Mandatory)]
		[ValidateNotNullOrEmpty()]
		[string]$Destination,

		[Parameter(Mandatory)]
		[System.Management.Automation.Runspaces.PSSession]$Session
	)
	process
	{
		foreach ($p in $Path)
		{
			try
			{
				if ($p.StartsWith('\\'))
				{
					Write-Verbose -Message "[$($p)] is a UNC path. Copying locally first"
					Copy-Item -Path $p -Destination ([environment]::GetEnvironmentVariable('TEMP', 'Machine'))
					$p = "$([environment]::GetEnvironmentVariable('TEMP', 'Machine'))\$($p | Split-Path -Leaf)"
				}
				if (Test-Path -Path $p -PathType Container)
				{
					Write-Log -Source $MyInvocation.MyCommand -Message "[$($p)] is a folder. Sending all files"
					$files = Get-ChildItem -Path $p -File -Recurse
					$sendFileParamColl = @()
					foreach ($file in $Files)
					{
						$sendParams = @{
							'Session' = $Session
							'Path' = $file.FullName
						}
						if ($file.DirectoryName -ne $p) ## It's a subdirectory
						{
							$subdirpath = $file.DirectoryName.Replace("$p\", '')
							$sendParams.Destination = "$Destination\$subDirPath"
						}
						else
						{
							$sendParams.Destination = $Destination
						}
						$sendFileParamColl += $sendParams
					}
					foreach ($paramBlock in $sendFileParamColl)
					{
						Send-File @paramBlock
					}
				}
				else
				{
					Write-Verbose -Message "Starting WinRM copy of [$($p)] to [$($Destination)]"
					# Get the source file, and then get its contents
					$sourceBytes = [System.IO.File]::ReadAllBytes($p);
					$streamChunks = @();

					# Now break it into chunks to stream.
					$streamSize = 1MB;
					for ($position = 0; $position -lt $sourceBytes.Length; $position += $streamSize)
					{
						$remaining = $sourceBytes.Length - $position
						$remaining = [Math]::Min($remaining, $streamSize)

						$nextChunk = New-Object byte[] $remaining
						[Array]::Copy($sourcebytes, $position, $nextChunk, 0, $remaining)
						$streamChunks +=, $nextChunk
					}
					$remoteScript = {
						if (-not (Test-Path -Path $using:Destination -PathType Container))
						{
							$null = New-Item -Path $using:Destination -Type Directory -Force
						}
						$fileDest = "$using:Destination\$($using:p | Split-Path -Leaf)"
						## Create a new array to hold the file content
						$destBytes = New-Object byte[] $using:length
						$position = 0

						## Go through the input, and fill in the new array of file content
						foreach ($chunk in $input)
						{
							[GC]::Collect()
							[Array]::Copy($chunk, 0, $destBytes, $position, $chunk.Length)
							$position += $chunk.Length
						}

						[IO.File]::WriteAllBytes($fileDest, $destBytes)

						Get-Item $fileDest
						[GC]::Collect()
					}

					# Stream the chunks into the remote script.
					$Length = $sourceBytes.Length
					$streamChunks | Invoke-Command -Session $Session -ScriptBlock $remoteScript
					Write-Verbose -Message "WinRM copy of [$($p)] to [$($Destination)] complete"
				}
			}
			catch
			{
				Write-Error $_.Exception.Message
			}
		}
	}

}

