So, what’s a PowerShell $Profile got to do with it?

Home > Blogs > PowerShell > So, what’s a PowerShell $Profile got to do with it?

So, what’s a PowerShell $Profile got to do with it?

Like This Blog 0 Jason Helmick
Added by August 25, 2011

So, students ask me about my PowerShell $profile that I use in class.  They want to know how I got the line numbering, and how I retrieve history commands and re-execute them so quickly

Screen shot 2011-08-25 at 10.55.12 AM

Well, among other things, I added a couple of functions to my $profile that help me out when I’m presenting.  First, for my prompt.  I didn’t invent the wheel on this, I actually took a look at the help file about_prompt and modified one the examples.

I wanted the prompt to stand out on the console display more, so I threw in the

$Host.UI.Write("Yellow",$Host.UI.RawUI.BackGroundColor,"[PS:$nextCommand]")

 

The cool part is using Get-History to help me out.  I wanted to use a fast-to-type alias that would retrieve and display a previous line number from the function above.  I wanted to be able to display it, invoke it, or just copy it to my clipboard so I can paste it into an email or something.  (I have the console edit and paste because multiple lines are a bitch to copy.)

So, I think the interesting part is using clip.exe to copy it to the clipboard.  Try it out and see what you think!


Knowledge is PowerShell,

Jason

Videos You May Like

A Simple Introduction to Cisco CML2

0 3638 0

Mark Jacob, Cisco Instructor, presents an introduction to Cisco Modeling Labs 2.0 or CML2.0, an upgrade to Cisco’s VIRL Personal Edition. Mark demonstrates Terminal Emulator access to console, as well as console access from within the CML2.0 product. Hello, I’m Mark Jacob, a Cisco Instructor and Network Instructor at Interface Technical Training. I’ve been using … Continue reading A Simple Introduction to Cisco CML2

Cable Testers and How to Use them in Network Environments

0 645 1

This content is from our CompTIA Network + Video Certification Training Course. Start training today! In this video, CompTIA Network + instructor Rick Trader demonstrates how to use cable testers in network environments. Let’s look at some tools that we can use to test our different cables in our environment. Cable Testers Properly Wired Connectivity … Continue reading Cable Testers and How to Use them in Network Environments

Difference Between $_ and $PSItem in Windows PowerShell

2 1854 4

In this video, I’m going to answer a very common question that I get when I’m teaching Windows PowerShell, and that’s, “What’s the difference between what’s called $_ and $PSItem?” Let me explain to you a little bit about what these two variables do. When we’re working with the PowerShell pipeline, and we want to … Continue reading Difference Between $_ and $PSItem in Windows PowerShell

Write a Comment

Share your thoughts...

Please fill out the comment form below to post a reply.