-
Notifications
You must be signed in to change notification settings - Fork 0
Help
#ProfilePal Module - Help Content
###New-Profile
SYNOPSIS
Create a new PowerShell profile script
SYNTAX
New-Profile [[-ProfileName] <String[]>] [<CommonParameters>]
DESCRIPTION
The PowerShell profile script can be created in any 1 of the 4 default contexts, and if not specified, defaults to the most common CurrentUserCurrentHost. If this function is called from within PowerShell ISE, the CurrentHost profiles will be created with the requisite PowerShellISE_profile prefix. In order to create new AllUsers profile scripts, this function must be called with elevated (admin) privileges.
PARAMETERS
-ProfileName <String[]>
Accepts 'CurrentUserCurrentHost', 'CurrentUserAllHosts', 'AllUsersCurrentHost' or 'AllUsersAllHosts'
-------------------------- EXAMPLE 1 --------------------------
PS .\>New-Profile
Creates a new starter profile script for the context Current User / Current [PowerShell] Host
Starter profile CurrentUserCurrentHost has been created. To review and/or modify (in the PowerShell ISE), try the
Edit-Profile function.
For example, run: Edit-Profile -profileName CurrentUserCurrentHost
Directory: C:\Users\[username]\Documents\WindowsPowerShell
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 4/27/2015 10:54 AM 2381 Microsoft.PowerShell_profile.ps1
-------------------------- EXAMPLE 2 --------------------------
PS .\>New-Profile -profileName CurrentUserAllHosts
Creates a new starter profile script for the context Current User / Current [PowerShell] Host
Starter profile CurrentUserAllHosts has been created. To review and/or modify (in the PowerShell ISE), try the
Edit-Profile function.
For example, run: Edit-Profile -profileName CurrentUserAllHosts
Directory: C:\Users\[username]\Documents\WindowsPowerShell
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 4/27/2015 10:57 AM 2378 profile.ps1
###Open-AdminConsole
SYNOPSIS
Launch a new console window from the command line, with optional -NoProfile support
SYNTAX
Open-AdminConsole [-noprofile] [<CommonParameters>]
DESCRIPTION
Simplifies opening a PowerShell console host, with Administrative permissions, by enabling the same result from the keyboard, instead of having to grab the mouse to Right-Click and select 'Run as Administrator'. The following aliases are also provided:
Open-AdminHost
Start-AdminConsole
Start-AdminHost
New-AdminConsole
New-AdminHost
Request-AdminConsole
Request-AdminHost
sudo
PARAMETERS
-noprofile [<SwitchParameter>]
###Edit-Profile
SYNOPSIS
Open a PowerShell Profile script in the ISE editor
SYNTAX
Edit-Profile [[-profileName] <String[]>] [<CommonParameters>]
DESCRIPTION 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. Both New-Profile and Edit-Profile can open any of the 4 contexts of PowerShell Profile scripts.
PARAMETERS
-profileName <String[]>
Accepts 'CurrentUserCurrentHost', 'CurrentUserAllHosts', 'AllUsersCurrentHost' or 'AllUsersAllHosts'
-------------------------- EXAMPLE 1 --------------------------
PS .\>Edit-Profile
Opens the default $profile script file, if it exists
-------------------------- EXAMPLE 2 --------------------------
PS .\>Edit-Profile CurrentUserAllHosts
Opens the specified CurrentUserAllHosts $profile script file, which applies to both Console and ISE hosts, for the current
user
###Get-Profile
SYNOPSIS
Returns corresponding PowerShell profile name, path, and status (whether it's script file exists or not)
SYNTAX
Get-Profile [[-Name] <String>] [<CommonParameters>]
DESCRIPTION
Can be passed a parameter for a profile by Name or Path, and returns a summary object
PARAMETERS
-Name <String>
Accepts 'AllProfiles', 'CurrentUserCurrentHost', 'CurrentUserAllHosts', 'AllUsersCurrentHost' or 'AllUsersAllHosts'
-------------------------- EXAMPLE 1 --------------------------
PS .\>Get-Profile
Name Path Exists
----------- ----------- --------------
CurrentUserCurrentHost C:\Users\BDady\Documents\WindowsPowerSh... True
-------------------------- EXAMPLE 2 --------------------------
PS .\>Get-Profile -Name AllUsersCurrentHost | Format-Table -AutoSize
Name Path Exists
----------- ----------- --------------
AllUsersCurrentHost C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1 False
###Get-UserName
SYNOPSIS
Get-UserName returns user's account info in the format of DOMAIN\AccountName
SYNTAX
Get-UserName [<CommonParameters>]
DESCRIPTION
[System.Security.Principal.WindowsIdentity]::GetCurrent().Name;
-------------------------- EXAMPLE 1 --------------------------
PS C:\>Get-UserName;
Returns DomainName\UserName
-------------------------- EXAMPLE 2 --------------------------
PS C:\>whoami
Linux friendly alias invokes Get-UserName
###Get-WindowTitle
SYNOPSIS
Stores the default PowerShell host window title
SYNTAX
Get-WindowTitle [<CommonParameters>]
DESCRIPTION
Read current window title into a variable. Supports Set-WindowTitle and Reset-WindowTitle functions.
###prompt
SYNOPSIS
From about_Prompts:
The Windows PowerShell prompt is determined by the built-in Prompt function. You can customize the prompt by creating your own Prompt function and saving it in your Windows PowerShell profile.
SYNTAX
prompt [<CommonParameters>]
DESCRIPTION From about_Prompts:
The Prompt function determines the appearance of the Windows PowerShell prompt. Windows PowerShell comes with a built-in Prompt function, but you can override it by defining your own Prompt function.
The Prompt function has the following syntax:
function Prompt { function-body}
###Reset-Profile
SYNOPSIS
Reload the profile (`$PROFILE), by using dot-source invokation
SYNTAX
Reset-Profile [<CommonParameters>]
DESCRIPTION
Essentially an alias for PS .\>. $Profile
###Reset-WindowTitle
SYNOPSIS
Restores default PowerShell host window title, as captured by Get-WindowTitle
SYNTAX
Reset-WindowTitle [<CommonParameters>]
DESCRIPTION
Provided to make it easy to reset the default window frame title, but presumes that Get-WindowTitle was previously run.
###Set-WindowTitle
SYNOPSIS
Customizes Host window title, to show version start date/time, and starting path.
SYNTAX
Set-WindowTitle [<CommonParameters>]
DESCRIPTION
For use in customizing PowerShell Hostlook and feel, in conjunction with a customized prompt function. With the path in the title, we can leave it out of the prompt; customized in another function within this module
###Start-RemoteDesktop
SYNOPSIS
Launch a Windows Remote Desktop admin session to a specified computername, with either FullScreen, or sized window
SYNTAX
Start-RemoteDesktop [-ComputerName] <ValidateNotNullOrEmptyAttribute> -Control [-FullScreen] [-ScreenSize <String[]>] []
DESCRIPTION
Start-RemoteDesktop calls the mstsc.exe process installed on the local instance of Windows. By default, Start-RemoteDesktop specifies the optional arguments of /admin, and /fullscreen. Start-RemoteDesktop also provides a -ScreenSize parameter, which supports optional window resolution specifications of 1440 x 1050, 1280 x 1024, and 1024 x 768.
I first made this because I was tired of my last mstsc session hanging on to my last resolution (which would change between when I was docked at my desk, or working from the smaller laptop screen); so this could always 'force' /fullscreen.
PARAMETERS
-ComputerName <ValidateNotNullOrEmptyAttribute>
Specifies the DNS name or IP address of the computer / server to connect to.
-Control [<SwitchParameter>]
Optionall specifies if the remote session should function in Admin, RestrictedAdmin, or Control mode [default in this
function].
-FullScreen [<SwitchParameter>]
Unambiguously specifies that the RDP window open to full screen size.
-ScreenSize <String[]>
Specifies the window resolution. If not specified, defaults to Full Screen.
-------------------------- EXAMPLE 1 --------------------------
PS C:\>Start-RemoteDesktop remotehost
Invokes mstsc.exe /v:remotehost /control
-------------------------- EXAMPLE 2 --------------------------
PS C:\>Start-RemoteDesktop -ComputerName <IP Address> -ScreenSize 1280x1024 -Control RestrictedAdmin
Invokes mstsc.exe /v:<IP Address> /RestrictedAdmin /w:1280 /h:1024
###Test-AdminPerms
SYNOPSIS
Test if you have Admin Permissions; returns simple boolean result
SYNTAX
Test-AdminPerms [<CommonParameters>]
DESCRIPTION
([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
[Security.Principal.WindowsBuiltInRole] 'Administrator')
###Test-Port
SYNOPSIS
Test-Port is effectively a PowerShell replacement for telnet, to support testing of a specified IP port of a remote computer
SYNTAX
Test-Port [-Target] <String[]> [-Port] <Int32> [-Timeout <Int32>] [<CommonParameters>]
DESCRIPTION
Test-Port enables testing for any answer or open indication from a remote network port.
PARAMETERS
-Target <String[]>
DNS name or IP address of a remote computer or network device to test response from.
-Port <Int32>
IP port number to test on the TARGET.
-Timeout <Int32>
Time-to-live (TTL) parameter for how long to wait for a response from the TARGET PORT.
-------------------------- EXAMPLE 1 --------------------------
PS C:\>Test-Port RemoteHost 9997
Tests if the remote host is open on the default Splunk port.