Tag: PowerShell

Last updated by at .

Azure Stack Azure Cloud Shell

Connect to Azure Stack from Azure Cloud Shell

A little while ago Microsoft announced the Azure Cloud Shell. The Azure Cloud Shell is a perfect tool to manage your Azure resources using the Azure CLI or Azure PowerShell. Wouldn’t it be great to also manage your resources running on Azure Stack? Thanks to the consistency between Microsoft Azure and Microsoft Azure Stack, you can use the same tools to manage your hybrid cloud.

First of all login to your Azure Cloud Shell on shell.azure.com or in the Azure Portal.

Azure Cloud Shell

After the login you have to register Azure Stack as a new cloud by running the following command:

Azure Stack Cloud List Azure CLI

Now you can list the new Azure Stack cloud by using:

To switch to the Azure Stack Cloud use the following command:

If you are doing this the first time and you use another account you can use az login to login.

One thing you should do is to switch the profile version to an Azure Stack compatible version

Azure Cloud Shell Azure Stack

Now you can start using the Azure CLI in the Azure Cloud Shell to manage your Azure Stack. First of all yes this works also if you just use the Azure CLI. In the case of the Azure Cloud Shell the Azure Stack needs to be accessible from the internet. If your Azure Stack is not accessible from the internet, you can just use the Azure CLI directly from your management machine.

Azure Stack Cloud Shell Visual Studio Code

Fun Fact, since you an also run the Azure Cloud Shell directly in Visual Studio Code, you can also just open up the shell session and start working from Visual Studio Code.

 

 

 



Ubuntu on Windows Server using WSL

Install Windows Subsystem for Linux on Windows Server

In 2017 Microsoft made it possible to run different Linux distribution on Windows 10, using a feature called the “Windows Subsystem for Linux“. With the latest official Semi-Annual Channel Windows Server release called Windows Server, version 1709 Microsoft also allowed to run the Windows Subsystem for Linux (WSL) on Windows Server. With the next release of Windows Server called Windows Server, version 1803, Microsoft will also add some improvements to the Windows Subsystem on Linux, which also apply to Windows 10 as well as Windows Server. This blog post shows you how you can do this.

First you have a Windows Server, version 1709 running. After that enable the Microsoft Windows Subsystem for Linux feature, running the following command (This will need a reboot)

You can download the appx packages for you favorite Linux distribution, this can be today:

  • Ubuntu
  • OpenSUSE
  • Suse Linux Enterprise Server

If you are running on Windows Server Core (which is highly likely), you can use the following command to download the Linux distributions.

You can then unpack the file:

Now you can open that folder and run the installer for example ubuntu.exe. The first time this will do the setup where you also define the UNIX username and password as well as the root password.

WSL on Windows Server

After that you can run updates for your distro and you can start using Linux.

If you want to know more about the WSL, check out the Microsoft Documentation: Windows Subsystem for Linux Documentation and have a look at my WSL post in for Windows 10: Crazy times – You can now run Linux on Windows 10 from the Windows Store



Hyper-V HVC SSH Direct for Linux VMs

HVC – SSH Direct for Linux VMs on Hyper-V

If you are running Hyper-V on Windows 10 or on Windows Server 2016, you probably know about a feature called PowerShell Direct. I also mentioned that PowerShell Direct is one of the 10 hidden features in Hyper-V you should know about. PowerShell Direct lets you remote connect to a Windows Virtual Machine running on a Hyper-V host, without any network connection inside the VM. PowerShell Direct uses the Hyper-V VMBus to connect inside the Virtual Machine. Of course this feature is really handy if you need it for automation and configuration for Virtual Machines. As this is great for Windows virtual machines, it does not work with Virtual Machines running Linux. In the latest Windows 10, Windows Server 1803 (RS4) and Windows Server 2019 (RS5) Insider Preview builds, Microsoft enabled a tool called HVC. HVC is at tool which allows you to do some command line VM management. HVC SSH is basically SSH Direct of Linux VMs.

This allows to connect to a Linux VM using SSH over the Hyper-V VMBus. You are also able to copy file inside a virtual machines using scp.

How to connect to Linux VMs using SSH Direct

HVC SSH on Hyper-V

To connect to Linux VMs using SSH Direct (HVC) simply type hvc.exe into the command line or PowerShell. This will give you all the possible command options. Of course SSH has to big configured inside the Linux virtual machine.

