Connecting to Azure via local PowerShell [Windows 10]

So to make life more interesting we will try to manage our Azure resources via PowerShell, running on our local workstation with Windows 10 Pro.

Before going to the details, its nice ot have updated help, which is done by typing:

To connect to Azure, there are some basics steps, before typing

There are some modulels that need to be installed and in order to do so, the appropriate policy should be set on your local instance:

After that, some modules must be installed

Wait some time, after which you could import the modules:

After that, connecting to Azure is as simple as typing:

Then you will be prompted to enter your Azure credentials on a form like this:

And in the end you should get something looking like this displayed on your PowerShell CLI:

You can also test by typing:

Which will dislplay all resouces, available within the current env.

Active directory interview questions, part 2 of 2

  • How does group policy resolve setting conflicts?
  1. Following the GPO’s processing order. More particular – the GPO containing the conflicting policy setting that applies last is the setting that overwrites all other settings.
  • Give three examples of where PowerShell pipeline should be used, rather than set as variable
  1. This is an intriguing question also in the Linux/bash environment.
  2. Allows data to be sent from one command to the second, without the need of variable definition
  3. Allows for easier ongoing refining of the function/script results
  4. Streaming/ piping values allow working with “infinite” length of continuous data, while its rather impossible to define such a variable
  • How do you establish a remote PowerShell session?  What are the pre-requisites?
  1. [If working within Domain] Enable PowerShell Remoting/ Enable-PSRemoting -Force
    1. Starts the WinRM service
    2. Starts automatically with system start
    3. Creates a firewall rule for incoming connection
  2. [If working within Workgroup]
    1. Configure the network as private
    2. Configure TrustedHosts on both machines.
  3. To execute a single remote cmdlet: Invoke-Command
  4. To initiate a remote session: Enter-PSSession


Establish remote PowerShell session

Imagine, you are working on perfectly good workstations, enjoying your GUI and you get a task to perform some maintenance on Windows Server, that has the “User interfaces and infrastructure” feature removed.

One way is to utilize PowerShell, the task automation, and configuration management framework developed by Microsoft about 10 years ago.

So to initialize remote PowerShell session, it takes:

  1. On the targeted server/ computer type:
    1. Enable-PSRemoting -Force //will change the needed configuration settings
    2. Or you can set a GPO, as shown here.
  2. On your machine enter:
    1. $cred = Get-Credential // get your domain credentials
    2. $rhost=”olp-dc2″ // setting the value for remote host
    3. Enter-PSSession -ComputerName -Credential $cred // fill out the computer name and the name of the user you want to use
    4. hostname // to check if you are running PowerShell in the host
    5. Get-PSSession //
    6. Enter-PSSessionComputerName -Credentials $cred // to switch to another PowerShell session
    7. Exit-PSSession // will kill the PowerShell session, as well as typing just exit
    8. Get-PSsession $computer-name // will show you the ongoing sesions
    9. Or just type exit to leave the session.

And as visable, powershell wont let you forget which session you are working in right now :).

You can see the on which the session is running in the begining of each row,
The result of Get-PSSession for the server in use.
overview of remote PowerShell

Aditional examples, can be found here and here.

Installing PowerShell on RHEL/Fedora/CentOS based systems

Even that it may sound unusual, there are occasions when you would prefer to install PowerShell on Linux systems. For example – like me, you have access to several Linux system for practicing and no windows server/ workstations. Thanks to Microsoft’s “love for Linux”, during Satya Nadella’s reign, it’s quite easy.


  1. Add the PowerShell repository:
    1. curl > /etc/yum.repos.d/microsoft.repo
  2. Update the repo
  3. Install PowerShell
    1. yum install powershell
  4. Launch PowerShell:
    1. powershell
  5. Enjoy 🙂