From 4e0cb8cae96ee53f8f330f6dfc3fcb0576426b84 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Mon, 21 Oct 2019 20:18:43 -0500 Subject: [PATCH] Documentation for the helper command functions. --- PS/PowerShellProfile.ps1 | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/PS/PowerShellProfile.ps1 b/PS/PowerShellProfile.ps1 index 9bf8a64..7548376 100644 --- a/PS/PowerShellProfile.ps1 +++ b/PS/PowerShellProfile.ps1 @@ -9,6 +9,10 @@ function prompt { "PS> " } +<# + .Synopsis + Invoke a scriptblock with evelvated permissions. +#> function Invoke-Elevated { param ( [ScriptBlock] @@ -18,14 +22,31 @@ function Invoke-Elevated { Start-Process powershell.exe -ArgumentList $code -WindowStyle hidden -Verb RunAs } -# helper command to get whether we are running under elevated privileges or not. +<# + .Synopsis + Returns true if you are running with elevated privileges. +#> function Get-Elevated { ([Security.Principal.WindowsPrincipal] ` [Security.Principal.WindowsIdentity]::GetCurrent() ` ).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) } -# Helper command to make symbolic links. +<# + .Synopsis + Create a symlink from a source to a destination. + + .Description + Creates a symlink from a $Source to a $Destination. + Automatically elevates to administrator privileges + if necessary. + + .Parameter Source + Required source to create the symlink from. + + .Parameter Destination + Required destination to create the symlink at. +#> function New-Link { param ( [Parameter(Position=0, Mandatory=$true)]