Category Archives: Scripting

Visual Studio Code: PowerShell Profile

1uqcgx

Intro

Microsoft has released a terrific open source, multi-platform code editor called Visual Studio Code. If you want to get started with VS Code, I would recommend watching the videos provided here and then watch this excellent video about replacing PowerShell ISE with Visual Studio Code by Mike Robbins.

What about the PowerShell profile?

While Visual Studio Code can use PowerShell as its terminal, it does not use any previously setup PowerShell profile. In order to create a VS Code PowerShell profile (or VSCPP for short), select the Terminal (make sure it says PowerShell Integrated in the drop down on the right) and type $profile.

VSCode1

In order to create this file, you can type PS>notepad $profile in the terminal. This will open notepad and let you create the file. You can add whatever settings you prefer to in PowerShell. Once you save the profile, hit F1 or Ctrl+Shift+P to bring up the Command Palette and type Reload Window.

VSCode2

When the reload completes, create a new PowerShell file in VS Code and you should see the Terminal switch to PowerShell Integrated and load your newly created VSCPP (this assumes you have installed the PowerShell extension into VS Code).

VSCode3

NOTE: The PowerShell version that is installed as an extension into VS Code, has its own version.

VSCode4

If you have modules, scripts, or functions that have a dependency on a certain version of PowerShell, you will have to change, comment, or remove the dependency in order to use them in Visual Studio Code.

Happy Scripting!
Alain

Advertisements

Top 50 PowerShell Blogs

I just received word from Feedspot that they chose to include WagtheReal in their Top 50 PowerShell Blogs on the web. I’m very humbled, and while PowerShell was not the main focus of my blog, I increasingly turn to it to manage Windows and Citrix environments. I think it’s one of the most important pieces of technology that a Windows and Citrix administrator should learn and I hope that my PowerShell focus posts will continue to be informative to my readers.

Thanks,
Alain

PowerShell: Friday Script Blitz 2

scripts-powershell-scripts-everywhere

Intro

In my current position I’m getting to do a lot of PowerShell scripting. Typically these are quick scripts for maintenance or finding information about our Citrix environment. I’m posting several here to share.

NOTE: These scripts were written against a XenApp 6.5 environment

check-deedrive.ps1

Iterates though all XenApp Servers in the farm and checks that the D: drive is formatted. I wrote this because we found some existing provisioned servers that had unformatted D: drives attached.

Get it from GitHub

count-usrprof.ps1

Iterates though user’s profile directories and counts number of files in specified sub directory. It produces a CSV report (if the file count is above a threshold you set in the script) and also counts the total number of profiles. Useful for confirming your profile management solution is working as expected.

Get it from GitHub

clean-crashdumps.ps1

Iterates though a list of servers and reports on crashdumps. EdgeSight and Windows can collect crashdumps and if you don’t clear them off, the accumulate. This script will generate a CSV report and delete the dumps if the -delete switch is included.

Get it from GitHub

Thanks for reading,
Alain