To make this work, the SSH server inside the VM needs to be configured.

Final Thoughts

Pretty cool tool which will be available in the official releases of Windows 10 and Windows Server 1803, released this spring. Later this year this feature will also be included in Windows Server 2019. If you want to try it out today, give the Windows Insider Preview builds a spin.

Thanks to Ben Armstrong for pointing this out 😉



Azure Stack PowerShell Docker Container

Run Azure Stack PowerShell and Azure Stack Tools in a Docker Container

The Azure Stack Tools is a set of scripts and tools to work with Azure Stack and Azure. If you want to run the Azure Stack Tools you will need to install the Azure Stack compatible Azure PowerShell module. To install that that can be some work and it does not allow to run the side by side today with the latest Azure PowerShell Module. For that I have a simple solution. I created two Docker Containers with preinstalled Azure Stack PowerShell and one with Azure Stack PowerShell and the Azure Stack Tools together.

AzureStack-Tools is a GitHub repository that hosts PowerShell modules for managing and deploying resources to Azure Stack. If you are planning to establish VPN connectivity, you can download these PowerShell modules to the Azure Stack Development Kit, or to a Windows-based external client

Azure Stack PowerShell Docker Container

Azure Stack PowerShell Docker Container

This container contains the Azure Stack PowerShell. To run Azure Stack PowerShell in a Docker Container, just run the following command on your server or PC with Docker installed.

Azure Stack Tools Docker Container

Azure Stack Tools Docker Container

This container contains the Azure Stack PowerShell as well as the Azure Stack Tools. To run Azure Stack Tools in a Docker Container, just run the following command on your server or pc with Docker installed.

Both Images are based on Windows Server Core and depending on the microsoft/windowsservercore Docker images.

This should help you to quickly spin up new Azure Stack Operator Workstations. And it should help you to work and interact with Azure Stack.



My Favorite Visual Studio Code Themes

While I am doing presentations, I often do demos, and since a lot of my demos are PowerShell based, I use a lot of Visual Studio Code. With that I often get the question which is the Visual Studio Code Theme I use. Even I change my Visual Studio Code Themes pretty often, I have a couple of favorites I want to share.

Cobalt2

Visual Studio Code Theme Cobalt2

My current favorite Visual Studio Code Theme is Cobalt2. Cobalt2 is a dark but colorful theme for Visual Studio. I like it because it is a dark theme, but it not uses the classic dark grey background, instead I like the mix of dark blue and yellow.

Atom One Dark

Visual Studio Code Theme Atom One Dark

Atom One Dark is another Dark theme I started to like very much. I like the popping colors on the dark background.

Ayu Mirage – Visual Studio Code Theme

Visual Studio Code Theme Ayu Mirage

The Ayu Themes for Visual Studio are simple, bright and elegant themes. I prefer the Ayu Mirage theme which as I said looks very elegant. The Ayu themes also have other options like the Ayu light which is also one of my favorites.

Dracula

Visual Studio Code Theme Dracula

Dracula is one of the famous Visual Studio Code themes, which is also available on other platforms. When I am not using the Cobalt2 theme, I most often switch to Dracula.

Ayu Light

Visual Studio Code Theme Ayu Light

I mentioned the Ayu Themes before, and this is the light version of it. I am mostly using dark themes, but when I switch to a light theme, I mostly use Ayu Light.

PowerShell ISE

Visual Studio Code Theme PowerShell ISE

If you are coming form PowerShell scripting, you are already familiar with the PowerShell ISE. The PowerShell ISE theme bring you back in to the old school world and even gives you the PowerShell blue background terminal.

There are a lot of other great Visual Studio Code Themes out there. What is your favorite? Let me know in the comments!



DSCManager_Clients

Announcing the itnetX PowerShell DSC Manager

Less than a year ago I worked with a couple of enterprise customers and had some interesting talks about configuration management in a modern Windows Server based datacenter where PowerShell DSC is the obvious. However the lack of graphic on premise management tools was a huge challenge for a lot of companies. While the concept of writing your configurations may not seem complicated, appropriately distributing them to machines and being able to report on the status is something that is very challenging to do on-prem. That’s where the idea was born to bring a graphical user experience for PowerShell DSC.

DSCManager_Green_150x150

