Tag: Scripting

Write PowerShell Code Online in a web browser using Visual Studio Codespaces

Write PowerShell Online using Visual Studio Codespaces

Last week the Visual Studio Services team announced a new service called Visual Studio Codespaces. Visual Studio Codespaces allows you to do cloud-hosted development for wherever you’re working. While the new services support many different programming and scripting languages, it also supports PowerShell. In this blog post, I am going to show you how you can write PowerShell code online in a web browser using Visual Studio Codespaces.

What is Visual Studio Codespaces

As mentioned, Visual Studio Codespaces (earlier known as Visual Studio Online) are cloud-hosted development environments, which are accessible from everywhere. I don’t want to go too deep into what Visual Studio Codespaces are since there are already great resources out there. However, I want to quickly give you an overview of the basics of Visual Studio Code spaces and how you can use them to write PowerShell code.

Visual Studio Codespaces gives you access to development machines, which can be cloud-hosted or self-hosted.

  • Cloud-hosted machines are machines running in the Microsoft Cloud, and you can take advantage of the power of that machine. In this case, you can use the web browser or Visual Studio Code to access that Codespace.
  • Self-hosted machines can be computers in your home, company, installed in the cloud using Azure VMs, or everywhere. Again, here you can use a remote machine using a web browser or VS Code to access that code space remotely.
Visual Studio Codespaces Overview

Visual Studio Codespaces Overview

This now allows you to have a powerful development environment that you can access and run from anywhere. I think that is pretty cool!

You can read more about the introduction of Visual Studio Codespaces here.



PowerShell ISE Mode in Visual Studio Code

How to use PowerShell ISE Mode in Visual Studio Code

If you are writing PowerShell code, you might have realized that there weren’t really improvements to the PowerShell Integrated Scripting Environment (PowerShell ISE) in the last couple of releases. With PowerShell becoming more popular on cross-platform systems, Visual Studio Code (VS Code) becomes the editor of choice. However, by default Visual Studio Code has a different behavior than the PowerShell ISE. To make it even easier, the latest PowerShell extension for Visual Studio Code, now includes PowerShell ISE Mode. PowerShell ISE Mode in Visual Studio Code, helps you to replicate and enable the settings from the following Microsoft Docs article: How to replicate the ISE experience in Visual Studio Code.

The ISE was first introduced with Windows PowerShell V2 and was re-designed with PowerShell V3. The ISE is supported in all supported versions of Windows PowerShell up to and including Windows PowerShell V5.1.

The PowerShell ISE is no longer in active feature development. As a shipping component of Windows, it continues to be officially supported for security and high-priority servicing fixes. We currently have no plans to remove the ISE from Windows.

There is no support for the ISE in PowerShell v6 and beyond.



Webinar PowerShell Scripting and Automation for Hyper-V

Recording: Scripting & Automation in Hyper-V without SCVMM now available

Last week I had the chance to do a Webinar together with Altaro about Scripting & Automation in Hyper-V without SCVMM. Now you can watch the recording from this online webinar.

System Center Virtual Machine Manager (SCVMM) provides some great automation benefits for those organizations that can afford the hefty price tag. However, if SCVMM isn’t a cost effective solution for your business, what are you to do? While VMM certainly makes automation much easier, you can achieve a good level of automation with PowerShell and the applicable PowerShell modules for Hyper-V, clustering, storage, and more.

Are you looking to get grips with automation and scripting?

Join Thomas Maurer, Microsoft Datacenter and Cloud Management MVP, who will use this webinar to show you how to achieve automation in your Hyper-V environments, even if you don’t have SCVMM.

Remember, any task you have to do more than once, should be automated. Bring some sanity to your virtual environment by adding some scripting and automation know-how to your toolbox.

 



Webinar PowerShell Scripting and Automation for Hyper-V

Webinar: Scripting & Automation in Hyper-V without SCVMM

There are some great Webinars coming up and I am proud to speak in one of them with Andrew Syrewicze (Altaro Software and Microsoft MVP) about PowerShell Scripting and Automation in Hyper-V.

System Center Virtual Machine Manager (SCVMM) provides some great automation benefits for those organizations that can afford the hefty price tag. However, if SCVMM isn’t a cost effective solution for your business, what are you to do? While VMM certainly makes automation much easier, you can achieve a good level of automation with PowerShell and the applicable PowerShell modules for Hyper-V, clustering, storage, and more.

Are you looking to get grips with automation and scripting?

Join Thomas Maurer, Microsoft Datacenter and Cloud Management MVP, who will use this webinar to show you how to achieve automation in your Hyper-V environments, even if you don’t have SCVMM.

Remember, any task you have to do more than once, should be automated. Bring some sanity to your virtual environment by adding some scripting and automation know-how to your toolbox.

We’re live on Thursday, 10th December 2015 at 10am EST / 4PM CET (30-45mins + live Q&A!)

Register for the webinar here

Free Webinar about Scripting & Automation in Hyper-V without SCVMM

 



Judge at the Nutanix Coding Challenge

Nutanix just announced the PowerShell Coding Challenge for your Nutanix environment. The challenge will be to build a script which solves a real world problem in these use cases: Provisioning/orchestration, reporting, data protection, disaster recovery and runbook automation.

Do you have what it takes to write the best script for a Nutanix environment? Find out by participating in the inaugural Total Recode challenge. This global contest gives you a platform for showcasing your best talent. May the most creative, badass coding guru win!

Want to get more familiar with the Nutanix product and test your script? Check out the Nutanix Prism APIs and our recently announced Community Edition software.

Nutanix Coding Challenge Prizes

You can win great prices:

  • Best Overall
    DJ1 Inspire 1 Drone (Valued up
    to $4000) or $4000 cash prize
  • Most Impactful
    Home Lab ($2,500 value)
    or $2,500 cash prize
  • Most Creative
    $2000 cash prize

And I am proud the be a judge in this contest with other great minds:

 

Nutanix Coding Challenge Judges

If you want to know more or join the challenge, check out the Nutantix Coding Challenge: Total Recode website.



Powershell Header

Powershell: if Statement basics

The if Statement is pretty important if you are creating PowerShell scripts. So I created this post to get some basic information here.

First, the syntax with a simple if:

if (condition) {do}

You can also use elseif and else:

if (condition) {do}
elseif (condition) {do}
else {do}

A simple if could look like this:


if ($varibale -eq "1") {
Write-Host "Yes variable is 1"
}

Comparison Operators:

  • Equal to: -eq
  • Less than: -lt
  • Greater than: -gt
  • Greater than or Eqaul to: -ge
  • Less than or equal to: -le
  • Not equal to: -ne

You can also check case-sensitive by adding a “c” to the operator. “-eq” would be “-ceq

Logical Operators:

  • Not -not
  • Not !
  • And -and
  • Or -or

So you can simply add multiple conditions:


if ($varibale -eq "1" -or $varibale -eq "2") {
Write-Host "Varibale is 1 or 2"
}