PowerShell

PowerShell content for the modern Microsoft data platform: automation, dbatools, SSH-based remoting across Windows and Linux, container scripting, and the Pure Storage PowerShell SDK.

Restoring Backups from Azure Blob with dbatools

Recently I needed to write a PowerShell script that could build a backup set from a collection of backups stored in Azure Blob Storage without any backup history available from MSDB. And as with all things SQL Server and PowerShell related I went straight to dbatools.io to see if Restore-DbaDatabase was up to the task…and of course, it is…let’s talk about how I solved this challenge.

When restoring from Azure Blob, the main challenge you have is accessing the blobs and building a backup set. For this process, you’ll need access to the Storage Account via PowerShell and you’ll have to have define a Credential on your SQL Instance that has access to the Storage Account. Here’s the code I used to connect to my Storage Account in Azure.

OpenSSH Resources for Windows and PowerShell

Had a conversation with a good friend in the SQL Community about OpenSSH and how it fits as a transport layer for PowerShell Remoting. I pointed him towards several resources I have online. So here’s a post aggregating those resources.

If you’re looking to get started with OpenSSH on Linux and Windows Systems check out thisPowerShell Summit presentation I did in 2018. This covers OpenSSH in theory and practice.

Session: OpenSSH Internals for PowerShell Pros

Using PowerShell in Containers

The vision for PowerShell Core is to be able to run PowerShell anywhere. In this article, I’m going to discuss how you can use Docker Containers to enable just that. We’ll look at running PowerShell in a container, running cmdlets, running different versions of PowerShell at the same time, and also how to build our own “serverless” computing platform.

Let’s address a few reasons why you would want to run PowerShell in a container.

Speaking at PowerShell Summit 2019

Speaking at PowerShell Summit 2019!

  I’m proud to announce that I will be speaking at <a href="https://app.socio.events/MjQ4Nw/Overview/14440">PowerShell + DevOps Global Summit 2019</a> the conference runs from April 29th 2018 through May 3rd 2019. This is an incredible event packed with fantastic content and speakers. <a href="https://powershelldevopsglobalsummit2018.sched.com/">Check out the amazing schedule</a>! All the data you need on going is in this excellent brochure <a href="https://powershell.org/wp-content/uploads/2017/09/2018-Brochure.pdf">right here</a>!

  This year I have two sessions!

  On **Tuesday, April 30th at 11:00AM** – I’m presenting “<a href="https://app.socio.events/MjQ4Nw/agenda/14445/session/61468">**Firewall Evasion and Remote Access with OpenSSH**</a>”

  Here’s the abstract

<blockquote>

    OpenSSH is much more than just remote terminal access to servers, it provides a full suite of remote connectivity methods t you network and its services. In this session, we will look at how to use OpenSSH and its forwarding, tunneling and VPN capabilities so that we can securely reach network services that are behind firewalls and other security boundaries.

    Common use cases for these techniques are cloud jump boxes, secure access into segmented networks, and being able to get remove access and moving data around in poorly secured networks…these tips are are things that will likely get you some extra attention from your security team.

    We will look at the following techniques:<br />– Accessing remote services with SSH Tunneling<br />– Building SWSH connections for multi-hop remote access using ProxyHosts<br />– Proxying HTTP/HTTPS connections with a Sock Proxy<br />– Using aliases to store these advanced configurations for easy use<br />– Controlling and preventing TCP tunneling

</blockquote>

  On **Thursday, May 1st at 1:00PM** – I’m presenting **“<a href="https://app.socio.events/MjQ4Nw/agenda/14445/session/61467">Containers – You Better Get on Board!</a>”**

  Here’s the abstract

<blockquote>

    Containers are taking over, changing the way systems are developed and deployed…and that’s now hyperbole. Just imagine if you could deploy SQL Server or even your whole application stack in just minutes. You can do that, leveraging containers! In this session, we’ll get your started on your container journey, learn some common container scenarios and introduce deployment automation with Kubernetes.

    In this session we’ll look at<br />– Container Fundamentals<br />– Common Container Scenarios<br />– Automation with Kubernetes<br />– Using PowerShell Containers

</blockquote>

I look forward to seeing you there.

Testing if a Port is Open With PowerShell

Ever want to confirm that a port is accessible from one computer to another? There’s a PowerShell cmdlet for that, Test-NetConnection. With the -Port option, this cmdlet will do a quick TCP three-way handshake on the remote system to confirm that the service is available and reports back if it succeeded or not. Check out that last line of output TcpTestSucceeded: False. That indicates that this port is not accessible. You can see, however, that the system is reachable via ICMP (Ping), PingSuceeded: True so we know that the remote system is alive, just not listening on the port we want to access.

Linux LFCE Learning Path Available at Pluralsight

I’m proud to announce the completion of my first Pluralsight Learning Path. This learning path is built to advance your Linux knowledge to the system administrator or system engineer level. In this series of courses you’ll learn the theory behind how things work and also practice demonstrations and tips to really nail home the things you need to know to run production Linux systems.

The learning objectives of this series align with the Linux Foundation Certified Engineer (LFCE) certification “Domains and Competencies” however these courses will be very valuable to your development as a Linux professional even if you’re not interested in certification.

Installing OpenSSH Server on Windows 10

So in yesterday’s post we learned that the OpenSSH client is included with the Windows 10, Update 1803!  Guess, what else is included in this server, an OpenSSH Server! Yes, that’s right…you can now run an OpenSSH server on your Windows 10 system and get a remote terminal! So in this post, let’s check out what we need to do to get OpenSSH Server up and running.

First, we’ll need to ensure we update the system to Windows 10, Update 1803. Do that using your normal update mechanisms.

OpenSSH is now Part of Windows!

Today is a big day! The OpenSSH client version 7.6p1 is now part of the Windows 10 operating system! Microsoft released Windows 10 Update 1803 and included in that release is the OpenSSH client, which is installed as part of the update.

That’s right an SSH client as part of the Windows operating system by default! Also included with this update is the OpenSSH Server which is included as an Windows Feature on Demand.

Distributing SSH User Keys via PowerShell

Folks in the Linux world are used to moving SSH keys to and from systems enabling password-less authentication. Let’s take a minute to look at what it takes to use PowerShell to distribute SSH user keys to remote systems.

In the OpenSSH package there’s a command ssh-copy-id which is a bash script that copies a user’s public key to a remote system. There’s a little intelligence in the script to set things up properly on the remote system for password-less key based authentication. If the appropriate directory and key file aren’t set up, ssh-copy-id will create the directory and key file with the correct permissions on remote system. As far as I can tell, ssh-copy-id has not been implemented in the Win32-OpenSSH port. So that leaves us with implementing this functionality ourselves, in PowerShell.

Speaking at PowerShell Summit 2018!

I’m proud to announce that I will be speaking at PowerShell + DevOps Global Summit 2018 on the conference runs from April 9th 2018 through April 12th 2018. This is an incredible event packed with fantastic content and speakers. Check out the amazing schedule! All the data you need on going is in this excellent brochure right here!

This year I have two sessions!

On Tuesday, April 10th at 2:00PM – I’m presenting “OpenSSH Internals for PowerShell Pros