Within itnetX we have done a couple of projects for service providers and other customers to help them automate deployments but also do configuration management, which provides us with the technical knowledge and experience what customers truly need.

Today I am happy to announce the itnetX DSC Manager.

Our customers love DSC to manage the configuration of their servers. However, they complain that maintaining DSC and getting insights is very cumbersome due to the lack of a user interface.

With DSC Manager, we respond to our customers with an easy to use and fresh user experience for having DSC under total control.

Dieter Gasser, itnetX Head of Product Management

itnetX DSC Manager

DSCManager_Dashboard

The itnetX DSC Manager provides a single pane of glass for all your clients, configurations and modules, regardless of where they are in your datacenter. itnetX DSC Manager allows you to implement configuration management the way DSC was intended from the beginning. Allowing you to effectively mitigate configuration drift, reconfigure servers with a few clicks and report on the configuration of any one server or group of servers

Key Benefits

  • Easy to read reports & dashboards
  • Remote configuration of LCM
  • Graphically view and build configurations
  • Manage large estates of PullServers
  • Build into existing automation with REST
  • Audit changes for compliance

Features

  • HTML reports and dashboards
  • Assign Named and Partial configurations
  • Configure LCM remotely to control for example reboot behavior
  • Visually view and build configurations
  • Manage agents from multiple PullServers
  • Manage Module repository
  • Automate via REST

Get Free Trial

DSC Manager is delivered as a prepackaged web application. The installation is simple and the clients can be installed and up and running within minutes. You can use DSC Manager for free to manage up to 5 clients. For managing more clients, you will require a license.

Big thanks goes to itnetX and the team behind the DSC Manager. itnetX also has a process in place which allows employees to build and work on their own ideas and bring them to market. Together with DSC experts like Ryan Bartram itnetX started that journey and we finally have something to celebrate.

Btw: If you need some help for a faster setup, check out: the Quick itnetX DSC Manager Installer script, which removes a couple of manual tasks.

 



Azure Stack Tools

Setup an Azure Stack Cloud Operator and Developer Workstation Environment

If you are responsable to manage and operate Azure Stack, you will need to enable a couple of tools to manage Azure Stack. This post should give you a summary of what you should do to setup your Azure Stack Operator and Developer workstation environment.

Operating System

Azure Stack Windows Admin Workstation

First of all you should setup a clean base system. I usually use the latest version of Windows 10, right now the latest Windows 10 version is the Fall Creators Update which give you some great features like the OpenSSH client or the Windows Subsystem for Linux build in, or I use Winodws Sevrer 2016 with Desktop Expierence. Make sure you install all the latest updates for Microsoft Update.

Install Visual Studio Code

PowerShell for Visual Studio Code

Visual Studio Code is a new, free, lightweight cross-platform code editor for building modern web and cloud applications on Mac OS X, Linux and Windows. It is perfect for editing JSON files and even writing some code. And it has a built-in Terminal so you don’t have to switch between different windows.

I recommend you install the following Extensions:

Install SSH Client or Windows Subsystem for Linux (WSL)

OpenSSH Windows 10

To manage Linux Virtual Machines running on Azure Stack or if you need to manage the hardware switches in Azure Stack or your border switches where Azure Stack is connected, SSH is the way to access it. Windows 10 now comes with several builtin options like the OpenSSH Client which you can install as addtional feature or for example the Windows Subsystem for Linux (WSL) which allows you to run several linux tools on Windows directly. If you are using another version of Winodws, the thrid party application PuTTY is your friend.

You can also using PowerShell to install it:

Install Azure Stack PowerShell

Install Azure Stack PowerShell

Azure Stack compatible Azure PowerShell modules are required to work with Azure Stack. PowerShell commands for Azure Stack are installed through the PowerShell gallery, you can run the following commands to install it: (Make sure there are no other Azure PowerShell Modules installed, if there are, the commands will remove them). If you also install Visual Studio, install Visual Studio first before you install the Azure Stack PowerShell.

If you need to install it on a machine which does not have access to the internet. check outthe offical Microsoft page: Install PowerShell for Azure Stack

Install Azure Stack tools

Azure Stack Tools

