Tag: shell

Create Custom Script Extension for Windows - Azure Arc

How to Run Custom Scripts on Azure Arc Enabled Servers

With the latest update for Azure Arc for Servers, you are now able to deploy and use extensions with your Azure Arc enabled servers. With the Custom Script extension, you can run scripts on Azure Arc enabled servers and works similar to the custom script extension for Azure virtual machines (VMs). There is an extension for Windows and Linux servers, which is a tool that can be used to launch and execute machine customization tasks post configuration automatically.

When this Extension is added to an Azure Arc machine, it can download PowerShell and shell scripts and files from Azure storage and launch a script on the machine, which in turn can download additional software components. Custom Script Extension for Linux and Windows – Azure Arc tasks can also be automated using the Azure PowerShell cmdlets and Azure Cross-Platform Command-Line Interface (Azure CLI).

Introducing Azure Arc
For customers who want to simplify complex and distributed environments across on-premises, edge and multicloud, Azure Arc enables deployment of Azure services anywhere and extends Azure management to any infrastructure.
Learn more about Azure Arc here.

How to run Custom Scripts on Azure Arc enabled servers

To run a custom script on an Azure Arc enabled server, you can simply deploy the Custom Script Extension. You open the server you want to run the custom script in the Azure Arc server overview. Navigate to Extensions and click on Add, and select the Custom Script Extension for Windows – Azure Arc or on Linux the Custom Script Extension for Linux – Azure Arc.

Add Custom Script Extension

Add Custom Script Extension

Now you can select the PowerShell or shell script you want to run on that machine, as well as adding some optional arguments for that script.

Create Custom Script Extension for Windows - Azure Arc

Create Custom Script Extension for Windows – Azure Arc

After that, it will take a couple of minutes to run the script on the machine.

Conclusion

The Custom Script Extensions for Linux and Windows can be used to launch and execute machine customization tasks post configuration automatically.

You can learn more about how Azure Arc provides you with cloud-native management technologies for your hybrid cloud environment here, and you can find the documentation for Azure Arc enabled servers on Microsoft Docs.

If you have any questions or comments, feel free to leave a comment below.



Windows Terminal Color Schemes -Themes

My Windows Terminal Color Schemes

The Windows Terminal became generally available at the Microsoft Build 2020 virtual conference a couple of weeks ago. I already blogged about how you can customize your Windows Terminal settings and shared my settings.json file. Many people asked me about the different Windows Terminal Color Schemes I use. So I thought a blog post would be a good way of sharing my Windows Terminal Schemes.

Windows Terminal 1.0 was released on May 19, you can find more documentation here on Microsoft Docs.

I already shared a couple of blog posts on how you can customize your Windows Terminal experience:

My Windows Terminal Color Schemes

Here is my Windows Terminal Color Schemes. Since I use the acrylic effect, I post a picture when the Windows Terminal window is active and one where it is inactive.

Vibrant Tom

Vibrant Tom

Vibrant Tom

Vibrant Tom Inactive

Vibrant Tom Inactive

This one I use for my default shell (PowerShell 7).

{
            // Color Scheme: VibrantTom
            "background" : "#16171D",
            "black" : "#878787",
            "blue" : "#44B4CC",
            "brightBlack" : "#E373C8",
            "brightBlue" : "#0000FF",
            "brightCyan" : "#19D1D8",
            "brightGreen" : "#81EC0D",
            "brightPurple" : "#FF00FF",
            "brightRed" : "#FF0000",
            "brightWhite" : "#E5E5E5",
            "brightYellow" : "#FFD93D",
            "cyan" : "#19D1D8",
            "foreground" : "#FFFFFF",
            "green" : "#CCFF04",
            "name" : "VibrantTom",
            "purple" : "#9933CC",
            "red" : "#FF6600",
            "white" : "#F5F5F5",
            "yellow" : "#FFD93D"
        },

Windows PowerShell Tom

Windows PowerShell Tom

Windows PowerShell Tom

Windows PowerShell Tom Inactive

Windows PowerShell Tom Inactive

