Posts Tagged ‘Functions’


Setting Conditional Breakpoints

Wednesday, April 20th, 2016 by June Blender
Applies to PowerShell Studio 2016, PrimalScript 2016, and later. I write lots of scripts — for production, for research, for testing, and for demonstrations. And, inevitably, I hit a bug. I'm actually relieved when I do, because no code is perfect and I'd rather find the bugs before my users do. In fact, I make sure the content in my test database is full of oddities so it's as close to the real world as possible. When you are debugging with a large test sample, like a database or directory, the default line breakpoints are not sufficient. I can hit…   More »

What’s new in PrimalScript 2015?

Thursday, March 19th, 2015 by Alex Riedel
Our 2015 versions have been out for a while and most of you already know about some of the new features. But we want to make sure you don’t miss anything, so here is a brief recap. PrimalScript 2015 now has a PowerShell dialog editor If you create graphical user interfaces (GUI) in PowerShell all the time, you probably already have SAPIEN PowerShell Studio. But if you just want to create a dialog here or there to prompt for some user input or display a particular piece of data as output, you do not need to create full-fledged event driven…   More »

Adding Parameter Sets to a Function

Thursday, October 2nd, 2014 by June Blender
Like many of you, I really live at the command line, because automation is more efficient than single actions. But, as the command line becomes more complex, we need tools to restore our efficiency. The complex syntax of parameter sets in functions is one of those cases. In this post, I learn to use the new Function Editor in PowerShell Studio 2014. I’m not just playing in a GUI. I’ve automated the command line. ------ When I write functions, I often start with the basic command – the one that makes the function work – and then build in features.…   More »

PowerShell Studio 2014: Convert Functions into a Module

Wednesday, July 9th, 2014 by David Corrales
PowerShell Studio 2014 added a new project feature: New Module From Functions. You may find at times you reuse various functions and constantly copy them into new scripts or find different variations of the same function are located in different scripts. You may come to the conclusion that those functions would better serve you in the form of a module where all your scripts can reference the functions in a centralized location. This is where the New Module From Functions feature comes in handy. The New Module From Functions allows you to import functions from various ps1 scripts and merge…   More »

Revisiting The Packager and Command Line Arguments

Thursday, October 25th, 2012 by David Corrales
The original The Packager and Command line Arguments blog article discussed how to pass parameters to a packaged executable. In this article we will revisit this subject and update the functions introduced in the previous article. The article will also cover how to simulate the packager parameters so that you can test your script without having to package it each time. This article’s example uses PowerShell Studio 2012, but it is also applicable to PrimalScript 2012. Command Line Parsing Functions: The original Convert-ArgumentsToDictionary function is no longer valid since PowerShell converts the Dictionary to an array when you return the…   More »

PrimalScript 2012: What’s new? (Part 7)

Wednesday, May 9th, 2012 by Alex Riedel
Last time we told you about some new debugger features in PrimalScript 2012. And you already know all about the new Ribbon user interface this new version sports. One thing that we were really focused about in this version was to make navigating your code easier. Since there is no “PrimalSense” toolbar anymore the method combo box that enabled you to jump between functions needed to find a new home. If you load a file into PrimalScript 2012 you will notice the two new combo boxes on top of the edit window: The right-hand combo box serves as an indicator…   More »

PowerShell Functions: Return vs Write

Tuesday, June 2nd, 2009 by Jeffery Hicks
The other day I was involved in a short Twitter debate about the relative merits of using RETURN vs Write-Object (or its alias Write) in PowerShell functions. Here's my take.   More »

VBScript Includes

Thursday, May 28th, 2009 by Jeffery Hicks
I've been using VBScript for a very long time. One drawback it has always had as a scripting language is an INCLUDE statement. In other languages you can use something like INCLUDE scriptfile at the beginning of the script. This would load any functions and variables in the specified script file into your current script. In PowerShell we can accomplish this by dot sourcing scripts. I never knew of a way to do the same thing with VBScript until now.   More »

Good, Better, Best

Thursday, May 21st, 2009 by Jeffery Hicks
I'm very happy to see more and more people getting their hands dirty with Windows PowerShell. A common challenge I see across different support forums is getting information from one part of a script to another. Very often the user has created a function and is attempting to use its output elsewhere in their script. Often I can tell the scripter is coming from a VBScript background or at least thinking that way. There's nothing necessarily wrong with writing a PowerShell script in a VBScript style, but these scripts are missing out. Let me walk you through several iterations of a function to demonstrate.   More »

Can I Get a Little Help Here?

Tuesday, May 19th, 2009 by Jeffery Hicks
One of my favorite features in PowerShell v2.0 is the ability to add help scripts and functions. The help system with cmdlets is terrific. Type help and the name of a cmdlet and you get syntax, parameters, a description and examples. In PowerShell v2 you can get this same functionality for your scripts and functions. The example I want to show you will work with PowerShell v2.0 that ships with WIndows 7 Release Candidate. There have been some changes since PowerShell CTP3 so if you want the absolute latest PowerShell bits you'll need Windows 7. Here's what you can look forward to.   More »