Code Monkey home page Code Monkey logo

bcdady / profilepal Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 82 KB

Now published and available from PowerShellGallery.com! The ProfilePal PowerShell Module contains functions that help create and edit PowerShell profiles, as well as some other functions which can easily be re-used across PowerShell profile scripts

Home Page: https://www.powershellgallery.com/packages/ProfilePal/

License: GNU General Public License v3.0

PowerShell 100.00%
powershell powershell-profile powershell-profile-script profile-script profile profile-customization

profilepal's Introduction

ProfilePal

Official Website

ProfilePal is a free PowerShell module, made by Bryan Dady, to help set IT Pros up for early success with learning, mastering, and accelerating PowerShell.

ProfilePal module provides helpful functions for creating and customizing PowerShell profiles, and includes a couple 'bonus' functions for making PowerShell a bit easier to work with; intended to help new(er) PowerShell users more quickly discover the value of managing and customizing their own PowerShell Profile.

There are a few extra goodies thrown in, mostly thanks to the generous PowerShell profile tips previously provided by Fabrice ZERROUKI

Profile Script Functions

Get-Profile

Returns profile name, script path, and status (whether it's script file exists or not), for all, or for a specified PowerShell profile.

New-Profile

Creates a new PowerShell profile script, which customizes the console, and includes functions and tips to get more familiar about managing one's own profile customization and preferences.

This is the one that does the heavy lifting

If not specified via parameter, New-Profile will create the CurrentUserCurrentHost profile. The newly created profile will include calls to functions defined within the ProfilePal module, such as Set-WindowTitle, and prompt.

Alias

Initialize-Profile

Edit-Profile

Opens a specified PowerShell profile in the PowerShell_ISE, for editing Edit-Profile will attempt to open any existing PowerShell Profile scripts, and if none are found, will offer to invoke the New-Profile cmdlet to build one.

Edit-Profile, Get-Profile, and New-Profile can open any of the 4 default contexts of PowerShell profile scripts. For more information on profiles, run get-help about_Profiles

Suspend-Profile

Suspends an active PowerShell profile by renaming (appending) the profile script filename. This can be helpful with testing or troubleshooting changes or potential conflicts between profiles. To reload a PowerShell session without the suspended profile, exit and restart the pertinent PowerShell host.

Resume-Profile

Resumes an suspended PowerShell profile, to be active in the next PowerShell session, by restoring a profile script file renamed by Suspend-Profile.

Reset-Profile

Simply reloads the current profile script (. $Profile), but 'reload' is not an approved PowerShell verb, so we call it Reset.

Get-UserName

Returns active user's account name in the format of DOMAIN\AccountName

Alias

whoami

PowerShell Host Customization Functions

prompt

Overrides the default prompt, removing the pwd/path element, and conditionally adds an [ADMIN] indicator, in place of the default Administrator string in the window title bar. Customizing prompt is explained in detail in the PowerShell help file about_Prompts (try get-help about_Prompts)

Since I find I rarely need to know my current path, I write the starting path and date / time to the Window Title, and then simplify the prompt to reflect the current directory:PS .\>

When the PowerShell console is started with Administrative permissions (see also Open-AdminConsole), this function inserts an [ADMIN] indicator, to replace the default 'Administrator:' text which would otherwise be added to the Window Title: PS [ADMIN] .\>

Get-WindowTitle

Stores the PowerShell host window title, in support of Set-WindowTitle and Reset-WindowTitle functions

Set-WindowTitle

Customizes PowerShell host window title, to show PowerShell version, starting path, and start date/time. With the path in the title, we can leave it out of the prompt; customized in prompt function within this module.

Reset-WindowTitle

Restores default PowerShell host window title, as captured by Get-WindowTitle

Bonus Functions

Start-RemoteDesktop

Launch a Windows Remote Desktop admin session to a specified computername, with either FullScreen, or sized window. Whenever I work in an environment that doesn't (yet) have PSRemoting enabled, I like to have Remote Desktop ready to run, with some handy presets. I often add an alias to this function, named rdp, in my own profile

Test-Port

Effectively a PowerShell-native alternative / replacement for telnet, to test IP port(s) of a remote computer. This comes in handy when working in an environment that disabled the Windows telnet client, in favor of security.

Alias: telnet

Test-LocalAdmin

Test if the current host process is running with elevated, local admin, permissions; returns simple Boolean result.

Open-AdminConsole

Launch a new console window, with Admin permissions, thanks to the RunAs verb. This is commonly done by right-clicking the PowerShell icon, but this function makes it easy to achieve the same from the command line. There is a -NoProfile parameter, so that the Administrative console / host can be started in a clean / 'default' mode.

Aliases: New-AdminConsole, New-AdminHost, Open-AdminHost, Start-AdminConsole, Start-AdminHost, sudo

profilepal's People

Contributors

bcdady avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

profilepal's Issues

Add cross-host profile editing support

Currently, ProfilePal can edit any of the four type of Console host profiles when invoked from console, and it can edit any ISE profile if/when invoked from ISE. Currently there is now way to open/edit an ISE profile script from Console, or to edit a Console profile script, from the functions in this module, in ISE.

Edit-Profile requires Edit-Module module

The Edit-Profile function relies on the Get-PSEdit, Assert-PSEdit, and Open-PSEdit functions which are provided by the Edit-Module module. These components should be merged into this module; via ModuleList ("packaged with this module").

file format issue with .psd1 manifest

In preliminary testing, cloning this repository to a new laptop / Github for windows, resulted in mangled file content, which prevented PowerShell from interpreting the manifest and importing the module

New-Profile fails if/when WindowsPowerShell directory doesn't exist

It appears that the New-Profile function fails to create lower level directories, in order to place a new profile script file in the designated directory.

Example:
[ADMIN] PS .> New-Profile -ProfileName CurrentUserAllHosts
new-item : Could not find a part of the path 'C:\Users\bryan\Documents\WindowsPowerShell\profile.ps1'.
At C:\Program Files\WindowsPowerShell\Modules\ProfilePal\1.0.0\ProfilePal.psm1:421 char:28

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.