{
            // Color Scheme: PowerShellTom
            "background" : "#012456",
            "black" : "#000000",
            "blue" : "#0000ff",
            "brightBlack" : "#AAAAAA",
            "brightBlue" : "#44B4CC",
            "brightCyan" : "#19D1D8",
            "brightGreen" : "#81EC0D",
            "brightPurple" : "#FF00FF",
            "brightRed" : "#FF0000",
            "brightWhite" : "#E5E5E5",
            "brightYellow" : "#FFD93D",
            "cyan" : "#19D1D8",
            "foreground" : "#FFFFFF",
            "green" : "#00ff00",
            "name" : "PowerShellTom",
            "purple" : "#9933CC",
            "red" : "#FF6600",
            "white" : "#F5F5F5",
            "yellow" : "#FFD93D"
        },

Retro Command Prompt

Retro Command Prompt

Retro Command Prompt

Dracula

Dracula

Dracula

Dracula Inactive

Dracula Inactive

{
            // Color Scheme: Dracula
            "background" : "#282A36",
            "black" : "#21222C",
            "blue" : "#BD93F9",
            "brightBlack" : "#6272A4",
            "brightBlue" : "#D6ACFF",
            "brightCyan" : "#A4FFFF",
            "brightGreen" : "#69FF94",
            "brightPurple" : "#FF92DF",
            "brightRed" : "#FF6E6E",
            "brightWhite" : "#FFFFFF",
            "brightYellow" : "#FFFFA5",
            "cyan" : "#8BE9FD",
            "foreground" : "#F8F8F2",
            "green" : "#50FA7B",
            "name" : "Dracula",
            "purple" : "#FF79C6",
            "red" : "#FF5555",
            "white" : "#F8F8F2",
            "yellow" : "#F1FA8C"
        },

Ubuntu Legit

UbuntuLegit

UbuntuLegit

UbuntuLegit Inactive

UbuntuLegit Inactive

This one I saw first at Scott Hanselman’s blog. This one I use for my Windows Subsystem for Linux 2 (WSL 2) running Ubuntu.

{
            // Color Scheme: UbuntuLegit
            "background":  "#2C001E",
            "black":  "#4E9A06",
            "blue":  "#3465A4",
            "brightBlack":  "#555753",
            "brightBlue":  "#729FCF",
            "brightCyan":  "#34E2E2",
            "brightGreen":  "#8AE234",
            "brightPurple":  "#AD7FA8",
            "brightRed":  "#EF2929",
            "brightWhite":  "#EEEEEE",
            "brightYellow":  "#FCE94F",
            "cyan":  "#06989A",
            "foreground":  "#EEEEEE",
            "green":  "#300A24",
            "name":  "UbuntuLegit",
            "purple":  "#75507B",
            "red":  "#CC0000",
            "white":  "#D3D7CF",
            "yellow":  "#C4A000"
        },

Vibrant Tom Light

Vibrant Tom Light

Vibrant Tom Light

Vibrant Tom Light Inactive

Vibrant Tom Light Inactive

This one I am still working on. I am not 100 percent happy, so let me know if you have any ideas.

{
            // Color Scheme: VibrantInkTom Light
            "background" : "#EEEEEE",
            "black" : "#878787",
            "blue" : "#44B4CC",
            "brightBlack" : "#595e68",
            "brightBlue" : "#0000FF",
            "brightCyan" : "#19D1D8",
            "brightGreen" : "#3f953a",
            "brightPurple" : "#FF00FF",
            "brightRed" : "#FF0000",
            "brightWhite" : "#E5E5E5",
            "brightYellow" : "#FF6600",
            "cyan" : "#44B4CC",
            "foreground" : "#16171D",
            "green" : "#3f953a",
            "name" : "VibrantTomLight",
            "purple" : "#9933CC",
            "red" : "#FF6600",
            "white" : "#F5F5F5",
            "yellow" : "#FFD93D"
        },

Conclusion

I hope this blog post helps you to customize your Windows Terminal and I hope you like my Windows Terminal color schemes. Let me know in the comments which Windows Terminal Theme you like best.



How to Change the Windows Terminal Default Shell Profile

How to Change the Windows Terminal Default Shell Profile

The Windows Terminal is now generally available as version 1.0. I already shared a blog post on how to customize the Windows Terminal and shared my personal settings.json file with a lot of different examples, like the integration of PowerShell Remoting, SSH Remoting, changing the background image and much more. One question I got is, how to change the Windows Terminal default shell or default profile from PowerShell to the Windows Subsystem for Linux (WSL) or the command line (cmd).

