#StupidProfileTrick – FunctionList

As I previously posted, my $Profile is stupidly complicated, and it adds a ton of functions.  Which ones did I add? (Reason this is of interest to me is because I mistakenly named a function with the same name as a cmdlet.  Yeah, totally stupid move on my part.  More on that later.) #region start…

0

Prompts

What does your function:\prompt look like?  Here’s mine: function prompt { if ($Host.IsAdministrator -eq $null) { $CurrentUser = [Security.Principal.WindowsIdentity]::GetCurrent(); $CurrentUserPrincipal = New-Object Security.Principal.WindowsPrincipal $CurrentUser; $AdminRole = [Security.Principal.WindowsBuiltinRole]::Administrator; Add-Member -InputObject $global:Host -Name IsAdministrator -MemberType NoteProperty -Value ( [bool](($CurrentUserPrincipal).IsInRole($AdminRole)) ); } # if ($Host.IsAdministrator -eq $null) # setting the titlebar $host.UI.RawUI.WindowTitle = ” $( $path = Get-Location;…

0

Rehash: Playing with Window Size

http://blogs.msdn.com/b/timid/archive/2011/06/23/playing-with-window-size.aspx gave the core magic for messing with the console window size.  Since then, I’ve seen functions that allow the user to set it to arbitrary values, but I found myself wanting to grow and shrink the window size by some specified delta, e.g. +10 columns, when generating the ‘test pattern’ from yesterdays’ post.  Why…

0

Capturing the Console Buffer

Vladimir Averkin’s http://blogs.msdn.com/b/powershell/archive/2009/01/11/colorized-capture-of-console-screen-in-html-and-rtf.aspx provides the code.  Here’s the core magic. $Host.UI.RawUI.GetBufferContents(System.Management.Automation.Host.Rectangle) will return a two-dimensional character array of the contents of the buffer. This entry cleans up the HTML function by creating XML instead of using System.Text.StringBuilder to append strings.  Sadly, I don’t know RTF at all, so this is merely a merging of that…

0