Visual Studio Code (VSCode) and PowerShell

This is my setup for using VSCode with powershell as a replacement for Windows PowerShell ISE.

1. Install VSCode, get the latest version from: VSCode Download
2. Add PowerShell Addin
– Press CTRL+SHIFT+X
– Type PowerShell
– Click the green install button
– When installed, click the blue Reload button
– A few modifications needs to be done in the editor USER settings, press CTRL+,
Add these lines if you like to the right hand side

    "editor.rulers": [ 120 ],
    "editor.renderWhitespace": "all",
    "editor.renderControlCharacters": true,
    "editor.lineNumbers": "on",
    "editor.fontSize": 14,
    "editor.wordWrap": "on",
    "omnisharp.projectLoadTimeout": 120,
    "csharp.suppressDotnetRestoreNotification": true,
    "files.trimTrailingWhitespace": true,
    "files.defaultLanguage": "powershell",
    "terminal.integrated.shell.windows":
    "C:\\WINDOWS\\sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"

So it looks a bit like this:

3. Save, by pressing CTRL+S
4. Restart VSCode and the settings should kick in, with Powershell being the default language.

As it is with Windows PowerShell and Windows PowerShell ISE, VSCode can also have a profile.
find the path in the terminal by typing $profile and press ENTER, if your PC is following the standard, the profile is most likely to be found in:
C:\Users\[USERNAME]\Documents\WindowsPowerShell\ and should be named Microsoft.VSCode_profile.ps1
So if you have some functions that should be loaded upon start of VSCode, then please update the file or create it and add what you need in there.

I hope you find it usefull.
Clicketyclick

Email this to someoneShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPin on Pinterest

Setting up a Powershell Remote admin desktop

In this post i will go through how i normally setup my PC when it is freshly installed.

  1. Install Remote Server Administration Tools (RSAT)
  2. Enable features needed on your PC in order to do remote adminstration
  3. Install Quest/Dell Powershell Commands for Active Directory (ActiveRoles)
  4. Install other 3rd part tools for PowerShell e.g. VM-PowerCli. it all comes down to what you need.
  5. Powershell Execution policy
  6. Import (enable) the needed cmdlets (activedirectory, quest etc. etc.)

1. Install Remote Server Administration Tools (RSAT)
Remember to download the version suited for your OS (32/64bit)
When Downloaded, open the downloaded file and install.
If you plan to install frequently, i recommend making a silent install, which can be archived by doing this command:
wusa.exe "Insert MSU filename e.g.:Windows6.2-KB2693643-x64.msu" /quiet /norestart

2. Enable features needed on your PC in order to do remote adminstration
Features can be added via Programs and features Gui or as i prefer via a cmd line.
As i often end up in (re-)installing a PC, this task is as easy as running a cmd file. The cmd file includes the following lines, whic i need. You might not need all of these, so feel free to remove those things you don’t need.

EnableFeatures.cmd (should be run in elevated mode)
dism /online /enable-feature /featurename:RemoteServerAdministrationTools
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Roles
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Roles-AD
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Roles-AD-DS
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Roles-AD-DS-SnapIns
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Roles-AD-DS-NIS
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Roles-AD-LDS
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Roles-AD-Powershell
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Roles-AD-DS-AdministrativeCenter
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Roles-DHCP
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Roles-DNS
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Roles-RDS
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Features
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Features-GP
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Roles-FileServices
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Roles-FileServices-Dfs
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Roles-FileServices-Fsrm
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Roles-FileServices-StorageMgmt
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-ServerManager
dism /online /enable-feature /featurename:RemoteServerAdministrationTools-Features-BitLocker
pause

Should you need to see what features that are available on your system, then run this from a elevated cmd prompt: dism /online /get-features

I will skip Step 3 and 4 in this case, as it is pretty straight forward, download what you need, click and install.

5. PowerShell Execution policy
You need to figure out what limits you want on your system when it comes to executing PowerShell scripts.
TechNet have an article for execution policy for PowerShell 1.0 here.
And an article for execution policy for PowerShell 4.0 here.
For my own use i normally set the execution policy to Unrestricted, but have in mind that i don’t just download a script from the internet and fire it off without checking what it will do to my systems first.

Set-ExecutionPolicy -ExecutionPolicy 'Unrestricted'

6. Import (enable) the needed cmdlets (activedirectory, quest etc. etc.)
First you need to figure out what modules you have on your system, from a PowerShell prompt run this command.

Get-Module -ListAvailable

If you find that you have the needed modules on the list, then you can import them by using:

Import-Module 'ModuleName'

As the Quest ActiveDirectory Tool is a Snapin, it is imported a bit differently.

Add-PSSnapin 'SnapinName'

When these steps have been completed, you should be ready to go.

Happy Scripting 🙂

Email this to someoneShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPin on Pinterest

PowerShell ISE on steroids

As many other PowerShellers i recieve a frequent newsletter from PowerShellMagazine.com the newsletter is bits and pieces from the PowerShell comunity. here the other day when i got the mail there was a link to an article about “ISESteroids – A Revolutionary PowerShell ISE Add-On” which instantly caught my eye and attention.

ISESteroids is a plugin for PowerShell ISE made by PowerShell MVP Tobias Weltner. The plugin gives you a lot of extra features to your PowerShell ISE, unfortunately there is a cost related to the plugin, which might scare of potential users. You can get a trial version here.

Read more about the plugin on either powershell.com or the article i read and liked better on powershellmagazine.com.

Enjoy scripting

Email this to someoneShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPin on Pinterest

Hello World

First published post

$a="Hello World"
$a
Hello World
Email this to someoneShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPin on Pinterest