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 171 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

An Overview of Office 365 – Administration Portal and Admin Center

0 912 3

This is part 1 of our 5-part Office 365 free training course. In this Office 365 training video, instructor Spike Xavier introduces some of the most popular services found in Microsoft Office 365 including the Admin Portal and Admin Center. For instructor-led Office 365 training classes, see our course schedule: Spike Xavier SharePoint Instructor – … Continue reading An Overview of Office 365 – Administration Portal and Admin Center

Windows 10 Managing, Deploying and Configuring – December 2, 2015

0 452 1

In this recorded Windows 10 training webinar from December 2, 2015, Windows Server instructor Rick Trader presents the deployment and management of Windows 10 Enterprise and the new Provisioning capability in Windows 10. Learn how to manage Windows 10 deployments using System Center Configuration Manager, Mobile Device Management and Intune. Also included in his presentation … Continue reading Windows 10 Managing, Deploying and Configuring – December 2, 2015

Write a Comment

Share your thoughts...

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