By default, the Windows Terminal takes PowerShell 7 (if it is installed) as the primary shell when you open the Windows Terminal. However, if you want to change that you can simply configure the default shell in Windows Terminal, in the settings.json file. On the top, you can find the “defaultProfile” setting with a GUID

{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
....
}

The GUID is the GUID of your profile. For example, if you want to change it to cmd, you can use the following GUID “0caa0dad-35be-5f56-a8ff-afceeeaa6101”.

Windows Terminal Default Profile - Default Shell

Windows Terminal settings.json

I hope this blog post gives you a look on how to switch the default shell in Windows Terminal. I recommend that you check out my other blog post where I share even more details on how to customize the Windows Terminal. You can also read the full announcement blog for the version 1.0 here or check out the documentation on Microsoft Docs.

If you have any questions, feel free to leave a comment.



Windows Terminal Background Acrylic Opacity

How to Change the Windows Terminal Background Image

As you may know, Microsoft released a new Windows Terminal, which is currently in preview. However, it has some great new features, and a lot of people are currently trying it out. Now I got a lot of questions about how you can change the background of the Windows Terminal. So I decided to write a quick blog post about how you can configure and customize the Windows Terminal background image. There are multiple ways you can do this. And you can not only change the color or use a background image, but you can also change the opacity, and if it should use the acrylic Windows effect.

Customize the Windows Terminal Background Image

First open the settings of the Windows Terminal app, which will open a JSON file, where the settings are stored.

Windows Terminal Settings

Windows Terminal Settings

This will allow you to customize the settings and colors of the terminal. Every console has a so-called profile, which you can modify. Let’s start with adding a background image.

        {
            "acrylicOpacity" : 0.5,
            "closeOnExit" : true,
            "colorScheme" : "VibrantInk",
            "commandline" : "C:\\Program Files\\PowerShell\\6\\pwsh.exe",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 12,
            "guid" : "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
            "historySize" : 9001,
            "icon" : "ms-appx:///ProfileIcons/{574e775e-4f2a-5b96-ac1e-a2962a402336}.png",
            "name" : "PowerShell Core",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : "%USERPROFILE%",
            "useAcrylic" : true,
            "backgroundImage": "C:/Users/thoma/OneDrive/Pictures/Me/Thomas Maurer Logos 2016/WindowsTerminal/Black Cloud Robot.png",
            "tabTitle": "PowerShell Core "
        },

With the “backgroundImage” value, you can set a specific image as the background.

"backgroundImage": "C:/Users/thoma/OneDrive/Pictures/Me/Thomas Maurer Logos 2016/WindowsTerminal/Black Cloud Robot.png"

Opacity

You can use the “backgroundImageOpacity” to set the opacity of the for the background image, and this is super helpful when you have a full background image.

Windows Terminal Background Image Opacity

Windows Terminal Background Image Opacity

You can add the following value to configure the opacity.

"backgroundImageOpacity" : 0.2

Acrylic effect

You can also configure the Windows Terminal to use the Acrylic effect in Windows 10 for the background. This will combine the acrylic effect with the background image.

Windows Terminal Background Acrylic Opacity

Windows Terminal Background Acrylic Opacity

Just set the following value to the settings.

"useAcrylic" : true,
"acrylicOpacity" : 0.5

Here is a full config you can have a look at, with all the settings enabled.

Profile

Profile

Let me know if that helps you to set, change, and customize the background image of the Windows Terminal. You can find more tips on how to customize the Windows Terminal on my blog and you can read more about the new Windows Terminal on the official blog. And if you want to know more about how you can run Azure Cloud Shell in the terminal, check out my blog post. If you have questions, let me know in the comments.



Azure Cloud Shell

Microsoft Azure Cloud Shell

Today at the Microsoft Build Conference, Microsoft announced the Azure Cloud Shell. The Azure Cloud Shell is a browser-based shell experience to manage and develop Azure resources.

Azure Cloud Shell offers a browser-accessible, pre-configured shell experience for managing Azure resources without the overhead of installing, versioning, and maintaining a machine yourself. Today it gives you a variety of different tools directly from your web browser in the Azure Portal.

This gives Azure Administrators an easy admin environment to manage resources as well as third-party applications. In the background Microsoft runs thousands of isolated containers, ready for you to use. Microsoft takes care of keeping this container up to date, so you can focus on your administrator tasks. The usage is free, the only thing you will need to pay, are the storage cost for your container and the things you store on the Azure File Share.