AzureStack-Tools is a GitHub repository that hosts PowerShell modules that you can use to manage and deploy resources to Azure Stack. This brings you several functionalities for Azure Stack management:

  • Deployment of Azure Stack – Helps prepare for Azure Stack deployment.
  • Resource Manager policy for Azure Stack – Constrains Azure subscription to the capabilities available in the Azure Stack.
  • Connecting to Azure Stack – Connect to an Azure Stack instance from your personal computer/laptop.
  • Setting up Identity for Azure Stack – Create and manage identity related objects and configurations for Azure Stack
  • Azure Stack Service Administration – Manage plans and subscriptions in Azure Stack.
  • Azure Stack Compute Administration – Manage compute (VM) service in Azure Stack.
  • AzureRM Template validator – Validate Azure ARM Template Capabilities
  • Azure Stack Infrastructure Administration – Manage Azure Stack Infrastructure

You can get the Azure Stack tools from GitHub:

You can directly open that folder in Visual Studio Code:

Configure Azure Stack PowerShell environment

As an Azure Stack user, you can configure your Azure Stack PowerShell environment. After you configure, you can use PowerShell to manage Azure Stack resources such as subscribe to offers, create virtual machines, deploy Azure Resource Manager templates, etc.

For an Azure Stack deployment which is using Azure Active Directory (AAD) as an Identity provider, you can use the following commands:

Install and configure CLI for use with Azure Stack

Azure CLI

You can also use the Azure CLI 2.0 to manage Azure Stack.

Install Azure CLI on Windows using MSI

To install the CLI on Windows and use it in the Windows command-line, download and run the Azure CLI Installer (MSI).

Install with apt-get for Bash on Ubuntu on Windows (WSL)

  1. Open the Bash shell.
  2. Modify your sources list.
  3. Run the following sudo commands:
  4. Run the CLI from the command prompt with the az command.

Connect to Azure Stack using the Azure CLI

If you are using Public Certificates for your Azure Stack, this is pretty staight forward, if you are using the Azure Stack Development Kit or an Internal CA, make sure your client trusts the Azure Stack CA root Certificate. You can find more here: Install and configure CLI for use with Azure Stack

Register your Azure Stack environment by running the az cloud register command.

Register as a cloud administrative environement:

  1. To register the cloud administrative environment, use:
  2. Set the active environment by using the following commands.
  3. Update your environment configuration to use the Azure Stack specific API version profile. To update the configuration, run the following command:
  4. Sign in to your Azure Stack environment by using the az login command. You can sign in to the Azure Stack environment either as a user or as a service principal.

Register the user environment, use:

  1. To register the user environment, use:
  2. Set the active environment by using the following commands.
  3. Update your environment configuration to use the Azure Stack specific API version profile. To update the configuration, run the following command:
  4. Sign in to your Azure Stack environment by using the az login command. You can sign in to the Azure Stack environment either as a user or as a service principal.

Install the Microsoft Azure Storage Explorer

Azure Stack Azure Storage Explorer

To access and manage Azure Stack Storage Accounts you can also use the Microsoft Azure Storage Explorer tool. Microsoft Azure Storage Explorer (Preview) is a standalone app from Microsoft that allows you to easily work with Azure Storage data on Windows, macOS and Linux.

If you are running the Azure Stack Development Kit, you should again have a look how you get the certificates implace, you can find that here: Connect Storage Explorer to an Azure Stack subscription

  1. Install the Microsoft Azure Storage Explorer
  2. After Storage Explorer  restarts, select the Edit menu, and then ensure that Target Azure Stack is selected. If it is not selected, select it, and then restart Storage Explorer for the change to take effect. This configuration is required for compatibility with your Azure Stack environment.
  3. To connect to the Azure Stack account, select Add an account.
  4. In the Connect to Azure Storage dialog box, under Azure environment, select Use Azure Stack Environment, and then click Next.
  5. To sign in with the Azure Stack account that’s associated with at least one active Azure Stack subscription, fill in the Sign in to Azure Stack Environment dialog box.
    The details for each field are as follows:Environment name: The field can be customized by user.
    ARM resource endpoint: The samples of Azure Resource Manager resource endpoints:For cloud operator:
    https://adminmanagement.-region-.-FQDN-
    For tenant:
    https://management.-region-.-FQDN-
    Tenant Id: Optional. The value is given only when the directory must be specified.

This should help you quickly setup an Azure Stack Cloud Operator Workstation. What other tools do you need to manage and operator your Azure Stack? leave a comment.