One thing that has annoyed me for a long time, si the fact that there was no obvious / easy way to connect to the console session of a VM, so you have to open the Hyper-V manager, click on your VM and click on ‘connect’. That’s just too much clicking…

function enter-vmsession{
  [cmdletbinding()]
  param($vmhost=$env:computername,$vmname)
  vmconnect.exe $vmhost $vmname
}

I found that Hyper-V manager is using the ‘vmconnect.exe’ to connect to the console session, and I wrote this little function that will kind of act like ‘enter-pssession’ just instead of connection to a session it actually launches the vm console. Saved me alot of time. :o)


I am not sure how you launch PowerShell, but I found for me the fastest and easiest way is the new option at is ‘baked’ into Windows 10.

I am sure you are familiar with pressing ‘WIN+X’ or right-clicking on the start button?

This thing:

menuoldWell there is now a way to replace the Command Prompt with PowerShell in a few clicks:

Right-click on the TaskBar -> Properties (or Settings,if you have the Anniversary Update installed)

poshmenu

And that’s it , now you have PowerShell as an option. ‘Win+X’ and then ‘A’ will give you an administrative PowerShell window :o)

menunew


By now, I’m sure everyone has heard of Nano server, it is the next big or rather small thing form Microsoft. If you just started you looking into Nano server, the process is quite confusing, as it is well not a standalone server, but more like a self build mini server version.

Here my script how to build one from scratch, super easy.

# Prerequisites:
# Download the latest server 2016 ISO
# Copy the $drive\'NanoServer' folder to a local resource

# Set the location of the localrsource and point to the NanoServerImageGenerator folder
Set-Location 'D:\NanoServer\NanoServerImageGenerator'
# Import the NanoServerImageGenerator module
Import-Module .\NanoServerImageGenerator.psd1 -Verbose
# Define the local machine password for the NanoServer
$nano_admin_password = ConvertTo-SecureString -AsPlainText -Force -String 'Pa$$word#123'
# Define the server's name
$nano_servername = ("nano" + "_" + (Get-Date).month + (Get-Date).day)
# Create the server vhd with the following settings
New-NanoServerImage -MediaPath D:\ -BasePath .\Base -TargetPath ".\$($nano_servername).vhd" `
                    -DeploymentType Guest -Edition Datacenter -Storage -Defender `
                    -EnableRemoteManagementPort -ComputerName $nano_servername `
                    -AdministratorPassword $nano_admin_password
# Create a new VM on Hyper-V and load the just created Nano VHD
New-VM -Name $nano_servername  -VHDPath ".\$($nano_servername).vhd" -MemoryStartupBytes 1024MB
# Start the Nano VM
Start-VM -Name $nano_servername

 

 


I am starting to work more with VS Code, especially since it is so easy now to write PowerShell code on my MacBook Pro, without having to switch to a Windows VM or remote into a Windows machine.

Yet there a few kinks, they are however easy to fix.

  1. Install Powershell on the macOS
So easy! Go to: [https://github.com/PowerShell/PowerShell/releases/

](https://github.com/PowerShell/PowerShell/releases/) Download the latest PowerShell package for macOS

(It’s the one ending with .pkg)
  
Allow the package to be run:
  
System Preferences -> Security & Privacy -> Allow Apps downloaded from
  
Follow the prompt
  
Done.   2. Installing the Powershell Extension
  
Press ‘Shift+CMD+P’ to open the Command Palett
  
Type ‘Install Extensions’, select it and press enter
  
Type in PowerShell, there is currently only a single extension from Microsoft for PowerShell, so that’s the one you should pick.
  
Click on Install/Enable, restart VS Code, done.   3. PowerShell Intellisense issues
  
It seems to be common issue if there is no OpenSSL installed
  
Have a read [here](https://github.com/PowerShell/vscode-powershell/blob/master/docs/troubleshooting.md#1-powershell-intellisense-does-not-work-cant-debug-scripts) how to fix it.   4. Another issue is PowerShell remoting. Since Windows is using win RM, macOS or Linux know nothing about that. You have to use SSH, specifically OpenSSH. You have to install that on your windows machine which is right now a little bit tricky ([step by step here](https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH)) but eventually they are going to build a cmdlet or something to automate that for you.

Well, going forward, with the movement of PowerShell being Opensource, it seems the ISE is no longer going to be the ‘main’ PowerShell development platform, but Visual Studio Code, which is a free, open source, multi-platform (Windows, Linux, macOS) code editor from Microsoft.

Late last year  it was announced that VS Code would get Powershell support, which is pretty awesome as you can not develop and administer PowerShell task from your Linux or Mac machine. The only drawback to it is, PowerShell is limited to PowerShell Core. On the bright site, that is super as Nano server is using PowerShell core as well.