Tag: macOS

PowerShell Remoting over SSH in PowerShell 7

Enable PowerShell SSH Remoting in PowerShell 7

In this blog post, we will have a look at how you can enable and set up PowerShell SSH Remoting or PowerShell Remoting over SSh with PowerShell 7. With PowerShell Core 6, Microsoft introduced PowerShell 7 Remoting over SSH, which allows true multiplatform PowerShell remoting between Linux, macOS, and Windows. PowerShell SSH Remoting creates a PowerShell host process on the target machine as an SSH subsystem. Normally, Windows PowerShell remoting uses WinRM for connection negotiation and data transport. However, WinRM is only available on Windows-based machines.

There are also some downsides to it. SSH-based remoting doesn’t currently support remote endpoint configuration and JEA (Just Enough Administration). It is also important to understand that this is not just another PowerShell SSH client.

Use SSH Transport with PowerShell Remoting

To use PowerShell 7 remoting with SSH on Windows, Linux, and macOS machines, you can use the same cmdlets you are already familiar from Windows PowerShell remoting with WinRM.

  • New-PSSession
  • Enter-PSSession
  • Invoke-Command

There are three new parameters for these cmdlets if you are using PowerShell SSH remoting.

  • -HostName (Instead of -Computername, you define the SSH target)
  • -UserName (Instead of -Credentials you use the -UserName parameter)
  • -KeyFilePath (If you are using SSH key authentication you can use the -KeyFilePath parameter to point to the key file)
New-PSSession -HostName tomsssh.server.com -UserName thomas

What's new in PowerShell 7

What’s new in PowerShell 7 – Check it out!

As you know, the PowerShell team just released the new PowerShell version called PowerShell 7. PowerShell 7 will brings a couple of new features and enhancements not only for users who used PowerShell Core 6 but also for people who are currently using Windows PowerShell 5.0. I want to quickly give you an overview of what’s new in PowerShell 7.

New feature enhancements – What’s new in PowerShell 7

There are many enhancements in PowerShell 7 to make it the best PowerShell version yet. It is almost impossible to list all of them in one single blog post, so I will focus on the once, which are the most important once for me.

Out-GridView, -ShowWindow and other GUI cmdlets are back on Windows

With .NET Core 3 brining back WPF support on Windows, the PowerShell team was able to bring back some of the popular graphical tools and cmdlets like Out-Gridview, Show-Command, and the Get-Help -ShowWindow.

Show-Command PowerShell 7

Show-Command PowerShell 7

ForEach-Object -Parallel

Since I started using PowerShell and get into working with objects, ForEach-Object was one of the most critical cmdlets. By adding the -Parallel parameter to the ForEach-Object cmdlet, you can execute a scriptblock in parallel, similar to the option we had with PSWorkflow. With that performance can get so much better if you are working with a broad set of objects. You can also optionally set the maximum threads, which will be used in parallel (the default thread count is set to 5) with the -ThrottleLimit parameter.

PowerShell 7 Installer

How to Install and Update PowerShell 7

The PowerShell team just announced PowerShell 7. PowerShell 7 is built on .NET Core 3 and brings back many APIs required by modules built on .NET Framework so that they work with .NET Core runtime. While PowerShell Core 6 was focusing on bringing cross-platform compatibility, PowerShell 7 will focus on making it a viable replacement for Windows PowerShell 5.1 and bringing near parity with Windows PowerShell. Here is how you can install and update PowerShell 7 on Windows and Linux using a simple one-liner.

If you want to know what’s new in PowerShell 7, check out my blog post!

One great example of how cross-platform PowerShell can work, check out my blog post: How to set up PowerShell SSH Remoting.

Install PowerShell 7

Before showing you the one-liner option to install PowerShell 7, I want to share with you the documentation to install PowerShell 7 on different operating systems like Windows, macOS, and Linux.

One-liner to install or update PowerShell 7 on Windows 10