Linux shell interpreter

  • Bash
  • sh

Azure tools

  • Azure CLI 2.0 and 1.0

Text editors

  • vim
  • nano
  • emacs

Source control

  • git

Build tools

  • make
  • maven
  • npm
  • pip

Containers

  • Docker
  • Kubectl
  • DC/OS CLI

Databases

  • MySQL client
  • PostgreSql client
  • sqlcmd Utility

Other

  • iPython Client

It also looks like PowerShell will be available later, hopefully it will arrive soon. Microsoft also announced Azure PowerShell 3.0. If you want to learn, check out my blog post: Mastering Azure with Cloud Shell



Bash on Windows 10

How to Install Linux Bash on Windows 10

With the Windows 10 Anniversary Update, which was released by Microsoft in Summer 2016, Microsoft included a Windows Subsystem for Linux in Windows 10. This allows you to enable Linux Bash on Windows 10. In this blog post I quickly want to show how you can enable the Windows Subsystem for Linux on Windows 10. This is great if you want to use some Linux tools on your Windows 10 machine. I use it for example to use SSH to connect to Linux Virtual Machines on Azure.

First you have the following requirements:

  • Windows 10 Anniversary Update – Windows 10 Build 14393 and higher
  • 64-bit versions of Windows 10
  • Internet Connection to download the Windows Subsystem for Linux in Windows
  • Active Developer Mode in Windows 10

First enable Developer Mode There are two option you can do this

Open the Settings App, go to Update & Security, go to For developers and enable Developer mode:

Windows 10 - Developer Mode

You can also use the following PowerShell command to enable Developer Mode:

 
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"

After this you can enable the Windows Subsystem for Linux as a Windows Feature in the Control Panel or PowerShell

Windows 10 - Windows Subsystem for Linux

Run the following PowerShell command to enable the Windows Subsystem for Linux:

Enable Windows Subsystem for Linux using PowerShell

 
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

After that you will need to restart your computer.

Now you can open up PowerShell or the command prompt and start using bash. (You can also start Bash directly from the Start Menu)

Bash on Windows 10

Hope this helps you to get started.

 



Cheatsheet: Using Diskpart on a Server Core installation #4

Using Diskpart on a Server Core installation. Disk Administration or Partition a disk.

Create a new partition and format a partition

SELECT DISK 0
CREATE PARTITION PRIMARY
ASSIGN LETTER=E
SELECT PARTITION 1
FORMAT FS=NTFS LABEL="New Volume" QUICK
EXIT

Commands you may then issue at the DISKPART prompt:

LIST Disk
LIST Partition
LIST Volume

SELECT Disk n
SELECT Volume n
SELECT Partition n

DETAIL Disk
DETAIL Partition
DETAIL volume

HELP
REM (remark/comment)
EXIT

Commands to Manage Basic Disks:

(set the current in-focus partition to be the system partition)

ASSIGN (allocate the next free drive letter)
ASSIGN LETTER=l (Choose a free letter)

CREATE PARTITION Primary Size=50000 (50 GB)
CREATE PARTITION Extended Size=25000
CREATE PARTITION logical Size=25000

DELETE Partition

EXTEND Size=10000

REMOVE letter=l (Remove drive letter l from the in-focus partition)
REMOVE /ALL (Remove ALL current drive letters and mount points)

Commands to Manage Dynamic Disks:

(set the current in-focus partition to be the system partition)

ASSIGN (allocate the next free drive letter)
ASSIGN LETTER=l (Choose a free letter)

ADD disk=n (Add a mirror to the in-focus SIMPLE volume on the specified disk.)

BREAK disk=n (Break the current in-focus mirror)

CREATE VOLUME Simple Size=n Disk=n
CREATE VOLUME Stripe Size=n Disk=n,n,...
CREATE VOLUME Raid Size=n Disk=n,n,...

DELETE DISK
DELETE PARTITION
DELETE VOLUME

EXTEND disk=n [Size=n]
IMPORT
ONLINE

REMOVE letter=l (Remove drive letter l from the in-focus volume)
REMOVE /ALL (Remove ALL current drive letters and mount points)
RETAIN

Commands to Convert Disks:

CONVERT mbr
CONVERT gpt
CONVERT dynamic
CONVERT basic

CLEAN ALL (remove all partition and volume info from the hard drive)
RESCAN