PowerShell – Azure Cloud Shell for PowerShell and Bash

November 3, 2017

Microsoft recently released a new feature called Azure Cloud Shell (for PowerShell and Bash).

To get started you need to log into the Azure Portal.

1. Click this icon

image

2. Choose Bash or PowerShell

image

3. Subscribe

This wil create an Azure File Storage to store your scripts

image

File Storage

Azure Files offers fully managed file shares in the cloud that are accessible via the industry standard Server Message Block (SMB) protocol.

Azure File shares can be mounted concurrently by cloud or on-premises deployments of Windows, macOS, and Linux.

Azure Files enable sharing files between applications running in your virtual machines using familiar Windows APIs or File REST API. Additionally,

Azure File Sync allows caching and synchronization of Azure Files shares on Windows Servers for local access.

image

Once created you can access all Azure resource using PowerShell or Bash resources.

And the scripts will be available online using your PC or even on a Mobile device !


image


Read more here : https://docs.microsoft.com/en-us/azure/cloud-shell/overview

Or watch this movie https://www.youtube.com/watch?v=RhnZ4lJgEnU&MC=SysMagSof&MC=MSAzure

Enjoy!

Advertisements

PowerShell – Accessing DotNet Assemblies

June 28, 2014

As you all know Powershell is built on top on the .Net Framework. Which contains a lot of classes that we could benefit from if we could access them in our scripting environment.

Well we can using the Assembly Reflection method.

There are different ways of accessing .NET Assemblies depending on the version of PS

PS Version 1

[Reflection.Assembly]::Load Loads an assembly
[Reflection.Assembly]::LoadFile Loads the contents of an assembly file on the specified path
[Reflection.Assembly]::LoadFrom Loads an assembly given its file name or path
[Reflection.Assembly]::LoadWithPartialName Loads an assembly from the application directory or from the global assembly cache using a partial name

Example :

[Reflection.Assembly]::LoadFile( `
  'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll')`
  | out-null            

[System.Web.HttpUtility]::UrlEncode("this is a test")

</br>PS Version 2

Using the Add-Type Cmdlet

Add-Type -AssemblyName System.Web
[System.Web.HttpUtility]::UrlEncode("this is a test")

These 2 examples use the URLEncode method in the HttpUtility Class.

Question is now which Classes are available (Public) to PS.

Well you can use this code to access Assembly Information.

[appdomain]::currentdomain.GetAssemblies() | % {$_.gettypes()}
| sort basetype | Out-GridView

And filter it in you the GRID

image

Now filter for Public Classes

image

Great playing field for Scripters !