Steve Lee (Microsoft Principal Software Engineer Manager in the PowerShell Team) shared some one-liner, which helps you quickly install and update:

Install and Update PowerShell 7

You can use this single command in Windows PowerShell to install PowerShell 7.

iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"

There are additional switches to, for example, install daily builds of the latest PowerShell previews.

The destination path to install PowerShell Core to.

Install PowerShell Core from the daily build.
Note that the ‘PackageManagement’ module is required to install a daily package.

Install the latest preview, which is currently version 7.

Use the MSI installer.

The quiet command for the MSI installer.

Do not overwrite the destination folder if it already exists.

On Windows, add the absolute destination path to the ‘User’ scope environment variable ‘Path’;
On Linux, make the symlink ‘/usr/bin/pwsh’ points to “$Destination/pwsh”;
On MacOS, make the symlink ‘/usr/local/bin/pwsh’ points to “$Destination/pwsh”.

One-liner to install or update PowerShell 7 on Linux

Install PowerShell 7 on Linux

You can use this as a single command to install PowerShell 7 on Linux.

wget https://aka.ms/install-powershell.sh; sudo bash install-powershell.sh; rm install-powershell.sh

Depending on your distro you are using, this will register Microsoft’s pkg repos and install that package (deb or rpm).

You can also use the following switches:

Installs VSCode and VSCode PowerShell extension (only relevant to machines with a desktop environment)

Do a quick launch test of VSCode (only applicable when used with -includeide)

Use sudo without verifying its availability (hard to accurately do on some distros)

Installs the latest preview release of PowerShell side-by-side with any existing production releases

To currently run the PowerShell Preview, you can run the following command:


After Installing

After you have installed PowerShell 7, also make sure to update PowerShellGet and the PackageManagement module.

I hope this blog post was helpful. If you have any questions, please let me know in the comments.

How to Install AzCopy

How to Install AzCopy for Azure Storage

AzCopy is a command-line tool to manage and copy blobs or files to or from a storage account. It also allows you to sync storage accounts and move files from Amazon S3 to Azure storage. In this blog post, I will cover how to install AzCopy on Windows, Linux, macOS, or in update the version in the Azure Cloud Shell.

AzCopy v10 is now generally available to all of our customers and provides higher throughput and more efficient data movement compared to the earlier version of AzCopy (v8). Version 10 also adds additional functionality like sync of blob storage accounts and much more.

Install AzCopy

You can get the latest version of AzCopy from here: Get started with AzCopy

Install AzCopy on Windows

To install AzCopy on Windows, you can run the following PowerShell script, or you can download the zip file and run it from where ever you want. This script will add the AzCopy folder location to your system path so that you can run the AzCopy command from anywhere.

#Download AzCopy
Invoke-WebRequest -Uri "https://aka.ms/downloadazcopy-v10-windows" -OutFile AzCopy.zip -UseBasicParsing
#Curl.exe option (Windows 10 Spring 2018 Update (or later))
curl.exe -L -o AzCopy.zip https://aka.ms/downloadazcopy-v10-windows
#Expand Archive
Expand-Archive ./AzCopy.zip ./AzCopy -Force
#Move AzCopy to the destination you want to store it
Get-ChildItem ./AzCopy/*/azcopy.exe | Move-Item -Destination "C:\Users\thmaure\AzCopy\AzCopy.exe"
#Add your AzCopy path to the Windows environment PATH (C:\Users\thmaure\AzCopy in this example), e.g., using PowerShell:
$userenv = [System.Environment]::GetEnvironmentVariable("Path", "User")
[System.Environment]::SetEnvironmentVariable("PATH", $userenv + ";C:\Users\thmaure\AzCopy", "User")

Install AzCopy on Linux

To install AzCopy on Linux, you can run the following shell script, or you can download the tar file and run it from where ever you want. This script will put the AzCopy executable into the /usr/bin folder so that you can run it from anywhere.

#Download AzCopy
wget https://aka.ms/downloadazcopy-v10-linux
#Expand Archive
tar -xvf downloadazcopy-v10-linux
#(Optional) Remove existing AzCopy version
sudo rm /usr/bin/azcopy
#Move AzCopy to the destination you want to store it
sudo cp ./azcopy_linux_amd64_*/azcopy /usr/bin/

