项目作者: infamousjoeg

项目描述 :
Common PowerShell functions that I use compiled into a PowerShell Module
高级语言: PowerShell
项目地址: git://github.com/infamousjoeg/CommonCommands.git
创建时间: 2017-08-07T15:23:01Z
项目社区:https://github.com/infamousjoeg/CommonCommands

开源协议:MIT License

下载


CommonCommands

license

Common commands used regularly by me. Compiled into a PowerShell Module.

Latest Update

  • Added Load-XAMLForm to allow XAML to be used for a PowerShell GUI
  • Split functions to seperate .ps1 files
  • Simplified CommonCommands.psm1
  • Updated README (duh!)

Included Functions

  • Send-EmailNotification
    • Sends an HTML e-mail w/ CC, priority, and file attachment capabilities
  • Get-CSVColumn
    • Gets all values of a specific column in a CSV file to an array
  • Set-Log
    • Sets the path to the log file to be written to
  • Write-Log
    • Writes a [DEBUG], [INFO], or [ERROR] message to the log file set
  • Set-Breakpoint
    • Just pauses script until any button is pressed
  • Load-XAMLForm
    • Requires xaml.xml file in the script’s working directory generated from Visual Studio - WPF Application - Visual C#

Future Update Functions

  • Open-FileDialog
    • Displays Windows “Open File” dialog for file selection
  • Save-FileDialog
    • Displays Windows “Save File” dialog for file save location selection

Pre-Requisites

  • PowerShell v3 or higher

Usage

Clone this repository into one of the directories listed as your PSMODULEPATH environment variable.

Run a PowerShell console and do the following:

  1. $modulePath = @(($env:PSMODULEPATH.Split(";")))
  2. Write-Host $modulePath[0]

The value of $modulePath is one of your recognized PowerShell Module directories.

  1. cd $modulePath[0]
  2. git clone https://github.com/infamousjoeg/CommonCommands.git

That will download all the files into a “CommonCommands” directory in the proper location.

  1. Import-Module CommonCommands
  2. Get-Command -Module CommonCommands

Load-XAMLForm

The function Load-XAMLForm was created based on information derived from this blog post on mcpmag.com.

The function expects a xaml.xml file to be located in the script’s working directory that contains the XAML created from Visual Studio.

The function will load in that XAML and parse it to work within PowerShell. It will then load up all elements from the XAML form code as variables to be worked with in the current PowerShell script.

The function will display the window and return the form variables in an array.

$Form.ShowDialog() | Out-Null