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

Agile Methodology in Project Management

0 154 0

In this video, you will gain an understanding of Agile and Scrum Master Certification terminologies and concepts to help you make better decisions in your Project Management capabilities. Whether you’re a developer looking to obtain an Agile or Scrum Master Certification, or you’re a Project Manager/Product Owner who is attempting to get your product or … Continue reading Agile Methodology in Project Management

JavaScript for C# Developers – September 24, 2014

0 487 3

Is JavaScript worth taking the time to learn if I’m a server-side .NET developer? How much of C# carries over to JavaScript? In this recorded video from Dan Wahlin’s webinar on September 24,2014, Dan answers these questions and more while also discussing similarities between the languages, key differences, and the future of JavaScript (ES6). If … Continue reading JavaScript for C# Developers – September 24, 2014

Detailed Forensic Investigation of Malware Infections – April 21, 2015

4 608 5

How does an investigator hunt down and identify unknown malware? In this recording of our IT Security training webinar on April 21, 2015, Security expert Mike Danseglio (CISSP / CEH) performed several malware investigations on infected computers and identify symptoms, find root cause, and follow the leads to determine what’s happening. He demonstrated his preferred … Continue reading Detailed Forensic Investigation of Malware Infections – April 21, 2015

Write a Comment

Share your thoughts...

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