Authorize with Azure Storage

When you start working with Azure Storage, you have two options to authorize against the Azure Storage. You can provide authorization credentials by using Azure Active Directory (AD), or by using a Shared Access Signature (SAS) token.

It also depends on which services you want to use.

Storage typeSupported method
Blob storageAzure AD and SAS
Blob storage (hierarchical namespace)Azure AD
File storageSAS only

Authenticate using Azure AD

To authenticate with AzCopy using Azure AD, you can use the following command

azcopy login

Authenticate using SAS token

To authenticate with AzCopy using a SAS token you can use this command as an example

azcopy cp "C:\local\path" "https://account.blob.core.windows.net/mycontainer1/?sv=2018-03-28&ss=bjqt&srt=sco&sp=rwddgcup&se=2019-05-01T05:01:17Z&st=2019-04-30T21:01:17Z&spr=https&sig=MGCXiyEzbtttkr3ewJIh2AR8KrghSy1DGM9ovN734bQF4%3D" --recursive=true

To make things easier you can use Azure PowerShell to generate the SAS token for you. I wrote a blog post on ITOPSTALK.com about how you can do that. You can get the SAS token using the following Azure PowerShell command. If you are running Linux or macOS, you can find on this blog post, how to install PowerShell 6.

$subscriptionId = "yourSubscriptionId"
$storageAccountRG = "demo-azcopy-rg"
$storageAccountName = "tomsaccount"
$storageContainerName = "images"
$localPath = "C:\temp\images"
Select-AzSubscription -SubscriptionId $SubscriptionId
$storageAccountKey = (Get-AzStorageAccountKey -ResourceGroupName $storageAccountRG -AccountName $storageAccountName).Value[0]
$destinationContext = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
$containerSASURI = New-AzStorageContainerSASToken -Context $destinationContext -ExpiryTime(get-date).AddSeconds(3600) -FullUri -Name $storageContainerName -Permission rw
azcopy copy $localPath $containerSASURI --recursive

To learn more about SAS tokens, check out Using shared access signatures (SAS).

I hope this helps you to install AzCopy and configure it. If you have any questions, feel free to leave a comment.

Install or Update PowerShell 6 on Windows 10

How to Install and Update PowerShell 6

Today Windows 10 and Windows Server 2019 ship with Windows PowerShell 5.1 as the default version. PowerShell Core 6 is a new edition of PowerShell that is cross-platform (Windows, macOS, and Linux), open-source, and built for heterogeneous environments and the hybrid cloud. PowerShell 6 today is a side by side version next to Windows PowerShell 5.1. That means on Windows you cannot just upgrade to PowerShell 6, you will need to install it, same as on Linux and macOS. This blog post shows you how simple you can install PowerShell 6 or update PowerShell 6, if you have already installed it, on Windows 10, Windows Server 2019 or Linux.

One great example of how cross-platform PowerShell can work, check out my blog post: How to set up PowerShell SSH Remoting

Of course, you can find excellent documentation out there on Microsoft Docs. However, Steve Lee (Microsoft Principal Software Engineer Manager in the PowerShell Team) shared some one-liner, which helps you quickly install and update PowerShell 6.

Install PowerShell Core 6

Before showing you the one-liner option to install PowerShell 6, I want to share with you the documentation to install PowerShell Core 6 on different operating systems like Windows, macOS, and Linux.

PowerShell Core

PowerShell Core 6.0 for Windows, Linux and macOS General Available (GA)

Microsoft yesterday announced the general availability of PowerShell Core 6.0. PowerShell Core 6.0 is a new edition of PowerShell that is cross-platform (Windows, macOS, and Linux), open-source, and built for heterogeneous environments and the hybrid cloud. PowerShell Core uses .NET Core 2.0 as its runtime. PowerShell Core also exposes the API set offered by .NET Core 2.0 to be used in PowerShell cmdlets and scripts.

You can find more about how to install  and update PowerShell 6 on my blog.

First and foremost, thank you to all of our amazing community, especially our open-source contributors (the most recent of which you can find on our community dashboard at https://aka.ms/PSGitHubBI) for donating your time and energy to PowerShell Core. Whether you contributed code, tests, documentation, issues, or even just your feedback and opinions, we are extremely grateful for the sweat and tears that you’ve invested in PowerShell. (For those interested in contributing, hop and over to our Contribution Guide on GitHub. You don’t have to be a guru to help out!)

Quote: PowerShell Team Blog: PowerShell Core 6.0: Generally Available (GA) and Supported!

PowerShell Core Installer

You can get PowerShell Core 6.0 in the links below, or you can also check out my blog post about how to install PowerShell 6.

PowerShell Core is open source and you can have a look at the code on PowerShell on GitHub. I hope this article gives you an overview about the new PowerShell Core 6.0. If you have any questions, feel free to leave a comment.

Surface Precisiaon Mouse Box

Microsoft Surface Precision Mouse Review

Last week I got the Microsoft Surface Precision Mouse delivered. The Surface Precision Mouse will become the replacement mouse for my Microsoft Sculpt Mouse, which I used for the last couple of years. Now I want to give you some impressions about the Surface Precision Mouse, since I am very happy and very surprised about the feature set.

Surface Precision Mouse

First of all the Microsoft Surface Precision Mouse feels awesome, very high quality and it is very comfortable in your hand. It feels very precise and you get very quickly used to it.

Now let me write about some extra features you might didn’t know about. You first get a button to configure the scroll wheel in two different speeds, one feels very light and fast and the other one is slower and is more resistant, so you can choose what you like more and switch between them, depending on your task.

Microsoft Surface Percision Mouse Settings

Of course you get some extra buttons which you can customize with different shortcuts, for example to open the Windows 10 Tasks View or other applications. You can also customize the buttons depending on the application you are working with.

Surface Precision Mouse Bottom

By already having the perfect mouse, in terms of feeling, comfort, precision and customizability, you get a really cool extra feature. The Surface Precision Mouse gives you more multi-tasking power by allowing you to work seamlessly across up to three computers, supports both Bluetooth and wired USB connections. You can pair your Surface Precision Mouse with three different devices and you can manually switch between them with the button on the bottom of the mouse, or you can use something called Smart Switch.

Microsoft Surface Percision Mouse Smart Switch

Smart Switch on the Surface Precision Mouse can be enabled by using the Microsoft Mouse and Keyboard Center. It allows you to setup the workplace layout in the app and now you can move the cursor to the border of the screen and the mouse will seamlessly switch to the other device. So if you are working on your desktop and you have your notebook right next to it, you can easily move the mouse from one device to the other.

Overall I am super happy with the new device!


Surface Precision Mouse Specs

The mouse also works with Windows 7, Windows 10, Windows 8.1 and macOS devices as long as they support Bluetooth 4.0 or higher.

InterfaceUSB 2.1, Bluetooth® Low Energy 4.0/4.1/4.2Dimensions4.8 x 3.05 x 1.7 (122.6 mm x 77.6 mm x 43.3 mm)
Wireless Frequency2.4GHz frequency rangeWeight4.76 ounces (135 grams) including rechargeable batteries
Buttons6 buttons, including right and left click and scroll wheel buttonBatteryRechargeable lithium ion battery (included)
DesignErgonomic design with side gripsBattery LifeUp to 3 months
ScrollingSmooth or magnetic detent customizable horizontal and vertical scrolling1ColorGray