diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bdb0cab --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96374c4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# ========================= +# Operating System Files +# ========================= + +# OSX +# ========================= + +.DS_Store +.AppleDouble +.LSOverride + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk diff --git a/Changelog.md b/Changelog.md new file mode 100644 index 0000000..33f54d2 --- /dev/null +++ b/Changelog.md @@ -0,0 +1,47 @@ +# ChangeLog for ISEScriptingGeek Module + +## v3.4.2 + ++ Updated license ++ Updated manifest to PowerShell 5.1 and supporting Desktop edition + +## v3.4.1 + ++ Replaced `Out-Null` references to using `[void]` ++ Cleaned up incorrect exported aliases ++ Code clean up and reformatting + +## v3.4.0 + ++ code cleanup as some commands have moved to the PSScriptTools module. ++ Moved help to external files (Issue #11) ++ Renamed `changelog.txt` to `changelog.md` ++ module restructuring ++ Updated `README.md` + +## v3.3.0.0 + ++ Added New-FileHere command ++ Fixed Open-SelectedISE to trim spaces from selected text and write a warning if file not found. ++ Added ChangeLog.txt file. ++ Added #requires -module PSDesiredStateConfiguration to New-DSCResourceSnippet.ps1 ++ Switched to MIT license + +## v3.3.1.0 + ++ Fixed a bug with New-CommentHelp to accept no parameters ++ Updated New-CommentHelp to ignore new Information related common parameters in v5 + +## v3.3.1.1 + ++ Updated New-FileHere function + +## v3.3.1.2 + ++ Published to PowerShell Gallery with a v5 manifest. + +## v3.3.1.3 + ++ updated module manifest ++ Updated script signing to support multiple certificates ++ Updated author name in manifest diff --git a/ISEScriptingGeek.psd1 b/ISEScriptingGeek.psd1 new file mode 100644 index 0000000..2b4c4d2 --- /dev/null +++ b/ISEScriptingGeek.psd1 @@ -0,0 +1,139 @@ + +@{ + +# Script module or binary module file associated with this manifest. +RootModule = 'ISEScriptingGeek.psm1' + +# Version number of this module. +ModuleVersion = '3.4.2' + +# Supported PSEditions +CompatiblePSEditions = @('Desktop') + +# ID used to uniquely identify this module +GUID = '6d1078ea-36c8-443a-9476-6d6c4d6ac834' + +# Author of this module +Author = 'Jeff Hicks' + +# Company or vendor of this module +CompanyName = 'JDH Information Technology Solutions, Inc.' + +# Copyright statement for this module +Copyright = '2013-2020 JDH Information Technology Solutions, Inc. All Rights Reserved.' + +# Description of the functionality provided by this module +Description = 'Functions and add-ons for the Windows PowerShell ISE v4.0 and later' + +# Minimum version of the Windows PowerShell engine required by this module +PowerShellVersion = '5.1' + +# Name of the Windows PowerShell host required by this module +# PowerShellHostName = '' + +# Minimum version of the Windows PowerShell host required by this module +# PowerShellHostVersion = '' + +# Minimum version of Microsoft .NET Framework required by this module +# DotNetFrameworkVersion = '' + +# Minimum version of the common language runtime (CLR) required by this module +CLRVersion = '4.0' + +# Processor architecture (None, X86, Amd64) required by this module +ProcessorArchitecture = 'None' + +# Modules that must be imported into the global environment prior to importing this module +# RequiredModules = @() + +# Assemblies that must be loaded prior to importing this module +RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() + +# Functions to export from this module +FunctionsToExport = 'Add-CurrentProject', 'Add-ISEBookmark', 'CloseAllFiles', + 'CloseAllFilesButCurrent', 'Convert-AliasDefinition', + 'Convert-CodetoSnippet', 'Convert-CommandtoHash', 'ConvertFrom-Alias', + 'ConvertFrom-MultiLineComment', 'ConvertTo-CommentHelp', + 'ConvertTo-Definition', 'ConvertTo-MultiLineComment', + 'ConvertTo-TextFile', 'Copy-ToWord', 'Edit-CurrentProject', + 'Edit-Snippet', 'Find-InFile', 'Get-ASTProfile', 'Get-CommandMetadata', + 'Get-ISEBookmark', 'Get-NextISETab', 'Get-ScriptComments', + 'Get-ScriptingHelp', 'Get-SearchResult', 'Import-CurrentProject', + 'New-CIMCommand', 'New-CommentHelp', 'New-DSCResourceSnippet', + 'New-FileHere', 'New-Inputbox', 'New-PSCommand', + 'Open-ISEBookmark', 'Open-SelectedISE', 'Out-ISETab', + 'Remove-ISEBookmark', 'Reset-ISEFile', 'Send-ToPrinter', + 'Start-MyScript', 'Update-ISEBookmark', 'Write-Signature', + 'New-Function','Set-ScriptLocation' + +# Cmdlets to export from this module +CmdletsToExport = @() + +# Variables to export from this module +VariablesToExport = 'MySnippets', 'MyModules', 'MyPowerShell', 'CurrentProjectList' + +# Aliases to export from this module +AliasesToExport = 'ccs','gcmd','glcm''tab','sd' + +# DSC resources to export from this module +# DscResourcesToExport = @() + +# List of all modules packaged with this module +# ModuleList = @() + +# List of all files packaged with this module +#FileList = '' + +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ + + #Category of this module + Category = 'PowerShell ISE' + + #IsPrerelease of this module + IsPrerelease = 'False' + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + Tags = 'ISE','Snippets','Scripting' + + # A URL to the license for this module. + LicenseUri = 'https://github.com/jdhitsolutions/ISEScriptingGeek/blob/master/License.txt' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/jdhitsolutions/ISEScriptingGeek' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + # External dependent modules of this module + # ExternalModuleDependencies = '' + + } # End of PSData hashtable + +} # End of PrivateData hashtable + +# HelpInfo URI of this module +# HelpInfoURI = '' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' + +} + diff --git a/ISEScriptingGeek.psm1 b/ISEScriptingGeek.psm1 new file mode 100644 index 0000000..ff75e35 Binary files /dev/null and b/ISEScriptingGeek.psm1 differ diff --git a/License.txt b/License.txt new file mode 100644 index 0000000..6bb8e93 --- /dev/null +++ b/License.txt @@ -0,0 +1,27 @@ +MIT License + +Copyright (c) 2015-2022 JDH Information Technology Solutions, Inc. + + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..c012c26 --- /dev/null +++ b/README.md @@ -0,0 +1,68 @@ +# ISEScriptingGeek Module + +[![PSGallery Version](https://img.shields.io/powershellgallery/v/ISEScriptingGeek.png?style=for-the-badge&logo=powershell&label=PowerShell%20Gallery)](https://www.powershellgallery.com/packages/ISEScriptingGeek/) [![PSGallery Downloads](https://img.shields.io/powershellgallery/dt/ISEScriptingGeek.png?style=for-the-badge&label=Downloads)](https://www.powershellgallery.com/packages/ISEScriptingGeek/) + +This module is a set of ISE add-ons and a few themes. It requires PowerShell5.1 or higher. + +_As of February 2019 I no longer intend to update or extend this module. VS Code is clearly Microsoft's choice for a scripting tool going forward. The PowerShell ISE isn't going away any time soon, but it is also no longer under active development so I need no point in continuing to develop this module. I will maintain it and address pull requests should members of the community wish to contribute, maintain or extend this module._ + +Install the module from the PowerShell Gallery. + +```powershell +Install-Module ISEScriptingGeek +``` + +Then in your PowerShell_ISE profile script, import the module. + +```powershell +Import-Module ISEScriptingGeek +``` + +This will add the menu short cuts. + +## Themes + +The themes can be found and imported from the Themes sub-folder of the module. +These are optional and are not connected to the add-ons. + +## Add-ons + +Once the module is imported, the add-ons will be listed under **ISE Scripting Geek** on the **Add-ons** menu in the ISE. +A number of the add-ons fall into grouped sub-folders: + +![add-ons menu](images/addons-menu.png) + +### Bookmarks + +A set of functions for creating and working with "bookmarks" to files opened in the ISE. + +### Convert + +These handle various conversions such as: + +- selected text to snippet, region +- case conversion +- alias expansion + +### Dates and times + +A set of functions for inserting date/time in different formats + +### Files + +A set of functions for working with open files and their associated folders + +### Work + +A set of functions for creating and managing a "work list" of files + +### Miscellaneous + +There are also other scripts directly off the **ISE Scripting Geek** menu, these functions provide various capabilities: + +- Print, Run or Sign script +- Send script to Word (with or without color) +- Send selected text to different search engines +- Help functions +- New CIM Command, DSC Resource snippets, etc. + diff --git a/Themes/Grayscale.StorableColorTheme.ps1xml b/Themes/Grayscale.StorableColorTheme.ps1xml new file mode 100644 index 0000000..2f32559 --- /dev/null +++ b/Themes/Grayscale.StorableColorTheme.ps1xml @@ -0,0 +1,813 @@ + + + + ErrorForegroundColor + ErrorBackgroundColor + WarningForegroundColor + WarningBackgroundColor + VerboseForegroundColor + VerboseBackgroundColor + DebugForegroundColor + DebugBackgroundColor + ConsolePaneBackgroundColor + ConsolePaneTextBackgroundColor + ConsolePaneForegroundColor + ScriptPaneBackgroundColor + ScriptPaneForegroundColor + TokenColors\Attribute + TokenColors\Command + TokenColors\CommandArgument + TokenColors\CommandParameter + TokenColors\Comment + TokenColors\GroupEnd + TokenColors\GroupStart + TokenColors\Keyword + TokenColors\LineContinuation + TokenColors\LoopLabel + TokenColors\Member + TokenColors\NewLine + TokenColors\Number + TokenColors\Operator + TokenColors\Position + TokenColors\StatementSeparator + TokenColors\String + TokenColors\Type + TokenColors\Unknown + TokenColors\Variable + ConsoleTokenColors\Attribute + ConsoleTokenColors\Command + ConsoleTokenColors\CommandArgument + ConsoleTokenColors\CommandParameter + ConsoleTokenColors\Comment + ConsoleTokenColors\GroupEnd + ConsoleTokenColors\GroupStart + ConsoleTokenColors\Keyword + ConsoleTokenColors\LineContinuation + ConsoleTokenColors\LoopLabel + ConsoleTokenColors\Member + ConsoleTokenColors\NewLine + ConsoleTokenColors\Number + ConsoleTokenColors\Operator + ConsoleTokenColors\Position + ConsoleTokenColors\StatementSeparator + ConsoleTokenColors\String + ConsoleTokenColors\Type + ConsoleTokenColors\Unknown + ConsoleTokenColors\Variable + XmlTokenColors\CharacterData + XmlTokenColors\QuotedString + XmlTokenColors\Comment + XmlTokenColors\CommentDelimiter + XmlTokenColors\15 + XmlTokenColors\13 + XmlTokenColors\12 + XmlTokenColors\14 + XmlTokenColors\18 + XmlTokenColors\MarkupExtension + XmlTokenColors\Quote + XmlTokenColors\17 + XmlTokenColors\ElementName + XmlTokenColors\11 + XmlTokenColors\19 + XmlTokenColors\16 + XmlTokenColors\Attribute + XmlTokenColors\10 + XmlTokenColors\Tag + XmlTokenColors\Text + + + + 255 + 255 + 0 + 0 + 1 + 1 + 0 + 0 + + + 0 + 255 + 255 + 255 + 0 + 1 + 1 + 1 + + + 255 + 255 + 140 + 0 + 1 + 1 + 0.2622507 + 0 + + + 0 + 255 + 255 + 255 + 0 + 1 + 1 + 1 + + + 255 + 229 + 0 + 229 + 1 + 0.7835378 + 0 + 0.7835378 + + + 0 + 255 + 255 + 255 + 0 + 1 + 1 + 1 + + + 255 + 0 + 102 + 102 + 1 + 0 + 0.13286832 + 0.13286832 + + + 0 + 255 + 255 + 255 + 0 + 1 + 1 + 1 + + + 255 + 212 + 212 + 212 + 1 + 0.658374846 + 0.658374846 + 0.658374846 + + + 0 + 255 + 255 + 255 + 0 + 1 + 1 + 1 + + + 255 + 42 + 42 + 42 + 1 + 0.0231533684 + 0.0231533684 + 0.0231533684 + + + 255 + 212 + 212 + 212 + 1 + 0.658374846 + 0.658374846 + 0.658374846 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 191 + 255 + 1 + 0 + 0.5209956 + 1 + + + 255 + 0 + 0 + 255 + 1 + 0 + 0 + 1 + + + 255 + 138 + 43 + 226 + 1 + 0.254152119 + 0.024157634 + 0.7605245 + + + 255 + 0 + 0 + 128 + 1 + 0 + 0 + 0.215860531 + + + 255 + 0 + 100 + 0 + 1 + 0 + 0.127437681 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 139 + 1 + 0 + 0 + 0.258182883 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 139 + 1 + 0 + 0 + 0.258182883 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 128 + 0 + 128 + 1 + 0.215860531 + 0 + 0.215860531 + + + 255 + 169 + 169 + 169 + 1 + 0.396755248 + 0.396755248 + 0.396755248 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 139 + 0 + 0 + 1 + 0.258182883 + 0 + 0 + + + 255 + 0 + 128 + 128 + 1 + 0 + 0.215860531 + 0.215860531 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 255 + 69 + 0 + 1 + 1 + 0.0595112443 + 0 + + + 255 + 0 + 102 + 102 + 1 + 0 + 0.13286832 + 0.13286832 + + + 255 + 42 + 42 + 42 + 1 + 0.0231533684 + 0.0231533684 + 0.0231533684 + + + 255 + 85 + 85 + 85 + 1 + 0.09084172 + 0.09084172 + 0.09084172 + + + 255 + 127 + 127 + 127 + 1 + 0.212230757 + 0.212230757 + 0.212230757 + + + 255 + 0 + 127 + 0 + 1 + 0 + 0.212230757 + 0 + + + 255 + 0 + 0 + 178 + 1 + 0 + 0 + 0.445201218 + + + 255 + 0 + 0 + 178 + 1 + 0 + 0 + 0.445201218 + + + 255 + 0 + 0 + 207 + 1 + 0 + 0 + 0.623960435 + + + 255 + 0 + 178 + 0 + 1 + 0 + 0.445201218 + 0 + + + 255 + 127 + 127 + 127 + 1 + 0.212230757 + 0.212230757 + 0.212230757 + + + 255 + 127 + 127 + 127 + 1 + 0.212230757 + 0.212230757 + 0.212230757 + + + 255 + 245 + 245 + 245 + 1 + 0.913098633 + 0.913098633 + 0.913098633 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 42 + 42 + 42 + 1 + 0.0231533684 + 0.0231533684 + 0.0231533684 + + + 255 + 245 + 245 + 245 + 1 + 0.913098633 + 0.913098633 + 0.913098633 + + + 255 + 42 + 42 + 42 + 1 + 0.0231533684 + 0.0231533684 + 0.0231533684 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 127 + 1 + 0 + 0 + 0.212230757 + + + 255 + 245 + 245 + 245 + 1 + 0.913098633 + 0.913098633 + 0.913098633 + + + 255 + 127 + 127 + 127 + 1 + 0.212230757 + 0.212230757 + 0.212230757 + + + 255 + 128 + 128 + 128 + 1 + 0.215860531 + 0.215860531 + 0.215860531 + + + 255 + 0 + 0 + 139 + 1 + 0 + 0 + 0.258182883 + + + 255 + 0 + 100 + 0 + 1 + 0 + 0.127437681 + 0 + + + 255 + 0 + 128 + 0 + 1 + 0 + 0.215860531 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 255 + 140 + 0 + 1 + 1 + 0.2622507 + 0 + + + 255 + 0 + 0 + 255 + 1 + 0 + 0 + 1 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 139 + 0 + 0 + 1 + 0.258182883 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 255 + 0 + 0 + 1 + 1 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 139 + 1 + 0 + 0 + 0.258182883 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + Grayscale + Consolas + 12 + \ No newline at end of file diff --git a/Themes/Monochrome Yellow.StorableColorTheme.ps1xml b/Themes/Monochrome Yellow.StorableColorTheme.ps1xml new file mode 100644 index 0000000..bfc293e --- /dev/null +++ b/Themes/Monochrome Yellow.StorableColorTheme.ps1xml @@ -0,0 +1,813 @@ + + + + ErrorForegroundColor + ErrorBackgroundColor + WarningForegroundColor + WarningBackgroundColor + VerboseForegroundColor + VerboseBackgroundColor + DebugForegroundColor + DebugBackgroundColor + ConsolePaneBackgroundColor + ConsolePaneTextBackgroundColor + ConsolePaneForegroundColor + ScriptPaneBackgroundColor + ScriptPaneForegroundColor + TokenColors\Attribute + TokenColors\Command + TokenColors\CommandArgument + TokenColors\CommandParameter + TokenColors\Comment + TokenColors\GroupEnd + TokenColors\GroupStart + TokenColors\Keyword + TokenColors\LineContinuation + TokenColors\LoopLabel + TokenColors\Member + TokenColors\NewLine + TokenColors\Number + TokenColors\Operator + TokenColors\Position + TokenColors\StatementSeparator + TokenColors\String + TokenColors\Type + TokenColors\Unknown + TokenColors\Variable + ConsoleTokenColors\Attribute + ConsoleTokenColors\Command + ConsoleTokenColors\CommandArgument + ConsoleTokenColors\CommandParameter + ConsoleTokenColors\Comment + ConsoleTokenColors\GroupEnd + ConsoleTokenColors\GroupStart + ConsoleTokenColors\Keyword + ConsoleTokenColors\LineContinuation + ConsoleTokenColors\LoopLabel + ConsoleTokenColors\Member + ConsoleTokenColors\NewLine + ConsoleTokenColors\Number + ConsoleTokenColors\Operator + ConsoleTokenColors\Position + ConsoleTokenColors\StatementSeparator + ConsoleTokenColors\String + ConsoleTokenColors\Type + ConsoleTokenColors\Unknown + ConsoleTokenColors\Variable + XmlTokenColors\CharacterData + XmlTokenColors\QuotedString + XmlTokenColors\Comment + XmlTokenColors\CommentDelimiter + XmlTokenColors\15 + XmlTokenColors\13 + XmlTokenColors\12 + XmlTokenColors\14 + XmlTokenColors\18 + XmlTokenColors\MarkupExtension + XmlTokenColors\Quote + XmlTokenColors\17 + XmlTokenColors\ElementName + XmlTokenColors\11 + XmlTokenColors\19 + XmlTokenColors\16 + XmlTokenColors\Attribute + XmlTokenColors\10 + XmlTokenColors\Tag + XmlTokenColors\Text + + + + 255 + 255 + 0 + 0 + 1 + 1 + 0 + 0 + + + 0 + 255 + 255 + 255 + 0 + 1 + 1 + 1 + + + 255 + 255 + 140 + 0 + 1 + 1 + 0.2622507 + 0 + + + 0 + 255 + 255 + 255 + 0 + 1 + 1 + 1 + + + 255 + 218 + 165 + 32 + 1 + 0.7011019 + 0.376262158 + 0.0144438446 + + + 0 + 255 + 255 + 255 + 0 + 1 + 1 + 1 + + + 255 + 184 + 134 + 11 + 1 + 0.4793202 + 0.2383976 + 0.00334653584 + + + 0 + 255 + 255 + 255 + 0 + 1 + 1 + 1 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 255 + 255 + 0 + 1 + 1 + 1 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 255 + 255 + 0 + 1 + 1 + 1 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 184 + 134 + 11 + 1 + 0.4793202 + 0.2383976 + 0.00334653584 + + + 255 + 184 + 134 + 11 + 1 + 0.4793202 + 0.2383976 + 0.00334653584 + + + 255 + 255 + 255 + 0 + 1 + 1 + 1 + 0 + + + 255 + 218 + 165 + 32 + 1 + 0.7011019 + 0.376262158 + 0.0144438446 + + + 255 + 218 + 165 + 32 + 1 + 0.7011019 + 0.376262158 + 0.0144438446 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 0 + 191 + 0 + 1 + 0 + 0.5209956 + 0 + + + 255 + 255 + 255 + 224 + 1 + 1 + 1 + 0.745404243 + + + 255 + 218 + 165 + 32 + 1 + 0.7011019 + 0.376262158 + 0.0144438446 + + + 255 + 0 + 159 + 0 + 1 + 0 + 0.3467041 + 0 + + + 255 + 255 + 255 + 0 + 1 + 1 + 1 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 0 + 191 + 0 + 1 + 0 + 0.5209956 + 0 + + + 255 + 218 + 165 + 32 + 1 + 0.7011019 + 0.376262158 + 0.0144438446 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 184 + 134 + 11 + 1 + 0.4793202 + 0.2383976 + 0.00334653584 + + + 255 + 184 + 134 + 11 + 1 + 0.4793202 + 0.2383976 + 0.00334653584 + + + 255 + 255 + 255 + 0 + 1 + 1 + 1 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 0 + 159 + 0 + 1 + 0 + 0.3467041 + 0 + + + 255 + 255 + 255 + 224 + 1 + 1 + 1 + 0.745404243 + + + 255 + 218 + 165 + 32 + 1 + 0.7011019 + 0.376262158 + 0.0144438446 + + + 255 + 0 + 191 + 0 + 1 + 0 + 0.5209956 + 0 + + + 255 + 255 + 255 + 0 + 1 + 1 + 1 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 0 + 255 + 0 + 1 + 0 + 1 + 0 + + + 255 + 218 + 165 + 32 + 1 + 0.7011019 + 0.376262158 + 0.0144438446 + + + 255 + 218 + 165 + 32 + 1 + 0.7011019 + 0.376262158 + 0.0144438446 + + + 255 + 127 + 127 + 0 + 1 + 0.212230757 + 0.212230757 + 0 + + + 255 + 255 + 255 + 0 + 1 + 1 + 1 + 0 + + + 255 + 229 + 229 + 0 + 1 + 0.7835378 + 0.7835378 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 204 + 204 + 0 + 1 + 0.603827357 + 0.603827357 + 0 + + + 255 + 178 + 178 + 0 + 1 + 0.445201218 + 0.445201218 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 255 + 255 + 0 + 1 + 1 + 1 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 255 + 255 + 0 + 1 + 1 + 1 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 255 + 215 + 0 + 1 + 1 + 0.6795425 + 0 + + + 255 + 255 + 255 + 0 + 1 + 1 + 1 + 0 + + + Monochrome Yellow + Lucida Console + 12 + \ No newline at end of file diff --git a/Themes/VIM.StorableColorTheme.ps1xml b/Themes/VIM.StorableColorTheme.ps1xml new file mode 100644 index 0000000..971180d --- /dev/null +++ b/Themes/VIM.StorableColorTheme.ps1xml @@ -0,0 +1,813 @@ + + + + ErrorForegroundColor + ErrorBackgroundColor + WarningForegroundColor + WarningBackgroundColor + VerboseForegroundColor + VerboseBackgroundColor + DebugForegroundColor + DebugBackgroundColor + ConsolePaneBackgroundColor + ConsolePaneTextBackgroundColor + ConsolePaneForegroundColor + ScriptPaneBackgroundColor + ScriptPaneForegroundColor + TokenColors\Attribute + TokenColors\Command + TokenColors\CommandArgument + TokenColors\CommandParameter + TokenColors\Comment + TokenColors\GroupEnd + TokenColors\GroupStart + TokenColors\Keyword + TokenColors\LineContinuation + TokenColors\LoopLabel + TokenColors\Member + TokenColors\NewLine + TokenColors\Number + TokenColors\Operator + TokenColors\Position + TokenColors\StatementSeparator + TokenColors\String + TokenColors\Type + TokenColors\Unknown + TokenColors\Variable + ConsoleTokenColors\Attribute + ConsoleTokenColors\Command + ConsoleTokenColors\CommandArgument + ConsoleTokenColors\CommandParameter + ConsoleTokenColors\Comment + ConsoleTokenColors\GroupEnd + ConsoleTokenColors\GroupStart + ConsoleTokenColors\Keyword + ConsoleTokenColors\LineContinuation + ConsoleTokenColors\LoopLabel + ConsoleTokenColors\Member + ConsoleTokenColors\NewLine + ConsoleTokenColors\Number + ConsoleTokenColors\Operator + ConsoleTokenColors\Position + ConsoleTokenColors\StatementSeparator + ConsoleTokenColors\String + ConsoleTokenColors\Type + ConsoleTokenColors\Unknown + ConsoleTokenColors\Variable + XmlTokenColors\CharacterData + XmlTokenColors\QuotedString + XmlTokenColors\Comment + XmlTokenColors\CommentDelimiter + XmlTokenColors\15 + XmlTokenColors\13 + XmlTokenColors\12 + XmlTokenColors\14 + XmlTokenColors\18 + XmlTokenColors\MarkupExtension + XmlTokenColors\Quote + XmlTokenColors\17 + XmlTokenColors\ElementName + XmlTokenColors\11 + XmlTokenColors\19 + XmlTokenColors\16 + XmlTokenColors\Attribute + XmlTokenColors\10 + XmlTokenColors\Tag + XmlTokenColors\Text + + + + 255 + 255 + 0 + 0 + 1 + 1 + 0 + 0 + + + 0 + 255 + 255 + 255 + 0 + 1 + 1 + 1 + + + 255 + 255 + 140 + 0 + 1 + 1 + 0.2622507 + 0 + + + 0 + 255 + 255 + 255 + 0 + 1 + 1 + 1 + + + 255 + 255 + 255 + 0 + 1 + 1 + 1 + 0 + + + 0 + 255 + 255 + 255 + 0 + 1 + 1 + 1 + + + 255 + 229 + 0 + 229 + 1 + 0.7835378 + 0 + 0.7835378 + + + 0 + 255 + 255 + 255 + 0 + 1 + 1 + 1 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 255 + 0 + 1 + 0 + 1 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 255 + 255 + 255 + 1 + 1 + 1 + 1 + + + 255 + 132 + 167 + 193 + 1 + 0.23074007 + 0.386429459 + 0.533276439 + + + 255 + 255 + 255 + 96 + 1 + 1 + 1 + 0.116970673 + + + 255 + 255 + 255 + 255 + 1 + 1 + 1 + 1 + + + 255 + 255 + 222 + 0 + 1 + 1 + 0.730460763 + 0 + + + 255 + 174 + 174 + 174 + 1 + 0.4232677 + 0.4232677 + 0.4232677 + + + 255 + 255 + 255 + 255 + 1 + 1 + 1 + 1 + + + 255 + 255 + 255 + 255 + 1 + 1 + 1 + 1 + + + 255 + 255 + 222 + 0 + 1 + 1 + 0.730460763 + 0 + + + 255 + 255 + 255 + 255 + 1 + 1 + 1 + 1 + + + 255 + 0 + 255 + 0 + 1 + 0 + 1 + 0 + + + 255 + 255 + 255 + 255 + 1 + 1 + 1 + 1 + + + 255 + 255 + 255 + 255 + 1 + 1 + 1 + 1 + + + 255 + 152 + 254 + 30 + 1 + 0.313988745 + 0.9911021 + 0.0129830325 + + + 255 + 0 + 127 + 0 + 1 + 0 + 0.212230757 + 0 + + + 255 + 255 + 255 + 255 + 1 + 1 + 1 + 1 + + + 255 + 255 + 255 + 255 + 1 + 1 + 1 + 1 + + + 255 + 0 + 212 + 45 + 1 + 0 + 0.658374846 + 0.0262412224 + + + 255 + 132 + 167 + 193 + 1 + 0.23074007 + 0.386429459 + 0.533276439 + + + 255 + 255 + 255 + 255 + 1 + 1 + 1 + 1 + + + 255 + 0 + 212 + 45 + 1 + 0 + 0.658374846 + 0.0262412224 + + + 255 + 0 + 255 + 0 + 1 + 0 + 1 + 0 + + + 255 + 0 + 223 + 0 + 1 + 0 + 0.73791045 + 0 + + + 255 + 0 + 191 + 0 + 1 + 0 + 0.5209956 + 0 + + + 255 + 0 + 159 + 0 + 1 + 0 + 0.3467041 + 0 + + + 255 + 0 + 127 + 0 + 1 + 0 + 0.212230757 + 0 + + + 255 + 0 + 159 + 0 + 1 + 0 + 0.3467041 + 0 + + + 255 + 0 + 191 + 0 + 1 + 0 + 0.5209956 + 0 + + + 255 + 0 + 223 + 0 + 1 + 0 + 0.73791045 + 0 + + + 255 + 0 + 255 + 0 + 1 + 0 + 1 + 0 + + + 255 + 0 + 223 + 0 + 1 + 0 + 0.73791045 + 0 + + + 255 + 0 + 191 + 0 + 1 + 0 + 0.5209956 + 0 + + + 255 + 0 + 159 + 0 + 1 + 0 + 0.3467041 + 0 + + + 255 + 0 + 159 + 0 + 1 + 0 + 0.3467041 + 0 + + + 255 + 0 + 159 + 0 + 1 + 0 + 0.3467041 + 0 + + + 255 + 0 + 191 + 0 + 1 + 0 + 0.5209956 + 0 + + + 255 + 0 + 223 + 0 + 1 + 0 + 0.73791045 + 0 + + + 255 + 0 + 255 + 0 + 1 + 0 + 1 + 0 + + + 255 + 0 + 159 + 0 + 1 + 0 + 0.3467041 + 0 + + + 255 + 0 + 255 + 0 + 1 + 0 + 1 + 0 + + + 255 + 0 + 191 + 0 + 1 + 0 + 0.5209956 + 0 + + + 255 + 212 + 212 + 212 + 1 + 0.658374846 + 0.658374846 + 0.658374846 + + + 255 + 255 + 255 + 255 + 1 + 1 + 1 + 1 + + + 255 + 0 + 255 + 0 + 1 + 0 + 1 + 0 + + + 255 + 0 + 255 + 0 + 1 + 0 + 1 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 255 + 140 + 0 + 1 + 1 + 0.2622507 + 0 + + + 255 + 229 + 229 + 0 + 1 + 0.7835378 + 0.7835378 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 255 + 255 + 0 + 1 + 1 + 1 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 255 + 0 + 0 + 1 + 1 + 0 + 0 + + + 255 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + + + 255 + 0 + 255 + 255 + 1 + 0 + 1 + 1 + + + 255 + 255 + 255 + 255 + 1 + 1 + 1 + 1 + + + VIM + Courier New + 14 + \ No newline at end of file diff --git a/docs/Add-CurrentProject.md b/docs/Add-CurrentProject.md new file mode 100644 index 0000000..b483b04 --- /dev/null +++ b/docs/Add-CurrentProject.md @@ -0,0 +1,58 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# Add-CurrentProject + +## SYNOPSIS + +This command adds the current file path to the current project list. + +## SYNTAX + +```yaml +Add-CurrentProject [[-List] ] [] +``` + +## DESCRIPTION + +This command adds the current file path to the current project list. The list is simply a text file with full file names to a group of scripts that you might be working on. The ISEScriptingGeek module uses a built-in variable, $currentProjectList. + + +## PARAMETERS + +### -List + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: $currentProjectList +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS + +[Edit-CurrentProject]() + +[Import-CurrentProject]() diff --git a/docs/Add-ISEBookmark.md b/docs/Add-ISEBookmark.md new file mode 100644 index 0000000..9129d58 --- /dev/null +++ b/docs/Add-ISEBookmark.md @@ -0,0 +1,38 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# Add-ISEBookmark + +## SYNOPSIS + +Add an ISE Bookmark + +## SYNTAX + +```yaml +Add-ISEBookmark +``` + +## DESCRIPTION + +Add an ISE Bookmark + +## PARAMETERS + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/CloseAllFiles.md b/docs/CloseAllFiles.md new file mode 100644 index 0000000..ac2ccf3 --- /dev/null +++ b/docs/CloseAllFiles.md @@ -0,0 +1,44 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# CloseAllFiles + +## SYNOPSIS + +Close all files in the ISE. + +## SYNTAX + +```yaml +CloseAllFiles [] +``` + +## DESCRIPTION + +Close all files in the ISE. + + +## PARAMETERS + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### None + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/CloseAllFilesButCurrent.md b/docs/CloseAllFilesButCurrent.md new file mode 100644 index 0000000..9b9ac8c --- /dev/null +++ b/docs/CloseAllFilesButCurrent.md @@ -0,0 +1,45 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# CloseAllFilesButCurrent + +## SYNOPSIS + +Close all files in the ISE except the current one. + +## SYNTAX + +```yaml +CloseAllFilesButCurrent [] +``` + +## DESCRIPTION + +Close all files in the ISE except the current one. + +## PARAMETERS + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Convert-AliasDefinition.md b/docs/Convert-AliasDefinition.md new file mode 100644 index 0000000..1cef2a7 --- /dev/null +++ b/docs/Convert-AliasDefinition.md @@ -0,0 +1,96 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# Convert-AliasDefinition + +## SYNOPSIS + +Convert aliases to their definition + +## SYNTAX + +### ToDefinition (Default) + +```yaml +Convert-AliasDefinition [-Text] [-ToDefinition] [] +``` + +### ToAlias + +```yaml +Convert-AliasDefinition [-Text] [-ToAlias] [] +``` + +## DESCRIPTION + +Convert aliases to their definition. + + +## PARAMETERS + +### -Text + +Enter a string to convert + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ToAlias + +```yaml +Type: SwitchParameter +Parameter Sets: ToAlias +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ToDefinition + +```yaml +Type: SwitchParameter +Parameter Sets: ToDefinition +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### None + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Convert-CodetoSnippet.md b/docs/Convert-CodetoSnippet.md new file mode 100644 index 0000000..f5ecb36 --- /dev/null +++ b/docs/Convert-CodetoSnippet.md @@ -0,0 +1,92 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# Convert-CodetoSnippet + +## SYNOPSIS + +Convert selected code to a snippet + +## SYNTAX + +```yaml +Convert-CodetoSnippet [-Text] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION + +Convert selected code to an ISE snippet. + +## PARAMETERS + +### -Confirm + +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Text + +Enter some code text or break, select text in the ISE and try again. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf + +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Convert-CommandtoHash.md b/docs/Convert-CommandtoHash.md new file mode 100644 index 0000000..f9cd30c --- /dev/null +++ b/docs/Convert-CommandtoHash.md @@ -0,0 +1,57 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# Convert-CommandtoHash + +## SYNOPSIS + +Convert a command to a hashtable + +## SYNTAX + +```yaml +Convert-CommandtoHash [[-Text] ] [] +``` + +## DESCRIPTION + +This is a crude attempt to convert a selected PowerShell expression into a corresponding hashtable that you can use for splatting. + +## PARAMETERS + +### -Text + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/ConvertFrom-Alias.md b/docs/ConvertFrom-Alias.md new file mode 100644 index 0000000..17a0d45 --- /dev/null +++ b/docs/ConvertFrom-Alias.md @@ -0,0 +1,58 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# ConvertFrom-Alias + +## SYNOPSIS + +Convert command from an alias + +## SYNTAX + +```yaml +ConvertFrom-Alias [[-Text] ] [] +``` + +## DESCRIPTION + +Convert a command from an alias. + + +## PARAMETERS + +### -Text + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/ConvertFrom-MultiLineComment.md b/docs/ConvertFrom-MultiLineComment.md new file mode 100644 index 0000000..8390c45 --- /dev/null +++ b/docs/ConvertFrom-MultiLineComment.md @@ -0,0 +1,58 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# ConvertFrom-MultiLineComment + +## SYNOPSIS + +Convert from a multi-line comment + +## SYNTAX + +```yaml +ConvertFrom-MultiLineComment [[-Text] ] [] +``` + +## DESCRIPTION + +Use this command to toggle between a multi-line comment. + + +## PARAMETERS + +### -Text + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/ConvertTo-CommentHelp.md b/docs/ConvertTo-CommentHelp.md new file mode 100644 index 0000000..59ab9ef --- /dev/null +++ b/docs/ConvertTo-CommentHelp.md @@ -0,0 +1,39 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# ConvertTo-CommentHelp + +## SYNOPSIS + +Convert MAML help to comment-based help + +## SYNTAX + +```yaml +ConvertTo-CommentHelp +``` + +## DESCRIPTION + +This function will make a best effort to convert help from an existing cmdlet to comment based help. This is handy when building a proxy function. Converted help will be opened in a new ISE Tab. + + +## PARAMETERS + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/ConvertTo-Definition.md b/docs/ConvertTo-Definition.md new file mode 100644 index 0000000..6c0ccf2 --- /dev/null +++ b/docs/ConvertTo-Definition.md @@ -0,0 +1,59 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# ConvertTo-Definition + +## SYNOPSIS + +Convert aliases to definitions. + +## SYNTAX + +``` +ConvertTo-Definition [-Text] [] +``` + +## DESCRIPTION + +Converts all command aliases in selected text to their corresponding command definition. + +## PARAMETERS + +### -Text + +Enter a string to convert + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/ConvertTo-MultiLineComment.md b/docs/ConvertTo-MultiLineComment.md new file mode 100644 index 0000000..b8eb3c7 --- /dev/null +++ b/docs/ConvertTo-MultiLineComment.md @@ -0,0 +1,57 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# ConvertTo-MultiLineComment + +## SYNOPSIS + +Convert to a multi-line comment. + +## SYNTAX + +```yaml +ConvertTo-MultiLineComment [[-Text] ] [] +``` + +## DESCRIPTION + +Convert selected text into a multi-line comment. + +## PARAMETERS + +### -Text + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/ConvertTo-TextFile.md b/docs/ConvertTo-TextFile.md new file mode 100644 index 0000000..c50d1b9 --- /dev/null +++ b/docs/ConvertTo-TextFile.md @@ -0,0 +1,52 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# ConvertTo-TextFile + +## SYNOPSIS + +Convert the file to a text file + +## SYNTAX + +```yaml +ConvertTo-TextFile [-Reload] +``` + +## DESCRIPTION + +Save the current file as a txt file with an option to reload in the PowerShell ISE. + +## PARAMETERS + +### -Reload + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Copy-ToWord.md b/docs/Copy-ToWord.md new file mode 100644 index 0000000..a09660c --- /dev/null +++ b/docs/Copy-ToWord.md @@ -0,0 +1,72 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# Copy-ToWord + +## SYNOPSIS + +Copy selected text to Microsoft Word + +## SYNTAX + +```yaml +Copy-ToWord [[-Text] ] [-Colorized] [] +``` + +## DESCRIPTION + +Use this command to copy selected text from the ISE into a new Microsoft Word document. You must have Microsoft Word installed. + + +## PARAMETERS + +### -Colorized + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Text + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Edit-CurrentProject.md b/docs/Edit-CurrentProject.md new file mode 100644 index 0000000..e110328 --- /dev/null +++ b/docs/Edit-CurrentProject.md @@ -0,0 +1,60 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# Edit-CurrentProject + +## SYNOPSIS + +Edit the current project list file + +## SYNTAX + +```yaml +Edit-CurrentProject [-List] [] +``` + +## DESCRIPTION + +Open the current project list in the PowerShell ISE to view or edit. You will need to manually remove items. +The list is simply a text file with full file names to a group of scripts that you might be working on. + +The ISEScriptingGeek module uses a built-in variable, $currentProjectList. + +## PARAMETERS + +### -List + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS + +[Add-CurrentProject]() + +[Import-CurrentProject]() diff --git a/docs/Edit-Snippet.md b/docs/Edit-Snippet.md new file mode 100644 index 0000000..250cd0b --- /dev/null +++ b/docs/Edit-Snippet.md @@ -0,0 +1,53 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# Edit-Snippet + +## SYNOPSIS + +Edit an ISE Snippet + +## SYNTAX + +```yaml +Edit-Snippet [[-Path] ] +``` + +## DESCRIPTION + +View snippets and edit selected in the PowerShell ISE. Changes won't be effective until the next ISE session or tab. + + +## PARAMETERS + +### -Path + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Find-InFile.md b/docs/Find-InFile.md new file mode 100644 index 0000000..f033174 --- /dev/null +++ b/docs/Find-InFile.md @@ -0,0 +1,43 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# Find-InFile + +## SYNOPSIS + +Search for text in selected files. + +## SYNTAX + +```yaml +Find-InFile [] +``` + +## DESCRIPTION + +Search for text in selected files. + +## PARAMETERS + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Get-ASTProfile.md b/docs/Get-ASTProfile.md new file mode 100644 index 0000000..6950404 --- /dev/null +++ b/docs/Get-ASTProfile.md @@ -0,0 +1,117 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# Get-ASTProfile + +## SYNOPSIS + +Profile a PowerShell script + +## SYNTAX + +```yaml +Get-ASTProfile [[-Path] ] [-FilePath ] [] +``` + +## DESCRIPTION + +This script will parse a PowerShell script using the AST to identify elements and any items that might be dangerous. +The output is a text report which by default is turned into a help topic stored in your Windows PowerShell folder under Documents, although you can specify an alternate location. + +DETAILS +The script takes the name of a script to profile. You can specify a ps1 or psm1 filename. Using the AST the script will prepare a text report showing you any script requirements, script parameters, commands and type names. +You will see all commands used including those that can't be resolved as well as those that I thought might be considered potentially dangerous such as cmdlets that use the verbs Remove or Stop. + +Because some people might invoke methods from .NET classes directly I've also captured all typenames. +Most of them will probably be related to parameters but as least you'll know what to look for. + +The report won't detail parameters from nested functions but you'll still see what commands they will use. +The script uses Get-Command to identify commands which might entail loading a module. Most of the time this shouldn't be an issue but you still might want to profile the script in virtualized or test environment. + +Any unresolved command you see is either from a module that couldn't be loaded or it might be an internally defined command. Once you know what to look for you can open the script in your favorite editor and search for the mystery commands. + +Note that if the script uses application names like Main or Control for function names, they might be misinterpreted. +In that case, search the script for the name, ie "main". + +This version will only analyze files with an extension of .ps1, .psm1 or .txt. + +## EXAMPLES + +### EXAMPLE 1 + +```powershell +PS C:\> Get-ASTProfile c:\download\UnknownScript.ps1 +``` + +This will analyze the script UnknownScript.ps1 and show the results in a help window. +It will also create a text file in your Documents\WindowsPowerShell folder called UnknownScript.help.txt. + +### EXAMPLE 2 + +```powershell +PS C:\> Get-ASTProfile c:\download\UnknownScript.ps1 -filepath c:\work +``` + +This command is the same as the first example except the help file will be created in C:\Work. + +## PARAMETERS + +### -Path + +The path to the script file. It should have an extension of .ps1, .psm1 or .bat. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: $(Read-Host "Enter the filename and path to a PowerShell script") +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -FilePath + +The path for the report file. The default is your WindowsPowerShell folder. This parameter has aliases of fp and out. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: fp, out + +Required: False +Position: Named +Default value: "$env:userprofile\Documents\WindowsPowerShell" +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### Help topic + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS + +[Get-Command]() + +[Get-Alias]() + diff --git a/docs/Get-CommandMetadata.md b/docs/Get-CommandMetadata.md new file mode 100644 index 0000000..cde27c0 --- /dev/null +++ b/docs/Get-CommandMetadata.md @@ -0,0 +1,102 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2014/09/friday-fun-creating-powershell-scripts-with-powershell +schema: 2.0.0 +--- + +# Get-CommandMetadata + +## SYNOPSIS + +Create a proxy function of a PowerShell command. + +## SYNTAX + +```yaml +Get-CommandMetadata [-Command] [-NewName ] [-NoHelp] [] +``` + +## DESCRIPTION + +This command will create a proxy version of a PowerShell cmdlet, function or alias. The intent is to simplify creating a new function from command metadata. You can give your command and opt to remove help references for the original command. + +If you run this in the PowerShell ISE, code for the new function will be inserted into a new Powershell tab. + +## EXAMPLES + +### EXAMPLE 1 + +```powershell +PS C:\> Get-CommandMetadata Get-WMIObject -nohelp -newname Get-MyOS +``` + +Create a proxy function for Get-WMIObject that will be called Get-MyOS. Help references will be replaced with a comment-help block. + +## PARAMETERS + +### -Command + +The name of a PowerShell command to proxy. This can be a cmdlet, function or alias. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -NewName + +The name you want to use for your new command. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -NoHelp + +Remove references to existing command help. Using this parameter will insert a comment-based help outline. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +This command was first described at http://jdhitsolutions.com/blog/2014/09/friday-fun-creating-powershell-scripts-with-powershell + +## RELATED LINKS + diff --git a/docs/Get-ISEBookmark.md b/docs/Get-ISEBookmark.md new file mode 100644 index 0000000..b448f2d --- /dev/null +++ b/docs/Get-ISEBookmark.md @@ -0,0 +1,43 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2014/09/friday-fun-creating-powershell-scripts-with-powershell +schema: 2.0.0 +--- + +# Get-ISEBookmark + +## SYNOPSIS + +Get an ISE Bookmark. + +## SYNTAX + +```yaml +Get-ISEBookmark [] +``` + +## DESCRIPTION + +Get an ISE Bookmark + +## PARAMETERS + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Get-NextISETab.md b/docs/Get-NextISETab.md new file mode 100644 index 0000000..0717c79 --- /dev/null +++ b/docs/Get-NextISETab.md @@ -0,0 +1,44 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2014/09/friday-fun-creating-powershell-scripts-with-powershell +schema: 2.0.0 +--- + +# Get-NextISETab + +## SYNOPSIS + +Get the next ISE tab. + +## SYNTAX + +```yaml +Get-NextISETab [] +``` + +## DESCRIPTION + +Use this command to easily cycle through open tabs in the ISE. + + +## PARAMETERS + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Get-ScriptComments.md b/docs/Get-ScriptComments.md new file mode 100644 index 0000000..e73c2aa --- /dev/null +++ b/docs/Get-ScriptComments.md @@ -0,0 +1,55 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2014/09/friday-fun-creating-powershell-scripts-with-powershell +schema: 2.0.0 +--- + +# Get-ScriptComments + +## SYNOPSIS + +Get comments from a PowerShell script file. + +## SYNTAX + +```yaml +Get-ScriptComments [-Path] [] +``` + +## DESCRIPTION + +This command will use the AST parser to go through a PowerShell script, either a .ps1 or .psm1 file, and display only the comments. + +## PARAMETERS + +### -Path + +Enter the path of a PS1 file + +```yaml +Type: String +Parameter Sets: (All) +Aliases: PSPath, Name + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Get-ScriptingHelp.md b/docs/Get-ScriptingHelp.md new file mode 100644 index 0000000..3ba71d4 --- /dev/null +++ b/docs/Get-ScriptingHelp.md @@ -0,0 +1,39 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2014/09/friday-fun-creating-powershell-scripts-with-powershell +schema: 2.0.0 +--- + +# Get-ScriptingHelp + +## SYNOPSIS + +Get about scripting help + +## SYNTAX + +```yaml +Get-ScriptingHelp +``` + +## DESCRIPTION + +Use this command to select about_scripting topics using Out-Gridview. + + +## PARAMETERS + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Get-SearchResult.md b/docs/Get-SearchResult.md new file mode 100644 index 0000000..b577d50 --- /dev/null +++ b/docs/Get-SearchResult.md @@ -0,0 +1,72 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2014/09/friday-fun-creating-powershell-scripts-with-powershell +schema: 2.0.0 +--- + +# Get-SearchResult + +## SYNOPSIS + +Search for selected text online + +## SYNTAX + +```yaml +Get-SearchResult [[-Text] ] [-SearchEngine ] [] +``` + +## DESCRIPTION + +Use this command to search online for the selected text. The default is Google. + +## PARAMETERS + +### -SearchEngine + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: Bing, Google, Yahoo + +Required: False +Position: Named +Default value: Google +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Text + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Import-CurrentProject.md b/docs/Import-CurrentProject.md new file mode 100644 index 0000000..8926253 --- /dev/null +++ b/docs/Import-CurrentProject.md @@ -0,0 +1,58 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# Import-CurrentProject + +## SYNOPSIS + +Open files from the project list + +## SYNTAX + +```yaml +Import-CurrentProject [-List] [] +``` + +## DESCRIPTION + +Read the current project list and open each file in the ISE. The list is simply a text file with full file names to a group of scripts that you might be working on. The ISEScriptingGeek module uses a built-in variable, $currentProjectList. + +## PARAMETERS + +### -List + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS + +[Add-CurrentProject]() + +[Edit-CurrentProject]() + diff --git a/docs/New-CIMCommand.md b/docs/New-CIMCommand.md new file mode 100644 index 0000000..ff46abb --- /dev/null +++ b/docs/New-CIMCommand.md @@ -0,0 +1,52 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# New-CIMCommand + +## SYNOPSIS + +Create a command based on a CIM class. + +## SYNTAX + +```yaml +New-CIMCommand [[-computername] ] +``` + +## DESCRIPTION + +This command starts a graphical wizard process to help you build a new function based on a WMI/CIM class. + +## PARAMETERS + +### -computername + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/New-CommentHelp.md b/docs/New-CommentHelp.md new file mode 100644 index 0000000..24457f8 --- /dev/null +++ b/docs/New-CommentHelp.md @@ -0,0 +1,91 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# New-CommentHelp + +## SYNOPSIS + +Auto-generate comment based help. + +## SYNTAX + +```yaml +New-CommentHelp [-Name] [-Synopsis] [-Description] [] +``` + +## DESCRIPTION + +This will generate comment based help based on a loaded command and insert it into the current file in the ISE. + +## PARAMETERS + +### -Description + +Enter a description. You can expand and edit later + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name + +What is the name of your function or command? + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Synopsis + +Enter a brief synopsis + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/New-DSCResourceSnippet.md b/docs/New-DSCResourceSnippet.md new file mode 100644 index 0000000..3c0b9f7 --- /dev/null +++ b/docs/New-DSCResourceSnippet.md @@ -0,0 +1,175 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# New-DSCResourceSnippet + +## SYNOPSIS + +Create ISE snippets for DSC Resources + +## SYNTAX + +### Name (Default) + +```yaml +New-DSCResourceSnippet [-Name] [-Author ] [-Passthru] [-WhatIf] [-Confirm] + [] +``` + +### Resource + +```yaml +New-DSCResourceSnippet [-DSCResource] [-Author ] [-Passthru] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION + +This command will convert the syntax for a DSC resource into an ISE snippet. Snippets will be created in the default location. Snippet names will take the name "DSC \". The snippet description uses the format "\ resource from module \ \".You will end up with a description like this: + +xWinEventLog resource from module xWinEventLog Microsoft Corporation + +You must run this command in the PowerShell ISE. + +## EXAMPLES + +### EXAMPLE 1 + +```powershell +PS C:\> New-DSCResourceSnippet -name xsmbshare -author "Jeff Hicks" -passthru + +Directory: C:\Users\Jeff\documents\WindowsPowerShell\Snippets + + +Mode LastWriteTime Length Name +---- ------------- ------ ---- +-a--- 10/20/2014 8:48 AM 1157 DSC xSmbShare Resource.snippets.ps1xml +``` + +Create a snippet from a single resource. + +### EXAMPLE 2 + +```powershell +PS C:\> Get-DSCResource | New-DSCResourceSnippet +``` + +This command will create snippets for every installed DSC resource. Existing snippet files will be overwritten. + +## PARAMETERS + +### -Name + +Enter the name of a DSC resource + +```yaml +Type: String[] +Parameter Sets: Name +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DSCResource + +Enter the name of a DSC resource + +```yaml +Type: DscResourceInfo[] +Parameter Sets: Resource +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -Author + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: $env:username +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Passthru + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf + +Shows what would happen if the cmdlet runs. The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm + +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS + +[Get-DSCResource]() + +[New-ISESnippet]() + diff --git a/docs/New-FileHere.md b/docs/New-FileHere.md new file mode 100644 index 0000000..09735fb --- /dev/null +++ b/docs/New-FileHere.md @@ -0,0 +1,85 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# New-FileHere + +## SYNOPSIS + +Create a new file in the current path. + +## SYNTAX + +```yaml +New-FileHere [[-Name] ] [-Open] [-Passthru] [] +``` + +## DESCRIPTION + +When you create a new file, the ISE wants to create it in the directory you were in when you started the ISE. +I often want to create a new file in the current location. This command has no parameters. You will be prompted for a new file name if you don't specify one. + + +## PARAMETERS + +### -Name + +Enter the name of the new file. If you don't specify one you will be prompted. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: (New-Inputbox -Prompt "Enter a file name" -Title "New File" -Default "MyUntitled.ps1") +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Open + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Passthru + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/New-Function.md b/docs/New-Function.md new file mode 100644 index 0000000..286cf4b --- /dev/null +++ b/docs/New-Function.md @@ -0,0 +1,38 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# New-Function + +## SYNOPSIS + +Insert a function outline + +## SYNTAX + +``` +New-Function +``` + +## DESCRIPTION + +Use this command to insert a function outline. This is very similar to using the function snippet. + +## PARAMETERS + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/New-Inputbox.md b/docs/New-Inputbox.md new file mode 100644 index 0000000..7fcd8c0 --- /dev/null +++ b/docs/New-Inputbox.md @@ -0,0 +1,97 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: +schema: 2.0.0 +--- + +# New-Inputbox + +## SYNOPSIS + +Display a Visual Basic style inputbox. + +## SYNTAX + +```yaml +New-Inputbox [-Prompt] [[-Title] ] [[-Default] ] [] +``` + +## DESCRIPTION + +This function will display a graphical Inputbox, like the one from VisualBasic and VBScript. You must specify a messag prompt. You can specify a title, the default is "Input". You can also specify a default value. The inputbox will write whatever is entered into it to the pipeline. If you click Cancel the inputbox will still write a string to the pipeline with a length of 0. It is recommended that you validate input. + +## EXAMPLES + +### EXAMPLE 1 + +```powershell +PS C:\> $c = New-Inputbox -prompt "Enter the Netbios name of a domain computer." -title "Enter a computername" -default $env:computername +PS C:\> get-service -computer $c +``` + +## PARAMETERS + +### -Prompt + +Enter a message prompt + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Title + + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: Input +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Default + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### [string] + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/New-PSCommand.md b/docs/New-PSCommand.md new file mode 100644 index 0000000..8b5ae53 --- /dev/null +++ b/docs/New-PSCommand.md @@ -0,0 +1,246 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command +schema: 2.0.0 +--- + +# New-PSCommand + +## SYNOPSIS + +Create an advanced function outline + +## SYNTAX + +```yaml +New-PSCommand [-Name] [[-NewParameters] ] [-ShouldProcess] [[-Synopsis] ] + [[-Description] ] [[-BeginCode] ] [[-ProcessCode] ] [[-EndCode] ] [-UseISE] + [] +``` + +## DESCRIPTION + +This command will create the outline of an advanced function based on a hash table of new parameter values. +You will still need to flesh out the function and insert the actual commands. + +You might need to tweak parameters in the resulting code for items such a default value, help message, parameter aliases and validation. + +The New-PSCommand command takes a lot of the grunt work out of the scripting process so you can focus on the actual working part of the function. + +## EXAMPLES + +### EXAMPLE 1 + +```powershell +PS C:\> $paramhash=@{Name="string[]";Test="switch";Path="string"} +PS C:\> New-PSCommand -name "Set-MyScript" -Newparameters $paramhash | out-file "c:\scripts\set-myscript.ps1" +``` + +Create an advanced script outline for Set-MyScript with parameters of Name, Test and Path. Results are saved to a file. + +### EXAMPLE 2 + +```powershell +PS C:\> $hash = [ordered]@{Name="string[]",$True,$True,$False,0;Path="string",$false,$false,$false,1;Size="int",$false,$false,$true;Recurse="switch"} + +PS C:\> $begin={ +#initialize some variables +$arr=@() +$a=$True +$b=123 +} +PS C:\> $end="write-host 'Finished' -foreground Green" +PS C:\> $synopsis = "Get user data" +PS C:\> $desc = @" +This command will do something really amazing. +All you need to do is provide +the right amount of pixie dust and shavings from a unicorn horn. + +This requires PowerShell v4 and a full moon. +"@ + +PS C:\> New-PSCommand -Name Get-UserData -NewParameters $hash -BeginCode $begin -EndCode $end -Synopsis $synopsis -Description $desc -useise +``` + +Create an advanced function from the ordered hash table. This expression will also insert extra code into the Begin and End scriptblocks as well as enter text for the help synopsis and description. The new command will be opened in the ISE. + +## PARAMETERS + +### -Name + +The name of the new function + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -NewParameters + +A hash table of new parameter values. The key should be the parameter name. The entry value should be the object type. You can also indicate if it should be an array by using \[\] with the object type. +Here's an example: + +@{Name="string\[\]";Test="switch";Path="string"} + +Or you can use an "advanced" version of the hash table to specify optional parameter attributes that follows the format: + +@{ParamName="type\[\]",Mandatory,ValuefromPipeline,ValuefromPipelinebyPropertyName,Position} + +Here's an example: + +$h = @{Name="string\[\]",$True,$True,$False,0; + Path="string",$false,$false,$false,1; + Size="int",$false,$false,$true; + Recurse="switch" + } + +You can also specify an ordered hash table if you are running PowerShell v or later. + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: Parameters + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ShouldProcess + +Set SupportsShouldProcess to True in the new function. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Synopsis + +Provide a brief synopsis of your command. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Description + +Provide a description for your command. You can always add and edit this later. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -BeginCode + +A block of code to insert in the Begin scriptblock. This can be either a scriptblock or a string. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 5 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProcessCode + +A block of code to insert at the start of the Process scriptblock. This can be either a scriptblock or a string. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 6 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -EndCode + +A block of code to insert at the start of the End scriptblock. This can be either a scriptblock or a string. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 7 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UseISE + +If you are running this command in the ISE, send the new function to the editor as a new file. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +This command was described at http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command + +## RELATED LINKS diff --git a/docs/Open-ISEBookmark.md b/docs/Open-ISEBookmark.md new file mode 100644 index 0000000..0dfd397 --- /dev/null +++ b/docs/Open-ISEBookmark.md @@ -0,0 +1,43 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command +schema: 2.0.0 +--- + +# Open-ISEBookmark + +## SYNOPSIS + +Open an ISE bookmark. + +## SYNTAX + +```yaml +Open-ISEBookmark [] +``` + +## DESCRIPTION + +Open an ISE bookmark. + +## PARAMETERS + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Open-SelectedISE.md b/docs/Open-SelectedISE.md new file mode 100644 index 0000000..01a879c --- /dev/null +++ b/docs/Open-SelectedISE.md @@ -0,0 +1,57 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command +schema: 2.0.0 +--- + +# Open-SelectedISE + +## SYNOPSIS + +Open selected file in an ISE tab + +## SYNTAX + +``` +Open-SelectedISE [[-Text] ] [] +``` + +## DESCRIPTION + +Open selected file in a PowerShell ISE tab. You can use this to open dot sourced files in a script or profile. Select the entire path and use this command or it's shortcut to open the file. + +## PARAMETERS + +### -Text + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Out-ISETab.md b/docs/Out-ISETab.md new file mode 100644 index 0000000..5bf38ee --- /dev/null +++ b/docs/Out-ISETab.md @@ -0,0 +1,77 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command +schema: 2.0.0 +--- + +# Out-ISETab + +## SYNOPSIS + +Send command output to an ISE tab + +## SYNTAX + +```yaml +Out-ISETab [-InputObject] [-UseCurrentFile] [] +``` + +## DESCRIPTION + +This command will accept pipelined input and place it in a new PowerShell ISE tab. + +## EXAMPLES + +### EXAMPLE 1 + +```powershell +PS C:\> get-process | sort WS -descending | Select -first 5 | out-isetab +``` + +## PARAMETERS + +### -InputObject + +```yaml +Type: Object[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -UseCurrentFile + +Insert the text into the current ISE tab. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Remove-ISEBookmark.md b/docs/Remove-ISEBookmark.md new file mode 100644 index 0000000..647a7f8 --- /dev/null +++ b/docs/Remove-ISEBookmark.md @@ -0,0 +1,76 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command +schema: 2.0.0 +--- + +# Remove-ISEBookmark + +## SYNOPSIS + +Delete an ISE bookmark. + +## SYNTAX + +```yaml +Remove-ISEBookmark [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION + +Delete an ISE bookmark. + + +## PARAMETERS + +### -Confirm + +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf + +Shows what would happen if the cmdlet runs. The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Reset-ISEFile.md b/docs/Reset-ISEFile.md new file mode 100644 index 0000000..3e6ac5f --- /dev/null +++ b/docs/Reset-ISEFile.md @@ -0,0 +1,38 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command +schema: 2.0.0 +--- + +# Reset-ISEFile + +## SYNOPSIS + +Reload a file in the PowerShell ISE + +## SYNTAX + +```yaml +Reset-ISEFile +``` + +## DESCRIPTION + +This command will reload an file in the ISE that might have been modified outside of the ISE. + +## PARAMETERS + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Send-ToPrinter.md b/docs/Send-ToPrinter.md new file mode 100644 index 0000000..5bc1409 --- /dev/null +++ b/docs/Send-ToPrinter.md @@ -0,0 +1,52 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command +schema: 2.0.0 +--- + +# Send-ToPrinter + +## SYNOPSIS + +Print the current file in the ISE. + +## SYNTAX + +```yaml +Send-ToPrinter [[-path] ] +``` + +## DESCRIPTION + +This function is intended to be used in the ISE to print the current script file to the default printer. + +## PARAMETERS + +### -path + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Set-ScriptLocation.md b/docs/Set-ScriptLocation.md new file mode 100644 index 0000000..42f6cbd --- /dev/null +++ b/docs/Set-ScriptLocation.md @@ -0,0 +1,44 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command +schema: 2.0.0 +--- + +# Set-ScriptLocation + +## SYNOPSIS + +Set location to current script folder. + +## SYNTAX + +```yaml +Set-ScriptLocation [] +``` + +## DESCRIPTION + +Use this command to change location to match that of the current script in the PowerShell ISE. + + +## PARAMETERS + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Start-MyScript.md b/docs/Start-MyScript.md new file mode 100644 index 0000000..608b2a7 --- /dev/null +++ b/docs/Start-MyScript.md @@ -0,0 +1,52 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command +schema: 2.0.0 +--- + +# Start-MyScript + +## SYNOPSIS + +Launch the current script file + +## SYNTAX + +```yaml +Start-MyScript [[-Path] ] +``` + +## DESCRIPTION + +Use this command to launch the current script file with Show-Command. Fill in the form to run the script. + +## PARAMETERS + +### -Path + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Update-ISEBookmark.md b/docs/Update-ISEBookmark.md new file mode 100644 index 0000000..38f6b93 --- /dev/null +++ b/docs/Update-ISEBookmark.md @@ -0,0 +1,57 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command +schema: 2.0.0 +--- + +# Update-ISEBookmark + +## SYNOPSIS + +Update an ISE Bookmark. + +## SYNTAX + +```yaml +Update-ISEBookmark [[-Bookmark] ] [] +``` + +## DESCRIPTION + +Update an ISE Bookmark. + +## PARAMETERS + +### -Bookmark + +```yaml +Type: Object +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. +For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.Object + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/docs/Write-Signature.md b/docs/Write-Signature.md new file mode 100644 index 0000000..4138453 --- /dev/null +++ b/docs/Write-Signature.md @@ -0,0 +1,38 @@ +--- +external help file: ISEScriptingGeek-help.xml +Module Name: ISEScriptingGeek +online version: http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command +schema: 2.0.0 +--- + +# Write-Signature + +## SYNOPSIS + +Sign a script with verified certificate. + +## SYNTAX + +```yaml +Write-Signature +``` + +## DESCRIPTION + +Use this command to easily sign a script file with a valid code signing certificate. + +## PARAMETERS + +## INPUTS + +### None + +## OUTPUTS + +### System.Object + +## NOTES + +Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + +## RELATED LINKS diff --git a/en-us/ISEScriptingGeek-help.xml b/en-us/ISEScriptingGeek-help.xml new file mode 100644 index 0000000..740bc5e --- /dev/null +++ b/en-us/ISEScriptingGeek-help.xml @@ -0,0 +1,3429 @@ + + + + + Add-CurrentProject + Add + CurrentProject + + This command adds the current file path to the current project list. + + + + This command adds the current file path to the current project list. The list is simply a text file with full file names to a group of scripts that you might be working on. The ISEScriptingGeek module uses a built-in variable, $currentProjectList. + + + + Add-CurrentProject + + List + + + + String + + String + + + $currentProjectList + + + + + + List + + + + String + + String + + + $currentProjectList + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Edit-CurrentProject + + + + Import-CurrentProject + + + + + + + Add-ISEBookmark + Add + ISEBookmark + + Add an ISE Bookmark + + + + Add an ISE Bookmark + + + + Add-ISEBookmark + + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + Convert-AliasDefinition + Convert + AliasDefinition + + Convert aliases to their definition + + + + Convert aliases to their definition. + + + + Convert-AliasDefinition + + Text + + Enter a string to convert + + String + + String + + + None + + + ToAlias + + + + + SwitchParameter + + + False + + + + Convert-AliasDefinition + + Text + + Enter a string to convert + + String + + String + + + None + + + ToDefinition + + + + + SwitchParameter + + + False + + + + + + Text + + Enter a string to convert + + String + + String + + + None + + + ToAlias + + + + SwitchParameter + + SwitchParameter + + + False + + + ToDefinition + + + + SwitchParameter + + SwitchParameter + + + False + + + + + + None + + + + + + + + + + None + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + Convert-CodetoSnippet + Convert + CodetoSnippet + + Convert selected code to a snippet + + + + Convert selected code to an ISE snippet. + + + + Convert-CodetoSnippet + + Text + + Enter some code text or break, select text in the ISE and try again. + + String + + String + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + Text + + Enter some code text or break, select text in the ISE and try again. + + String + + String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + Convert-CommandtoHash + Convert + CommandtoHash + + Convert a command to a hashtable + + + + This is a crude attempt to convert a selected PowerShell expression into a corresponding hashtable that you can use for splatting. + + + + Convert-CommandtoHash + + Text + + + + String + + String + + + None + + + + + + Text + + + + String + + String + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + ConvertFrom-Alias + ConvertFrom + Alias + + Convert command from an alias + + + + Convert a command from an alias. + + + + ConvertFrom-Alias + + Text + + + + Object + + Object + + + None + + + + + + Text + + + + Object + + Object + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + ConvertFrom-MultiLineComment + ConvertFrom + MultiLineComment + + Convert from a multi-line comment + + + + Use this command to toggle between a multi-line comment. + + + + ConvertFrom-MultiLineComment + + Text + + + + String + + String + + + None + + + + + + Text + + + + String + + String + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + ConvertTo-CommentHelp + ConvertTo + CommentHelp + + Convert MAML help to comment-based help + + + + This function will make a best effort to convert help from an existing cmdlet to comment based help. This is handy when building a proxy function. Converted help will be opened in a new ISE Tab. + + + + ConvertTo-CommentHelp + + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + ConvertTo-Definition + ConvertTo + Definition + + Convert aliases to definitions. + + + + Converts all command aliases in selected text to their corresponding command definition. + + + + ConvertTo-Definition + + Text + + Enter a string to convert + + String + + String + + + None + + + + + + Text + + Enter a string to convert + + String + + String + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + ConvertTo-MultiLineComment + ConvertTo + MultiLineComment + + Convert to a multi-line comment. + + + + Convert selected text into a multi-line comment. + + + + ConvertTo-MultiLineComment + + Text + + + + String + + String + + + None + + + + + + Text + + + + String + + String + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + ConvertTo-TextFile + ConvertTo + TextFile + + Convert the file to a text file + + + + Save the current file as a txt file with an option to reload in the PowerShell ISE. + + + + ConvertTo-TextFile + + Reload + + + + + SwitchParameter + + + False + + + + + + Reload + + + + SwitchParameter + + SwitchParameter + + + False + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + Copy-ToWord + Copy + ToWord + + Copy selected text to Microsoft Word + + + + Use this command to copy selected text from the ISE into a new Microsoft Word document. You must have Microsoft Word installed. + + + + Copy-ToWord + + Text + + + + String[] + + String[] + + + None + + + Colorized + + + + + SwitchParameter + + + False + + + + + + Colorized + + + + SwitchParameter + + SwitchParameter + + + False + + + Text + + + + String[] + + String[] + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + Edit-CurrentProject + Edit + CurrentProject + + Edit the current project list file + + + + Open the current project list in the PowerShell ISE to view or edit. You will need to manually remove items. The list is simply a text file with full file names to a group of scripts that you might be working on. + The ISEScriptingGeek module uses a built-in variable, $currentProjectList. + + + + Edit-CurrentProject + + List + + + + String + + String + + + None + + + + + + List + + + + String + + String + + + None + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Add-CurrentProject + + + + Import-CurrentProject + + + + + + + Edit-Snippet + Edit + Snippet + + Edit an ISE Snippet + + + + View snippets and edit selected in the PowerShell ISE. Changes won't be effective until the next ISE session or tab. + + + + Edit-Snippet + + Path + + + + String + + String + + + None + + + + + + Path + + + + String + + String + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + Find-InFile + Find + InFile + + Search for text in selected files. + + + + Search for text in selected files. + + + + Find-InFile + + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + Get-ASTProfile + Get + ASTProfile + + Profile a PowerShell script + + + + This script will parse a PowerShell script using the AST to identify elements and any items that might be dangerous. The output is a text report which by default is turned into a help topic stored in your Windows PowerShell folder under Documents, although you can specify an alternate location. + DETAILS The script takes the name of a script to profile. You can specify a ps1 or psm1 filename. Using the AST the script will prepare a text report showing you any script requirements, script parameters, commands and type names. You will see all commands used including those that can't be resolved as well as those that I thought might be considered potentially dangerous such as cmdlets that use the verbs Remove or Stop. + Because some people might invoke methods from .NET classes directly I've also captured all typenames. Most of them will probably be related to parameters but as least you'll know what to look for. + The report won't detail parameters from nested functions but you'll still see what commands they will use. The script uses Get-Command to identify commands which might entail loading a module. Most of the time this shouldn't be an issue but you still might want to profile the script in virtualized or test environment. + Any unresolved command you see is either from a module that couldn't be loaded or it might be an internally defined command. Once you know what to look for you can open the script in your favorite editor and search for the mystery commands. + Note that if the script uses application names like Main or Control for function names, they might be misinterpreted. In that case, search the script for the name, ie "main". + This version will only analyze files with an extension of .ps1, .psm1 or .txt. + + + + Get-ASTProfile + + Path + + The path to the script file. It should have an extension of .ps1, .psm1 or .bat. + + String + + String + + + $(Read-Host "Enter the filename and path to a PowerShell script") + + + FilePath + + The path for the report file. The default is your WindowsPowerShell folder. This parameter has aliases of fp and out. + + String + + String + + + "$env:userprofile\Documents\WindowsPowerShell" + + + + + + Path + + The path to the script file. It should have an extension of .ps1, .psm1 or .bat. + + String + + String + + + $(Read-Host "Enter the filename and path to a PowerShell script") + + + FilePath + + The path for the report file. The default is your WindowsPowerShell folder. This parameter has aliases of fp and out. + + String + + String + + + "$env:userprofile\Documents\WindowsPowerShell" + + + + + + None + + + + + + + + + + Help topic + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + -------------------------- EXAMPLE 1 -------------------------- + PS C:\> Get-ASTProfile c:\download\UnknownScript.ps1 + + This will analyze the script UnknownScript.ps1 and show the results in a help window. It will also create a text file in your Documents\WindowsPowerShell folder called UnknownScript.help.txt. + + + + -------------------------- EXAMPLE 2 -------------------------- + PS C:\> Get-ASTProfile c:\download\UnknownScript.ps1 -filepath c:\work + + This command is the same as the first example except the help file will be created in C:\Work. + + + + + + Get-Command + + + + Get-Alias + + + + + + + Get-CommandMetadata + Get + CommandMetadata + + Create a proxy function of a PowerShell command. + + + + This command will create a proxy version of a PowerShell cmdlet, function or alias. The intent is to simplify creating a new function from command metadata. You can give your command and opt to remove help references for the original command. + If you run this in the PowerShell ISE, code for the new function will be inserted into a new Powershell tab. + + + + Get-CommandMetadata + + Command + + The name of a PowerShell command to proxy. This can be a cmdlet, function or alias. + + String + + String + + + None + + + NewName + + The name you want to use for your new command. + + String + + String + + + None + + + NoHelp + + Remove references to existing command help. Using this parameter will insert a comment-based help outline. + + + SwitchParameter + + + False + + + + + + Command + + The name of a PowerShell command to proxy. This can be a cmdlet, function or alias. + + String + + String + + + None + + + NewName + + The name you want to use for your new command. + + String + + String + + + None + + + NoHelp + + Remove references to existing command help. Using this parameter will insert a comment-based help outline. + + SwitchParameter + + SwitchParameter + + + False + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + This command was first described at http://jdhitsolutions.com/blog/2014/09/friday-fun-creating-powershell-scripts-with-powershell + + + + + -------------------------- EXAMPLE 1 -------------------------- + PS C:\> Get-CommandMetadata Get-WMIObject -nohelp -newname Get-MyOS + + Create a proxy function for Get-WMIObject that will be called Get-MyOS. Help references will be replaced with a comment-help block. + + + + + + Online Version: + http://jdhitsolutions.com/blog/2014/09/friday-fun-creating-powershell-scripts-with-powershell + + + + + + Get-ISEBookmark + Get + ISEBookmark + + Get an ISE Bookmark. + + + + Get an ISE Bookmark + + + + Get-ISEBookmark + + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Online Version: + http://jdhitsolutions.com/blog/2014/09/friday-fun-creating-powershell-scripts-with-powershell + + + + + + Get-NextISETab + Get + NextISETab + + Get the next ISE tab. + + + + Use this command to easily cycle through open tabs in the ISE. + + + + Get-NextISETab + + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Online Version: + http://jdhitsolutions.com/blog/2014/09/friday-fun-creating-powershell-scripts-with-powershell + + + + + + Get-ScriptComments + Get + ScriptComments + + Get comments from a PowerShell script file. + + + + This command will use the AST parser to go through a PowerShell script, either a .ps1 or .psm1 file, and display only the comments. + + + + Get-ScriptComments + + Path + + Enter the path of a PS1 file + + String + + String + + + None + + + + + + Path + + Enter the path of a PS1 file + + String + + String + + + None + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Online Version: + http://jdhitsolutions.com/blog/2014/09/friday-fun-creating-powershell-scripts-with-powershell + + + + + + Get-ScriptingHelp + Get + ScriptingHelp + + Get about scripting help + + + + Use this command to select about_scripting topics using Out-Gridview. + + + + Get-ScriptingHelp + + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Online Version: + http://jdhitsolutions.com/blog/2014/09/friday-fun-creating-powershell-scripts-with-powershell + + + + + + Get-SearchResult + Get + SearchResult + + Search for selected text online + + + + Use this command to search online for the selected text. The default is Google. + + + + Get-SearchResult + + Text + + + + String + + String + + + None + + + SearchEngine + + + + + Bing + Google + Yahoo + + String + + String + + + Google + + + + + + SearchEngine + + + + String + + String + + + Google + + + Text + + + + String + + String + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Online Version: + http://jdhitsolutions.com/blog/2014/09/friday-fun-creating-powershell-scripts-with-powershell + + + + + + Import-CurrentProject + Import + CurrentProject + + Open files from the project list + + + + Read the current project list and open each file in the ISE. The list is simply a text file with full file names to a group of scripts that you might be working on. The ISEScriptingGeek module uses a built-in variable, $currentProjectList. + + + + Import-CurrentProject + + List + + + + String + + String + + + None + + + + + + List + + + + String + + String + + + None + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Add-CurrentProject + + + + Edit-CurrentProject + + + + + + + New-CIMCommand + New + CIMCommand + + Create a command based on a CIM class. + + + + This command starts a graphical wizard process to help you build a new function based on a WMI/CIM class. + + + + New-CIMCommand + + computername + + + + String + + String + + + None + + + + + + computername + + + + String + + String + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + New-CommentHelp + New + CommentHelp + + Auto-generate comment based help. + + + + This will generate comment based help based on a loaded command and insert it into the current file in the ISE. + + + + New-CommentHelp + + Name + + What is the name of your function or command? + + String + + String + + + None + + + Synopsis + + Enter a brief synopsis + + String + + String + + + None + + + Description + + Enter a description. You can expand and edit later + + String + + String + + + None + + + + + + Description + + Enter a description. You can expand and edit later + + String + + String + + + None + + + Name + + What is the name of your function or command? + + String + + String + + + None + + + Synopsis + + Enter a brief synopsis + + String + + String + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + New-DSCResourceSnippet + New + DSCResourceSnippet + + Create ISE snippets for DSC Resources + + + + This command will convert the syntax for a DSC resource into an ISE snippet. Snippets will be created in the default location. Snippet names will take the name "DSC <resource name>". The snippet description uses the format "<Resource Name> resource from module <module name> <vendor>".You will end up with a description like this: + xWinEventLog resource from module xWinEventLog Microsoft Corporation + You must run this command in the PowerShell ISE. + + + + New-DSCResourceSnippet + + Name + + Enter the name of a DSC resource + + String[] + + String[] + + + None + + + Author + + + + String + + String + + + $env:username + + + Passthru + + + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + + New-DSCResourceSnippet + + DSCResource + + Enter the name of a DSC resource + + DscResourceInfo[] + + DscResourceInfo[] + + + None + + + Author + + + + String + + String + + + $env:username + + + Passthru + + + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + + + + Name + + Enter the name of a DSC resource + + String[] + + String[] + + + None + + + DSCResource + + Enter the name of a DSC resource + + DscResourceInfo[] + + DscResourceInfo[] + + + None + + + Author + + + + String + + String + + + $env:username + + + Passthru + + + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + -------------------------- EXAMPLE 1 -------------------------- + PS C:\> New-DSCResourceSnippet -name xsmbshare -author "Jeff Hicks" -passthru + +Directory: C:\Users\Jeff\documents\WindowsPowerShell\Snippets + + +Mode LastWriteTime Length Name +---- ------------- ------ ---- +-a--- 10/20/2014 8:48 AM 1157 DSC xSmbShare Resource.snippets.ps1xml + + Create a snippet from a single resource. + + + + -------------------------- EXAMPLE 2 -------------------------- + PS C:\> Get-DSCResource | New-DSCResourceSnippet + + This command will create snippets for every installed DSC resource. Existing snippet files will be overwritten. + + + + + + Get-DSCResource + + + + New-ISESnippet + + + + + + + New-FileHere + New + FileHere + + Create a new file in the current path. + + + + When you create a new file, the ISE wants to create it in the directory you were in when you started the ISE. I often want to create a new file in the current location. This command has no parameters. You will be prompted for a new file name if you don't specify one. + + + + New-FileHere + + Name + + Enter the name of the new file. If you don't specify one you will be prompted. + + String + + String + + + (New-Inputbox -Prompt "Enter a file name" -Title "New File" -Default "MyUntitled.ps1") + + + Open + + + + + SwitchParameter + + + False + + + Passthru + + + + + SwitchParameter + + + False + + + + + + Name + + Enter the name of the new file. If you don't specify one you will be prompted. + + String + + String + + + (New-Inputbox -Prompt "Enter a file name" -Title "New File" -Default "MyUntitled.ps1") + + + Open + + + + SwitchParameter + + SwitchParameter + + + False + + + Passthru + + + + SwitchParameter + + SwitchParameter + + + False + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + New-Function + New + Function + + Insert a function outline + + + + Use this command to insert a function outline. This is very similar to using the function snippet. + + + + New-Function + + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + + + New-Inputbox + New + Inputbox + + Display a Visual Basic style inputbox. + + + + This function will display a graphical Inputbox, like the one from VisualBasic and VBScript. You must specify a messag prompt. You can specify a title, the default is "Input". You can also specify a default value. The inputbox will write whatever is entered into it to the pipeline. If you click Cancel the inputbox will still write a string to the pipeline with a length of 0. It is recommended that you validate input. + + + + New-Inputbox + + Prompt + + Enter a message prompt + + String + + String + + + None + + + Title + + + + String + + String + + + Input + + + Default + + + + String + + String + + + None + + + + + + Prompt + + Enter a message prompt + + String + + String + + + None + + + Title + + + + String + + String + + + Input + + + Default + + + + String + + String + + + None + + + + + + None + + + + + + + + + + [string] + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + -------------------------- EXAMPLE 1 -------------------------- + PS C:\> $c = New-Inputbox -prompt "Enter the Netbios name of a domain computer." -title "Enter a computername" -default $env:computername +PS C:\> get-service -computer $c + + + + + + + + + + New-PSCommand + New + PSCommand + + Create an advanced function outline + + + + This command will create the outline of an advanced function based on a hash table of new parameter values. You will still need to flesh out the function and insert the actual commands. + You might need to tweak parameters in the resulting code for items such a default value, help message, parameter aliases and validation. + The New-PSCommand command takes a lot of the grunt work out of the scripting process so you can focus on the actual working part of the function. + + + + New-PSCommand + + Name + + The name of the new function + + String + + String + + + None + + + NewParameters + + A hash table of new parameter values. The key should be the parameter name. The entry value should be the object type. You can also indicate if it should be an array by using [] with the object type. Here's an example: + @{Name="string[]";Test="switch";Path="string"} + Or you can use an "advanced" version of the hash table to specify optional parameter attributes that follows the format: + @{ParamName="type[]",Mandatory,ValuefromPipeline,ValuefromPipelinebyPropertyName,Position} + Here's an example: + $h = @{Name="string[]",$True,$True,$False,0; Path="string",$false,$false,$false,1; Size="int",$false,$false,$true; Recurse="switch" } + You can also specify an ordered hash table if you are running PowerShell v or later. + + Object + + Object + + + None + + + Synopsis + + Provide a brief synopsis of your command. + + String + + String + + + None + + + Description + + Provide a description for your command. You can always add and edit this later. + + String + + String + + + None + + + BeginCode + + A block of code to insert in the Begin scriptblock. This can be either a scriptblock or a string. + + String + + String + + + None + + + ProcessCode + + A block of code to insert at the start of the Process scriptblock. This can be either a scriptblock or a string. + + String + + String + + + None + + + EndCode + + A block of code to insert at the start of the End scriptblock. This can be either a scriptblock or a string. + + String + + String + + + None + + + ShouldProcess + + Set SupportsShouldProcess to True in the new function. + + + SwitchParameter + + + False + + + UseISE + + If you are running this command in the ISE, send the new function to the editor as a new file. + + + SwitchParameter + + + False + + + + + + Name + + The name of the new function + + String + + String + + + None + + + NewParameters + + A hash table of new parameter values. The key should be the parameter name. The entry value should be the object type. You can also indicate if it should be an array by using [] with the object type. Here's an example: + @{Name="string[]";Test="switch";Path="string"} + Or you can use an "advanced" version of the hash table to specify optional parameter attributes that follows the format: + @{ParamName="type[]",Mandatory,ValuefromPipeline,ValuefromPipelinebyPropertyName,Position} + Here's an example: + $h = @{Name="string[]",$True,$True,$False,0; Path="string",$false,$false,$false,1; Size="int",$false,$false,$true; Recurse="switch" } + You can also specify an ordered hash table if you are running PowerShell v or later. + + Object + + Object + + + None + + + ShouldProcess + + Set SupportsShouldProcess to True in the new function. + + SwitchParameter + + SwitchParameter + + + False + + + Synopsis + + Provide a brief synopsis of your command. + + String + + String + + + None + + + Description + + Provide a description for your command. You can always add and edit this later. + + String + + String + + + None + + + BeginCode + + A block of code to insert in the Begin scriptblock. This can be either a scriptblock or a string. + + String + + String + + + None + + + ProcessCode + + A block of code to insert at the start of the Process scriptblock. This can be either a scriptblock or a string. + + String + + String + + + None + + + EndCode + + A block of code to insert at the start of the End scriptblock. This can be either a scriptblock or a string. + + String + + String + + + None + + + UseISE + + If you are running this command in the ISE, send the new function to the editor as a new file. + + SwitchParameter + + SwitchParameter + + + False + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + This command was described at http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command + + + + + -------------------------- EXAMPLE 1 -------------------------- + PS C:\> $paramhash=@{Name="string[]";Test="switch";Path="string"} +PS C:\> New-PSCommand -name "Set-MyScript" -Newparameters $paramhash | out-file "c:\scripts\set-myscript.ps1" + + Create an advanced script outline for Set-MyScript with parameters of Name, Test and Path. Results are saved to a file. + + + + -------------------------- EXAMPLE 2 -------------------------- + PS C:\> $hash = [ordered]@{Name="string[]",$True,$True,$False,0;Path="string",$false,$false,$false,1;Size="int",$false,$false,$true;Recurse="switch"} + +PS C:\> $begin={ +#initialize some variables +$arr=@() +$a=$True +$b=123 +} +PS C:\> $end="write-host 'Finished' -foreground Green" +PS C:\> $synopsis = "Get user data" +PS C:\> $desc = @" +This command will do something really amazing. +All you need to do is provide +the right amount of pixie dust and shavings from a unicorn horn. + +This requires PowerShell v4 and a full moon. +"@ + +PS C:\> New-PSCommand -Name Get-UserData -NewParameters $hash -BeginCode $begin -EndCode $end -Synopsis $synopsis -Description $desc -useise + + Create an advanced function from the ordered hash table. This expression will also insert extra code into the Begin and End scriptblocks as well as enter text for the help synopsis and description. The new command will be opened in the ISE. + + + + + + Online Version: + http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command + + + + + + Open-ISEBookmark + Open + ISEBookmark + + Open an ISE bookmark. + + + + Open an ISE bookmark. + + + + Open-ISEBookmark + + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Online Version: + http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command + + + + + + Open-SelectedISE + Open + SelectedISE + + Open selected file in an ISE tab + + + + Open selected file in a PowerShell ISE tab. You can use this to open dot sourced files in a script or profile. Select the entire path and use this command or it's shortcut to open the file. + + + + Open-SelectedISE + + Text + + + + String + + String + + + None + + + + + + Text + + + + String + + String + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Online Version: + http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command + + + + + + Out-ISETab + Out + ISETab + + Send command output to an ISE tab + + + + This command will accept pipelined input and place it in a new PowerShell ISE tab. + + + + Out-ISETab + + InputObject + + + + Object[] + + Object[] + + + None + + + UseCurrentFile + + Insert the text into the current ISE tab. + + + SwitchParameter + + + False + + + + + + InputObject + + + + Object[] + + Object[] + + + None + + + UseCurrentFile + + Insert the text into the current ISE tab. + + SwitchParameter + + SwitchParameter + + + False + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + -------------------------- EXAMPLE 1 -------------------------- + PS C:\> get-process | sort WS -descending | Select -first 5 | out-isetab + + + + + + + + Online Version: + http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command + + + + + + Remove-ISEBookmark + Remove + ISEBookmark + + Delete an ISE bookmark. + + + + Delete an ISE bookmark. + + + + Remove-ISEBookmark + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Online Version: + http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command + + + + + + Reset-ISEFile + Reset + ISEFile + + Reload a file in the PowerShell ISE + + + + This command will reload an file in the ISE that might have been modified outside of the ISE. + + + + Reset-ISEFile + + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Online Version: + http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command + + + + + + Send-ToPrinter + Send + ToPrinter + + Print the current file in the ISE. + + + + This function is intended to be used in the ISE to print the current script file to the default printer. + + + + Send-ToPrinter + + path + + + + String + + String + + + None + + + + + + path + + + + String + + String + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Online Version: + http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command + + + + + + Set-ScriptLocation + Set + ScriptLocation + + Set location to current script folder. + + + + Use this command to change location to match that of the current script in the PowerShell ISE. + + + + Set-ScriptLocation + + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Online Version: + http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command + + + + + + Start-MyScript + Start + MyScript + + Launch the current script file + + + + Use this command to launch the current script file with Show-Command. Fill in the form to run the script. + + + + Start-MyScript + + Path + + + + String + + String + + + None + + + + + + Path + + + + String + + String + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Online Version: + http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command + + + + + + Update-ISEBookmark + Update + ISEBookmark + + Update an ISE Bookmark. + + + + Update an ISE Bookmark. + + + + Update-ISEBookmark + + Bookmark + + + + Object + + Object + + + None + + + + + + Bookmark + + + + Object + + Object + + + None + + + + + + System.Object + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Online Version: + http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command + + + + + + Write-Signature + Write + Signature + + Sign a script with verified certificate. + + + + Use this command to easily sign a script file with a valid code signing certificate. + + + + Write-Signature + + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ + + + + + + Online Version: + http://jdhitsolutions.com/blog/2012/12/create-powershell-scripts-with-a-single-command + + + + \ No newline at end of file diff --git a/en-us/about_ScriptingHelp.help.txt b/en-us/about_ScriptingHelp.help.txt new file mode 100644 index 0000000..13fb3e3 Binary files /dev/null and b/en-us/about_ScriptingHelp.help.txt differ diff --git a/en-us/about_Scripting_Best_Practices.help.txt b/en-us/about_Scripting_Best_Practices.help.txt new file mode 100644 index 0000000..74016db Binary files /dev/null and b/en-us/about_Scripting_Best_Practices.help.txt differ diff --git a/en-us/about_Scripting_Try_Catch.help.txt b/en-us/about_Scripting_Try_Catch.help.txt new file mode 100644 index 0000000..f57794a Binary files /dev/null and b/en-us/about_Scripting_Try_Catch.help.txt differ diff --git a/en-us/about_Scripting_ValidateCount.help.txt b/en-us/about_Scripting_ValidateCount.help.txt new file mode 100644 index 0000000..133547b Binary files /dev/null and b/en-us/about_Scripting_ValidateCount.help.txt differ diff --git a/en-us/about_Scripting_ValidateLength.help.txt b/en-us/about_Scripting_ValidateLength.help.txt new file mode 100644 index 0000000..85a841c Binary files /dev/null and b/en-us/about_Scripting_ValidateLength.help.txt differ diff --git a/en-us/about_Scripting_ValidateNotNullorEmpty.help.txt b/en-us/about_Scripting_ValidateNotNullorEmpty.help.txt new file mode 100644 index 0000000..10656d1 Binary files /dev/null and b/en-us/about_Scripting_ValidateNotNullorEmpty.help.txt differ diff --git a/en-us/about_Scripting_ValidatePattern.help.txt b/en-us/about_Scripting_ValidatePattern.help.txt new file mode 100644 index 0000000..102705d Binary files /dev/null and b/en-us/about_Scripting_ValidatePattern.help.txt differ diff --git a/en-us/about_Scripting_ValidateRange.help.txt b/en-us/about_Scripting_ValidateRange.help.txt new file mode 100644 index 0000000..a3eebf0 Binary files /dev/null and b/en-us/about_Scripting_ValidateRange.help.txt differ diff --git a/en-us/about_Scripting_ValidateScript.help.txt b/en-us/about_Scripting_ValidateScript.help.txt new file mode 100644 index 0000000..3496e56 Binary files /dev/null and b/en-us/about_Scripting_ValidateScript.help.txt differ diff --git a/en-us/about_Scripting_ValidateSet.help.txt b/en-us/about_Scripting_ValidateSet.help.txt new file mode 100644 index 0000000..61f5577 Binary files /dev/null and b/en-us/about_Scripting_ValidateSet.help.txt differ diff --git a/functions/Bookmarks.ps1 b/functions/Bookmarks.ps1 new file mode 100644 index 0000000..51a65af --- /dev/null +++ b/functions/Bookmarks.ps1 @@ -0,0 +1,117 @@ + +#create a script bookmarking system for the PowerShell ISE + +Function Get-ISEBookmark { + [cmdletbinding()] + Param() + + Write-Verbose "Importing bookmarks from $MyBookmarks" + Try { + Import-CSV $MyBookmarks -ErrorAction Stop | + Out-GridView -Title "My ISE Bookmarks" -OutputMode Single + } + Catch { + Write-Warning "Failed to find or import bookmarks from $($MyBookmarks). Does file exist?" + } +} #close Get-ISEBookmark + +Function Open-ISEBookmark { + [cmdletbinding()] + Param() + + $bookmark = Get-ISEBookmark + + if ($bookmark) { + Write-Verbose "Processing bookmark $($bookmark.name) for $($bookmark.path)" + + #open the file + psedit $bookmark.path + + #find the file in the collection of open files + $search = $psise.CurrentPowerShellTab.files.where( {$_.fullpath -eq $bookmark.path}) + + #make the file the currently selected + $psise.CurrentPowerShellTab.files.SelectedFile = $search[0] + + #jump to the bookmark location + Write-Verbose "Jumping to line $($Bookmark.LineNumber)" + $search[0].editor.SetCaretPosition($bookmark.LineNumber, 1) + } #if bookmark + +} #close Open-ISEBookmark + +Function Remove-ISEBookmark { + [cmdletbinding(SupportsShouldProcess)] + Param() + + $bookmark = Get-ISEBookmark + + if ($bookmark) { + Write-Verbose "Processing bookmark $($bookmark.name) for $($bookmark.path)" + $save = Import-CSV -Path $MyBookmarks | where {$_.id -notmatch $bookmark.id} + Write-Verbose "Updating $MyBookmarks" + $save | Export-Csv -Path $MyBookmarks -Encoding ASCII + + } #if bookmark + +} #close Remove-ISEBookmark + +Function Update-ISEBookmark { + [cmdletbinding()] + Param( + [Parameter(Position = 0, ValueFromPipeline)] + [object]$Bookmark + ) + + $bookmark = Get-ISEBookmark + + if ($bookmark) { + Write-Verbose "Processing bookmark $($bookmark.name) for $($bookmark.path)" + $line = New-Inputbox -Prompt "Enter the line number" -Title $MyInvocation.MyCommand -Default $Bookmark.LineNumber + if ($line) { + $name = New-Inputbox -Prompt "Enter the name" -Title $MyInvocation.MyCommand -Default $Bookmark.name + } + else { + #nothing entered so bail out + Write-Verbose "Cancelling" + Return + } + + If ($name) { + + #get all bookmarks + $all = Get-content -Path $MyBookmarks | ConvertFrom-Csv + + #get matching bookmark by ID from CSV file + $bmk = $all.where( {$_.id -eq $bookmark.id}) + + #update the entry + $bmk[0].Linenumber = $line + $bmk[0].name = $name + + #save the results back to the file + $all | Export-Csv -Path $MyBookmarks + } + else { + #cancelling + Write-Verbose "Cancelling" + } + } #close if bookmark + +} #close Update-ISEBookmark + +Function Add-ISEBookmark { + + $line = $psise.CurrentFile.Editor.CaretLine + $path = $psise.CurrentFile.FullPath + $name = New-Inputbox -Prompt "Enter a name or description for this bookmark." -Title "Add ISE Bookmark" + + $obj = [pscustomobject]@{ + ID = [guid]::NewGuid().guid + LineNumber = $line + Name = $name + Path = $Path + } + $obj | Export-Csv -Path $MyBookmarks -Append -Encoding ASCII + +} #close Add-ISEBookmark diff --git a/functions/CIMScriptMaker.ps1 b/functions/CIMScriptMaker.ps1 new file mode 100644 index 0000000..20e8963 --- /dev/null +++ b/functions/CIMScriptMaker.ps1 @@ -0,0 +1,203 @@ + + +Function New-CIMCommand { + Param([string]$computername = $env:COMPUTERNAME) + + Function Get-Namespace { + #this function will recursively enumerate namespaces + + Param( + [string]$Namespace = "Root", + [Microsoft.Management.Infrastructure.CimSession]$CimSession + ) + + $nspaces = $cimsession | Get-CimInstance -Namespace $Namespace -ClassName __Namespace + foreach ($nspace in $nspaces) { + + $child = Join-Path -Path $Namespace -ChildPath $nspace.Name + $child + Get-Namespace $child $CimSession + } + } + + #create a CIMSession + $cimsess = New-CimSession -ComputerName $computername + + #browse namespaces + Write-Host "Enumerating namspaces on $computername....please wait..." -ForegroundColor Cyan + $ns = Get-Namespace -CimSession $cimsess | Sort-Object | + Out-GridView -Title "$($cimsess.Computername): Select a namespace" -OutputMode Single + + if ($ns) { + #get classes filtering out system classes + Write-Host "Enumerating classes...please wait..." -ForegroundColor Cyan + $class = $cimsess | Get-CimClass -Namespace $ns | + Where-Object {$_.cimclassname -notmatch "^__" -AND $_.CimClassProperties.Name -notcontains "Antecedent"} | + Sort-Object CimClassName | Select-Object CimClassName, CimClassProperties | + Out-GridView -Title "$NS : Select a class name" -OutputMode Single + } + + if ($class) { + + #create a VBScript message box + $wshell = New-Object -ComObject "Wscript.Shell" + $r = $wshell.Popup("Do you want to test this class?", -1, $class.CimClassname, 32 + 4) + + if ($r -eq 6) { + #Yes + $test = $cimsess | Get-CimInstance -Namespace $ns -ClassName $class.CimClassName + if ($test) { + $test | Out-GridView -Title "$NS\$($Class.cimClassName)" -Wait + $prompt = "Do you want to continue?" + $icon = 32 + 4 + } + else { + $prompt = "No results were returned. Do you want to continue?" + $icon = 16 + 4 + } + + $r = $wshell.Popup($prompt, -1, $class.CimClassname, $icon) + if ($r -eq 7) { + Write-Host "Exiting. Please try again later." -ForegroundColor Yellow + #bail out + Return + } + + } #if r = 6 + + #define basic command + $cmd = "Get-CimInstance @cimParam" + + #create a filter + $filterProperty = $class.CimClassProperties | Select-Object Name, CimType, Flags | + Out-GridView -Title "Select a property to filter on or cancel to not filter." -OutputMode Single + + if ($filterProperty) { + $operator = "=", "<", ">", "<>", ">=", "<=", "like" | + Out-GridView -Title "Select an operator. Default if you cancel is =" -OutputMode Single + + #create a VBSCript inputbox + Add-Type -AssemblyName "microsoft.visualbasic" -ErrorAction Stop + $Prompt = "Enter a value for your filter. If using a string, wrap the value in ''. If using Like, use % as the wildcard character." + $title = "-filter ""$($filterproperty.Name) $operator ?""" + $value = [microsoft.visualbasic.interaction]::InputBox($Prompt, $Title) + + $filter = "-filter ""$($filterproperty.Name) $operator $value""" + + $cmd += " $filter" + } #if filterproperty + + #show properties + Write-Host "Getting class properties" -ForegroundColor Cyan + $properties = $class.CimClassProperties | Select-Object Name, CimType, Flags | + Out-Gridview -Title "$($class.CimClassName) : Select one or more properties. Cancel will select *" -PassThru + + if ($properties) { + $select = $properties.name -join "," + $cmd += @" + | + Select-Object -property $select,PSComputername +"@ + } #if properties + + } #if $class + + #define a name for the function using the class name + #remove _ from class name + $cname = $class.CimClassName.Replace("_", "") + $cmdName = "Get-$cname" + + #the auto-generated PowerShell code + $myScript = @" +#Requires -version 3.0 + +Function $cmdName { +<# +.Synopsis +Get $($Class.CimClassName) information +.Description +This command uses the CIM cmdlets to query a remote computer for information from the $($Class.CimClassName) class in the $NS namespace. +This command requires PowerShell 3.0 or later. +.Parameter Computername +The name of a computer to query. It should be running PowerShell 3.0 or later. +This parameter also supports aliases of CN and Host. +.Parameter CimSession +A previously created CimSession. Works best when you pipe the CimSession +to this command. See examples. +.Example +PS C:\> $cmdName + +Run the command defaulting to the local computername. +.Example +PS C:\> Get-CimSession | $cmdName | Out-Gridview -title $cmdName + +Get all CIMSessions and pipe them to this command sending results to Out-Gridview. +.Notes +Version : 1.0 +Author : $($env:userdomain)\$($env:username) +Last Updated: $((Get-Date).ToShortDateString()) +.Inputs +String or CimSession +.Outputs +CIMObject or custom object +.Link +Get-CimInstance +Get-CimSession +#> + +[cmdletbinding(DefaultParameterSetName="Computer")] +Param( +[Parameter(Position=0,ValueFromPipelinebyPropertyName=`$True, +ParameterSetName="Computer")] +[ValidateNotNullorEmpty()] +[Alias("CN","Host")] +[string[]]`$Computername=`$env:Computername, + +[Parameter(Position=0,ValueFromPipeline=`$True, +ParameterSetName="Session")] +[string[]]`$CimSession + +) + +Begin { + Write-Verbose "Starting command `$(`$MyInvocation.Mycommand)" + #create a hashtable of parameters to splat against Get-CimInstance + `$cimParam=@{ + Namespace = "$NS" + ClassName = "$($Class.CimClassName) " + ErrorAction = "Stop" + } +} #begin + +Process { + if (`$computername) { + `$cimParam.Computername=`$computername + Write-Verbose "Processing `$Computername" + } + else { + #must be a cimsession + `$cimParam.CIMSession=`$CimSession + Write-Verbose "Processing `$(`$CimSession.ComputerName)" + } + + Try { + $cmd + } #try + Catch { + Write-Warning "Failed to retrieve information. `$(`$_.Exception.Message)" + } #catch +} #Process + +End { + Write-Verbose "Ending command `$(`$MyInvocation.Mycommand)" +} #end + +} #end function +"@ + + $myScript | Out-ISETab + + #remove the cimsession + $cimsess | Remove-CimSession + +} #end function \ No newline at end of file diff --git a/functions/CloseAllFiles.ps1 b/functions/CloseAllFiles.ps1 new file mode 100644 index 0000000..2c94368 --- /dev/null +++ b/functions/CloseAllFiles.ps1 @@ -0,0 +1,28 @@ + + +#close all saved files in the ISE + +Function CloseAllFiles { + [cmdletbinding()] + Param() + + $saved = $psISE.CurrentPowerShellTab.Files.Where( {$_.isSaved}) + foreach ($file in $saved) { + write-Verbose "closing $($file.FullPath)" + [void]$psISE.CurrentPowerShellTab.files.Remove($file) + } + +} #end function + +#close all other saved files except for the active file +Function CloseAllFilesButCurrent { + [cmdletbinding()] + Param() + + $saved = $psISE.CurrentPowerShellTab.Files.Where( {$_.isSaved -AND $_.fullpath -ne $psISE.CurrentFile.FullPath }) + foreach ($file in $saved) { + write-Verbose "closing $($file.FullPath)" + [void]$psISE.CurrentPowerShellTab.files.Remove($file) + } + +} #end function \ No newline at end of file diff --git a/functions/Convert-AliasDefinition.ps1 b/functions/Convert-AliasDefinition.ps1 new file mode 100644 index 0000000..8c78e4b --- /dev/null +++ b/functions/Convert-AliasDefinition.ps1 @@ -0,0 +1,64 @@ + + +Function Convert-AliasDefinition { + + [cmdletBinding(DefaultParameterSetName = "ToDefinition")] + + Param( + [Parameter(Position = 0, Mandatory = $True, HelpMessage = "Enter a string to convert")] + [string]$Text, + [Parameter(ParameterSetName = "ToAlias")] + [switch]$ToAlias, + [Parameter(ParameterSetName = "ToDefinition")] + [switch]$ToDefinition + ) + + #make sure we are using the ISE + if ($host.name -match "ISE") { + Try { + #get alias if it exists otherwise throw an exception that + #will be caught + if ($ToAlias) { + #get alias by definition and convert to name + $alias = get-alias -definition $Text -ErrorAction Stop + #there might be multiples so use the first one found + if ($alias -is [array]) { + $replace = $alias[0].name + } + else { + $replace = $alias.name + } + } + else { + #get alias by name and convert to definition + + #if the text is ?, this is a special character so + #we'll just assume it is Where-Object + if ($Text -eq "?") { + $Replace = "Where-Object" + } + else { + $alias = Get-Alias -name $Text -ErrorAction Stop + $replace = $alias.definition + } + } #Else ToDefinition + + } #close Try + + Catch { + Write-Host "Nothing for for $text" -ForegroundColor Cyan + } + + #make changes if an alias was found + If ($replace) { + #Insert the replacment + $psise.currentfile.editor.insertText($replace) + } + + } #if ISE + else { + Write-Warning "You must be using the PowerShell ISE" + } + +} #end function + diff --git a/functions/Convert-CodetoSnippet.ps1 b/functions/Convert-CodetoSnippet.ps1 new file mode 100644 index 0000000..0244e7e --- /dev/null +++ b/functions/Convert-CodetoSnippet.ps1 @@ -0,0 +1,50 @@ + + +Function Convert-CodetoSnippet { + [cmdletbinding(SupportsShouldProcess)] + [alias("ccs")] + + Param( + [Parameter(Position = 0, Mandatory = $True, + HelpMessage = "Enter some code text or break, select text in the ISE and try again.")] + [ValidateNotNullorEmpty()] + [string]$Text + ) + + Add-Type -AssemblyName "Microsoft.VisualBasic" + + $title = [Microsoft.VisualBasic.Interaction]::InputBox("Enter a title for your snippet", $MyInvocation.mycommand.name) + + if ($title) { + $description = [Microsoft.VisualBasic.Interaction]::InputBox("Enter a description for your snippet", $MyInvocation.mycommand.name, "This is required") + if ($description) { + $author = [Microsoft.VisualBasic.Interaction]::InputBox("Enter an author for your snippet", $MyInvocation.mycommand.name, $env:username) + if (!$author) { + $author = " " + } #if author + } #if description + else { + #if no description assume user cancelled + Write-Warning -Message "No description was specified. Operation cancelled." + Return + } + + if ($PSCmdlet.ShouldProcess($title) ) { + Try { + New-IseSnippet -Title $title -Text $Text -description $Description -author $Author + } + Catch { + $message = ("There was an error creating the snippet. `n`n{0} `n`nDo you want to force an overwrite?" -f $_.exception.message) + $returnValue = [microsoft.visualbasic.interaction]::Msgbox($message, "YesNo,Exclamation", $MyInvocation.MyCommand.name) + if ($returnValue -eq "yes") { + #re-run the command but this time with -Force + New-IseSnippet -Title $title -Text $Text -description $Description -author $Author -Force + } + } + } #shouldprocess + } + +} #end Convert-CodeToSnippet + + + diff --git a/functions/Convert-CommandToHash.ps1 b/functions/Convert-CommandToHash.ps1 new file mode 100644 index 0000000..f448171 --- /dev/null +++ b/functions/Convert-CommandToHash.ps1 @@ -0,0 +1,94 @@ + +#Convert the named parameter part of a command into a hash table in the ISE + +Function Convert-CommandtoHash { + [cmdletbinding()] + Param( + [ValidateNotNullorEmpty()] + [string]$Text = $psise.currentfile.editor.SelectedText + ) + + Set-StrictMode -Version latest + + New-Variable astTokens -force + New-Variable astErr -force + + Write-verbose "Converting $text" + + $ast = [System.Management.Automation.Language.Parser]::ParseInput($Text, [ref]$astTokens, [ref]$astErr) + + #resolve the command name + $cmdType = Get-Command $asttokens[0].text + if ($cmdType.CommandType -eq 'Alias') { + $cmd = $cmdType.ResolvedCommandName + } + else { + $cmd = $cmdType.Name + } + + Write-Verbose "Command is $cmd" + Write-Verbose ($astTokens | out-string) + + #last item is end of input token + + $r = for ($i = 1; $i -lt $astTokens.count - 2 ; $i++) { + if ($astTokens[$i].ParameterName) { + $p = $astTokens[$i].ParameterName + write-verbose "Parameter name = $p" + write-verbose ($astTokens[$i] | out-string) + $v = "" + #check next token + if ($astTokens[$i + 1].Kind -match 'Parameter|NewLine|EndOfInput') { + #the parameter must be a switch + $v = "`$True" + } + else { + While ($astTokens[$i + 1].Kind -notmatch 'Parameter|NewLine|EndOfInput') { + #break out of loop if there is no text + write-verbose "While: $($astTokens[$i])" + $i++ + #test if value is a string and if it is quoted, if not include quotes + if ($astTokens[$i].Text -match "\D" -AND $astTokens[$i].Text -notmatch """\w+.*""" -AND $astTokens[$i].Text -notmatch "'\w+.*'") { + #ignore commas and variables + if ($astTokens[$i].Kind -match 'Comma|Variable') { + $value = $astTokens[$i].Text + } + else { + #Assume text and quote it + Write-Verbose "Quoting $($astTokens[$i].Text)" + $value = "'$($astTokens[$i].Text)'" + } + } + else { + Write-Verbose "Using text as is for $($astTokens[$i].Text)" + $value = $astTokens[$i].Text + } + + Write-Verbose "Adding $Value to `$v" + $v += $value + } + } #while + + "$p = $v`r" + Write-Verbose "hashentry -> $p = $v`r" + } + + } #for + + Write-Verbose "Finished processing AST" + Write-verbose ($r | out-string) + + #create text + $hashtext = @" +`$paramHash = @{ + $r} + +$cmd @paramHash +"@ + + #insert the text which should replace the highlighted line + $psise.CurrentFile.Editor.InsertText($hashtext) + +} + + diff --git a/functions/Convert-ISEComment.ps1 b/functions/Convert-ISEComment.ps1 new file mode 100644 index 0000000..12dc87b --- /dev/null +++ b/functions/Convert-ISEComment.ps1 @@ -0,0 +1,53 @@ + +#convert selected text into a multi-line comment + +Function ConvertTo-MultiLineComment { + [cmdletbinding()] + Param([string]$Text = $psise.CurrentFile.Editor.SelectedText) + + if ($text -match "^<#" -AND $text -match "#>$") { + Write-Warning "Selected text already appears to be a multiline comment" + } + elseif ($text -match "^#") { + #strip off # in text + $text = $text.Replace("#", "") + $replace = "<#`n$text`n#>" + + } + else { + $replace = @" +<# +$Text +#> +"@ + + } #else + + if ($replace) { + $psise.currentfile.editor.InsertText($replace) + } +} #end function + +Function ConvertFrom-MultiLineComment { + [cmdletbinding()] + Param([string]$Text = $psise.CurrentFile.Editor.SelectedText) + + #trim off leading and trailing spaces + $MyText = $Text.Trim() + + if ($MyText.StartsWith("<#") -AND $MyText.EndsWith("#>")) { + #get everything between the first 2 and last 2 characters + $replace = $myText.Substring(2, $MyText.length - 4) + + #insert a #character + [string[]]$newText = $replace.split("`n") | + select -Skip 1 -First ($MyText.Split("`n").count - 2) | foreach {("#$_").Trim()} + $psise.currentfile.editor.InsertText(($newtext.trim() | out-string)) + } + else { + Write-Warning "Could not detect that selected text is a multiline comment" + } + +} #end function + + diff --git a/functions/ConvertAll.ps1 b/functions/ConvertAll.ps1 new file mode 100644 index 0000000..082dd41 Binary files /dev/null and b/functions/ConvertAll.ps1 differ diff --git a/functions/ConvertFrom-Alias.ps1 b/functions/ConvertFrom-Alias.ps1 new file mode 100644 index 0000000..5b50c84 --- /dev/null +++ b/functions/ConvertFrom-Alias.ps1 @@ -0,0 +1,59 @@ + + +Function ConvertFrom-Alias { + + Param ( + [Parameter(Position = 0)] + [ValidateNotNullorEmpty()] + $Text = $psISE.CurrentFile.Editor.text + ) + + #make sure we are using the ISE + if ($host.name -match "ISE") { + + #Turn the script into syntax tokens + Write-Verbose "Tokenizing" + + #verify there are no syntax errors first by Tokenizing the script + $out = $null + $tokens = [System.Management.Automation.PSparser]::Tokenize($text, [ref]$out) + + #if there are errors they will be directed to $out + if ($out) { + #enumerate each parsing error in $out + foreach ($problem in $out) { + Write-Warning $problem.message + Write-Warning "Line: $($problem.Token.Startline) at character: $($problem.token.StartColumn)" + } + } + else { + #if no errors then proceed to convert + $tokens | Where-Object { $_.Type -eq 'Command'} | + Sort-Object StartLine, StartColumn -Descending | + ForEach-Object { + #handle the ? by escaping it + if ($_.content -eq '?') { + Write-Verbose "Found a ?" + $result = Get-Command -name '`?' -CommandType Alias + } + else { + $result = Get-Command -name $_.Content -CommandType Alias -ErrorAction SilentlyContinue + } + + #check and see if Get-Command returned anything + if ($result) { + #find each command and insert the corresponding command definition + Write-Verbose "Replacing $($result.name) with $($result.definition)" + $psISE.CurrentFile.Editor.Select($_.StartLine, $_.StartColumn, $_.EndLine, $_.EndColumn) + $psISE.CurrentFile.Editor.InsertText($result.Definition) + } + } #foreach + } #else $tokens exists and there were no parsing errors + } #if ISE + else { + Write-Warning "You must be using the PowerShell ISE" + } + + Write-Verbose "Finished" + +} #end Function diff --git a/functions/ConvertTo-CommentHelp.ps1 b/functions/ConvertTo-CommentHelp.ps1 new file mode 100644 index 0000000..7735872 --- /dev/null +++ b/functions/ConvertTo-CommentHelp.ps1 @@ -0,0 +1,61 @@ + + +Function ConvertTo-CommentHelp { + [cmdletbinding()] + Param() + + Add-Type -AssemblyName "microsoft.visualbasic" -ErrorAction Stop + $Prompt = "Enter the name of a cmdlet. Leave blank to cancel" + $Default = "" + $Title = $MyInvocation.MyCommand.Name + [string]$command = [microsoft.visualbasic.interaction]::InputBox($Prompt, $Title, $Default) + + if ($command) { + Try { + + $help = get-help -Name $command -full -errorAction Stop + } + Catch { + Throw $_ + #bail out + Return + } + } + Else { + #cancelled + } + + If ($help) { + $myHelp = @" +<# +.Synopsis +$($help.Synopsis) +.Description +$($help.description.Text) +$(foreach ($param in $help.parameters.parameter) { +".Parameter $($param.name)`n" +"$($param.Description.Text)" +"`n" +}) +.Inputs +$(($help.inputTypes | out-string).trim()) +.Outputs +$(($help.returnValues | out-string).trim()) +.Notes +$($help.alertSet.alert | foreach {"$($_.text)`n"}) +$(foreach ($item in $help.examples.example) { +".Example`n" + $($item.code) + "`n" + $(($item.remarks| out-string).trimEnd()) + "`n" +}) +.Link +$(($help.relatedLinks | out-string).Trim()) +#> +"@ + + $myHelp | Out-ISETab + } #if $help + +} \ No newline at end of file diff --git a/functions/ConvertTo-TextFile.ps1 b/functions/ConvertTo-TextFile.ps1 new file mode 100644 index 0000000..e1d80b0 Binary files /dev/null and b/functions/ConvertTo-TextFile.ps1 differ diff --git a/functions/Copy-ToWord.ps1 b/functions/Copy-ToWord.ps1 new file mode 100644 index 0000000..c148188 --- /dev/null +++ b/functions/Copy-ToWord.ps1 @@ -0,0 +1,56 @@ + +#this is an ISE only function +#copy selected ISE text to Microsoft Word + +Function Copy-ToWord { + [cmdletbinding()] + Param( + [ValidatePattern("\S+")] + [string[]]$Text = $psise.CurrentFile.Editor.SelectedText, + [switch]$Colorized + ) + + If (($global:word.Application -eq $Null) -OR -NOT (Get-Process WinWord)) { + #remove any variables that might be left over just to be safe + Remove-Variable -Name doc, selection -Force -ErrorAction SilentlyContinue + + #create a Word instance if the object doesn't already exist + $global:word = New-Object -ComObject word.application + + #create a new document + $global:doc = $global:word.Documents.add() + + #create a selection + $global:selection = $global:word.Selection + + #set font and paragraph for fixed width content + $global:selection.Font.Name = "Consolas" + $global:selection.font.Size = 10 + $global:selection.paragraphFormat.SpaceBefore = 0 + $global:selection.paragraphFormat.SpaceAfter = 0 + + #show the Word document + $global:word.Visible = $True + } + + if ($Colorized) { + #copy the selection to the clipboard and paste + #This is a shortcut hack that may not always work the first time + $wshell = New-Object -ComObject Wscript.shell + #must be lower-case c otherwise you will end up sending + #ctrl+shift+c + $wshell.SendKeys("^c") + #timing is everything with SendKeys. This could be a lower value + start-sleep -Milliseconds 500 + $global:selection.Paste() + } + else { + #insert the text + $global:selection.TypeText($text) + } + + #insert a new paragraph (ENTER) + $global:selection.TypeParagraph() + +} #end Function + diff --git a/functions/CurrentProjects.ps1 b/functions/CurrentProjects.ps1 new file mode 100644 index 0000000..06e255b --- /dev/null +++ b/functions/CurrentProjects.ps1 @@ -0,0 +1,74 @@ + +<# +The list is a simple text file with the complete path to scripts you are working on. +#> + + +Function Add-CurrentProject { + + [cmdletbinding()] + Param( + [ValidateNotNullorEmpty()] + [string]$List = $currentProjectList + ) + + #add the current file path to the list if it isn't already there + If ((Get-Content -path $CurrentProjectList) -notcontains $psise.CurrentFile.FullPath) { + $psise.CurrentFile.FullPath | Out-File -FilePath $list -Encoding ascii -Append + } + else { + write-warning "$($psise.CurrentFile.FullPath) already in $list" + + } +} #Add-CurrentProject + +Function Edit-CurrentProject { + + + [cmdletbinding()] + Param( + [Parameter(Position = 0, Mandatory)] + [ValidateScript( { + if (Test-Path $_) { + $True + } + else { + Throw "Cannot validate path $_" + } + })] + [string]$List + ) + + psedit $list + +} #Edit-CurrentProject + +Function Import-CurrentProject { + + [cmdletbinding()] + Param( + [Parameter(Position = 0, Mandatory)] + [ValidateScript( { + if (Test-Path $_) { + $True + } + else { + Throw "Cannot validate path $_" + } + })] + [string]$List + ) + + #get the list of file paths filtering out any blank lines + $items = Get-Content -Path $list | where {$_} + + foreach ($item in $items) { + if (Test-Path $item) { + psedit $item + } + else { + write-warning "Can't find $item" + } + } + +} #Import-CurrentProject \ No newline at end of file diff --git a/functions/CycleISETabs.ps1 b/functions/CycleISETabs.ps1 new file mode 100644 index 0000000..d081cbe --- /dev/null +++ b/functions/CycleISETabs.ps1 @@ -0,0 +1,32 @@ + +#cycle through PowerShell Tabs +#this needs to be in your PowerShell ISE profile to work properly + +Function Get-NextISETab { + [cmdletbinding()] + Param() + + $iseTabs = $psISE.PowerShellTabs + + #get current tab + for ($i = 0; $i -le $iseTabs.count - 1; $i++) { + Write-Verbose $iseTabs[$i].Displayname + if ($iseTabs[$i].Displayname -eq $psISE.CurrentPowerShellTab.DisplayName) { + $current = $i + } + } + + #check if the next index number if valid + if ($current++ -ge $iseTabs.count - 1) { + $next = 0 + } + else { + $next = $current++ + } + + $nextTab = $iseTabs[$next] + + $iseTabs.SelectedPowerShellTab = $NextTab + +} + diff --git a/functions/Edit-Snippet.ps1 b/functions/Edit-Snippet.ps1 new file mode 100644 index 0000000..3c29458 --- /dev/null +++ b/functions/Edit-Snippet.ps1 @@ -0,0 +1,16 @@ +Function Edit-Snippet { + Param( + [string]$Path = "$env:userprofile\Documents\WindowsPowerShell\Snippets" + ) + + #display snippets by name without the .snippet.ps1xml extension + $snips = Get-ChildItem $path | Select-Object @{Name = "Name"; Expression = {$_.name.split(".")[0]}} | + Out-Gridview -title "Select one or more snippets to edit" -OutputMode Multiple + + foreach ($snip in $snips) { + $file = join-path -Path $path -ChildPath "$($snip.name).snippets.ps1xml" + Open-EditorFile $file + } + +} + diff --git a/functions/Find-InFile.ps1 b/functions/Find-InFile.ps1 new file mode 100644 index 0000000..b2c008a Binary files /dev/null and b/functions/Find-InFile.ps1 differ diff --git a/functions/Get-ASTScriptProfile.ps1 b/functions/Get-ASTScriptProfile.ps1 new file mode 100644 index 0000000..606c7c2 --- /dev/null +++ b/functions/Get-ASTScriptProfile.ps1 @@ -0,0 +1,214 @@ + + +Function Get-ASTProfile { + + [cmdletbinding()] + Param( + [Parameter(Position = 0, HelpMessage = "Enter the path of a PowerShell script")] + [ValidateScript( {Test-Path $_})] + [ValidatePattern( "\.(ps1|psm1|txt)$")] + [string]$Path = $(Read-Host "Enter the filename and path to a PowerShell script"), + [ValidateScript( {Test-Path $_})] + [Alias("fp", "out")] + [string]$FilePath = "$env:userprofile\Documents\WindowsPowerShell" + ) + + Write-Verbose "Starting $($myinvocation.MyCommand)" + + #region setup profiling + #need to resolve full path and convert it + $Path = (Resolve-Path -Path $Path).Path | Convert-Path + Write-Verbose "Analyzing $Path" + + Write-Verbose "Parsing File for AST" + New-Variable astTokens -force + New-Variable astErr -force + + $AST = [System.Management.Automation.Language.Parser]::ParseFile($Path, [ref]$astTokens, [ref]$astErr) + + #endregion + + #region generate AST data + + #include PowerShell version information + Write-Verbose "PSVersionTable" + Write-Verbose ($PSversionTable | Out-String) + + if ($ast.ScriptRequirements) { + $requirements = ($ast.ScriptRequirements | Out-String).Trim() + } + else { + $requirements = "-->None detected" + } + + if ($ast.ParamBlock.Parameters ) { + write-verbose "Parameters detected" + $foundParams = $(($ast.ParamBlock.Parameters | + Select-Object Name, DefaultValue, StaticType, Attributes | + Format-List | Out-String).Trim() + ) + } + else { + $foundParams = "-->None detected. Parameters for nested commands not tested." + } + + + #define the report text + $report = @" +This is an analysis of a PowerShell script or module. Analysis will most likely NOT be 100% thorough. + +"@ + + Write-Verbose "Getting requirements and parameters" + $report += @" + +REQUIREMENTS +$requirements + +PARAMETERS +$foundparams + +"@ + + Write-Verbose "Getting all command elements" + + $commands = @() + $unresolved = @() + + $genericCommands = $astTokens | + Where-Object {$_.tokenflags -eq 'commandname' -AND $_.kind -eq 'generic'} + + $aliases = $astTokens | + Where-Object {$_.tokenflags -eq 'commandname' -AND $_.kind -eq 'identifier'} + + Write-Verbose "Parsing commands" + foreach ($command in $genericCommands) { + Try { + $commands += Get-Command -Name $command.text -ErrorAction Stop + } + Catch { + $unresolved += $command.Text + } + } + + foreach ($command in $aliases) { + Try { + $commands += Get-Command -Name $command.text -erroraction Stop | + ForEach-Object { + #get the resolved command + Get-Command -Name $_.Definition + } + } + Catch { + $unresolved += $command.Text + } + } + + Write-Verbose "All commands" + $report += @" + +ALL COMMANDS +All possible PowerShell commands. This list may not be complete or even correct. + +$(($Commands | Sort -Unique | Format-Table -autosize | Out-String).Trim()) + +"@ + + Write-Verbose "Unresolved commands" + if ($unresolved) { + $unresolvedText = $Unresolved | Sort-Object -Unique | Format-Table -autosize | Out-String + } + else { + $unresolvedText = "-->None detected" + } + + $report += @" + +UNRESOLVED +These commands may be called from nested commands or unknown modules. + +$unresolvedtext +"@ + + Write-Verbose "Potentially dangerous commands" + #identify dangerous commands + $danger = "Remove", "Stop", "Disconnect", "Suspend", "Block", + "Disable", "Deny", "Unpublish", "Dismount", "Reset", "Resize", + "Rename", "Redo", "Lock", "Hide", "Clear" + + $danger = $commands | Where-Object {$danger -contains $_.verb} | Sort-Object Name | Get-Unique + + if ($danger) { + $dangercommands = $($danger | Format-Table -AutoSize | Out-String).Trim() + } + else { + $dangercommands = "-->None detected" + } + + #get type names, some of which may come from parameters + Write-Verbose "Typenames" + + $typetokens = $asttokens | Where-Object {$_.tokenflags -eq 'TypeName'} + if ($typetokens ) { + $foundTypes = $typetokens | + Sort-Object @{expression = {$_.text.toupper()}} -unique | + Select-Object -ExpandProperty Text | ForEach-Object { "[$_]"} | Out-String + } + else { + $foundTypes = "-->None detected" + } + + $report += @" + +TYPENAMES +These are identified .NET type names that might be used as accelerators. + +$foundTypes +"@ + + $report += @" + +WARNING +These are potentially dangerous commands. + +$dangercommands +"@ + + #endregion + + Write-Verbose "Display results" + #region create and display the result + + #create a help topic file using the script basename + $basename = (Get-Item $Path).basename + #stored in the Documents folder + $reportFile = Join-Path -Path $FilePath -ChildPath "ABOUT_$basename.help.txt" + + Write-Verbose "Saving report to $reportFile" + #insert the Topic line so help recognizes it + @" +TOPIC +about $basename profile + +"@ |Out-File -FilePath $reportFile -Encoding ascii + + #create the report + @" +SHORT DESCRIPTION +Script Profile report for: $Path + +"@ | Out-File -FilePath $reportFile -Encoding ascii -Append + + @" +LONG DESCRIPTION +$report +"@ | Out-File -FilePath $reportFile -Encoding ascii -Append + + #view the report with Notepad + + Notepad $reportFile + + #endregion + + Write-Verbose "Profiling complete." +} #end of function \ No newline at end of file diff --git a/functions/Get-ScriptComments.ps1 b/functions/Get-ScriptComments.ps1 new file mode 100644 index 0000000..4fe7c65 --- /dev/null +++ b/functions/Get-ScriptComments.ps1 @@ -0,0 +1,46 @@ + +#parse a script file for comments only + +Function Get-ScriptComments { + + [cmdletbinding()] + Param( + [Parameter(Position = 0, Mandatory, HelpMessage = "Enter the path of a PS1 file", + ValueFromPipeline, ValueFromPipelineByPropertyName)] + [Alias("PSPath", "Name")] + [ValidateScript( {Test-Path $_})] + [ValidatePattern("\.ps(1|m1)$")] + [string]$Path + ) + + Begin { + #Begin scriptblock + Write-Verbose -Message "Starting $($MyInvocation.Mycommand)" + #initialization commands + #explicitly define some AST variables + New-Variable astTokens -force + New-Variable astErr -force + } #close begin + + Process { + #Process scriptblock + #convert each path to a nice filesystem path + $Path = Convert-Path -Path $Path + + Write-Verbose -Message "Parsing $Path" + #Parse the file + $ast = [System.Management.Automation.Language.Parser]::ParseFile($Path, [ref]$astTokens, [ref]$astErr) + + #filter tokens for comments and display text + $asttokens.where( {$_.kind -eq 'comment'}) | + Select-Object -ExpandProperty Text + } #close process + + End { + #end scriptblock + + #ending the function + Write-Verbose -Message "Ending $($MyInvocation.Mycommand)" + } #close end + +} #close function \ No newline at end of file diff --git a/functions/Get-SearchResult.ps1 b/functions/Get-SearchResult.ps1 new file mode 100644 index 0000000..aec8893 --- /dev/null +++ b/functions/Get-SearchResult.ps1 @@ -0,0 +1,32 @@ + + +Function Get-SearchResult { + [cmdletbinding()] + Param( + [Parameter(Position = 0)] + [ValidateNotNullorEmpty()] + [string]$Text = $psise.currentfile.editor.selectedText, + [ValidateSet("Bing", "Google", "Yahoo")] + [string]$SearchEngine = "Google" + ) + + Switch ($SearchEngine) { + "Bing" { + $lang = (get-culture).parent.name + $url = "http://www.bing.com/search?q=$text+language%3A$lang" + Break + } + "Google" { + $url = "http://www.google.com/search?q=$text" + } + "Yahoo" { + $url = "http://search.yahoo.com/search?p=$text" + } + } #switch + + + write-Verbose "Opening $url in $SearchEngine" + + Start $url + +} #end function \ No newline at end of file diff --git a/functions/New-CommentHelp.ps1 b/functions/New-CommentHelp.ps1 new file mode 100644 index 0000000..a8a2e4c --- /dev/null +++ b/functions/New-CommentHelp.ps1 @@ -0,0 +1,175 @@ + + +# Comments: +#This works best in the ISE with your function already loaded. + +Function New-CommentHelp { + [cmdletbinding()] + Param( + [Parameter(Position = 0, Mandatory, HelpMessage = "What is the name of your function or command?" )] + [ValidateNotNullorEmpty()] + [string]$Name, + + [Parameter(Position = 1, Mandatory, HelpMessage = "Enter a brief synopsis" )] + [ValidateNotNullorEmpty()] + [string]$Synopsis, + + [Parameter(Position = 2, Mandatory, HelpMessage = "Enter a description. You can expand and edit later" )] + [ValidateNotNullorEmpty()] + [string]$Description + ) + + #define beginning of comment based string + + $comment = @" +<# +.SYNOPSIS +{0} +.DESCRIPTION +{1} + +"@ + + + #Create comment based help string + $help = $comment -f $synopsis, $description + + #test if command is loaded and if so get parameters + #ignore common: + $common = "VERBOSE|DEBUG|ERRORACTION|WARNINGACTION|ERRORVARIABLE|WARNINGVARIABLE|OUTVARIABLE|OUTBUFFER|PIPELINEVARIABLE|WHATIF|CONFIRM|INFORMATIONVARIABLE|INFORMATIONACTION" + Try { + $command = Get-Command -Name $name -ErrorAction Stop + $params = $command.parameters.keys | Where-Object {$_ -notmatch $common} + } + Catch { + #otherwise prompt + $scriptname = Read-Host "If your command is a script file, enter the full file name with extension. Otherwise leave blank" + if ($scriptname) { + Try { + $command = Get-Command -Name $scriptname -ErrorAction Stop + $params = $command.parameters.keys | Where-Object {$_ -notmatch $common} + } + Catch { + Write-Warning "Failed to find $scriptname" + #BAIL OUT + Return + } + + } #if $scriptname + else { + #prompt for a comma separated list of parameter names + $EnterParams = Read-Host "Enter a comma separated list of parameter names" + $Params = $EnterParams.Split(",") + } + } + + #get parameters from help or prompt for comma separated list + if ($params) { + Foreach ($param in $params) { + #get aliases from the command + $aliases = $command.parameters[$param].aliases + #get parameter attribute + $pa = $command.parameters[$param].Attributes | Where-Object {$_.GetType().name -eq "ParameterAttribute"} + #extract any parameter help messages + if ($pa.HelpMessage) { + [string]$paramDesc = $pa.HelpMessage + } + if ($aliases) { + $paramDesc += " This command has aliases of: $($aliases -join ",")" + } + #define a new line + #this must be left justified to avoid a parsing error + $paramHelp = @" +.PARAMETER $Param +$paramDesc + +"@ + + #append the parameter to the help comment + $help += $paramHelp + } #foreach param + } #if $params + + #Define a default example using the command name + #this must be left justified to avoid a parsing error + $exHelp = @" +.EXAMPLE +PS C:\> $Name + + +"@ + + #add the example to the help comment + $help += $exHelp + + #stuff for the Notes section + $version = "1.0" + $verDate = (Get-Date).ToShortDateString() + + + #construct a Notes section + $NoteHere = @" +.NOTES +NAME : {0} +VERSION : {1} +LAST UPDATED: {2} +AUTHOR : {3}\{4} + +Learn more about PowerShell: +http://jdhitsolutions.com/blog/essential-powershell-resources/ + + **************************************************************** + * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED * + * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK. IF * + * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, * + * DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING. * + **************************************************************** + +"@ + + #insert the values + $Notes = $NoteHere -f $Name, $version, $verDate, $env:userdomain, $env:username + + #add the section to help + $help += $Notes + + #define a here string for any links you might want to add + $linkHelp = @" +.LINK + +"@ + + #add the section to help + $help += $linkHelp + + #} + + #Inputs + $inputHelp = @" +.INPUTS + +"@ + + $help += $InputHelp + + #outputs + $outputHelp = @" +.OUTPUTS + +"@ + + $help += $OutputHelp + + #close the help comment + $help += "#>" + + #if ISE insert into current file + if ($psise) { + $psise.CurrentFile.Editor.InsertText($help) | Out-Null + } + else { + #else write to the pipeline + $help + } + +} #end function \ No newline at end of file diff --git a/functions/New-DSCResourceSnippet.ps1 b/functions/New-DSCResourceSnippet.ps1 new file mode 100644 index 0000000..e2aa23f --- /dev/null +++ b/functions/New-DSCResourceSnippet.ps1 @@ -0,0 +1,115 @@ + +#requires -module PSDesiredStateConfiguration + +Function New-DSCResourceSnippet { + + [cmdletbinding(SupportsShouldProcess = $True, DefaultParameterSetName = "Name")] + Param( + [Parameter(Position = 0, Mandatory = $True, HelpMessage = "Enter the name of a DSC resource", + ParameterSetName = "Name")] + [ValidateNotNullorEmpty()] + [string[]]$Name, + [Parameter(Position = 0, Mandatory = $True, HelpMessage = "Enter the name of a DSC resource", + ValueFromPipeline = $True, ParameterSetName = "Resource")] + [ValidateNotNullorEmpty()] + [Microsoft.PowerShell.DesiredStateConfiguration.DscResourceInfo[]] $DSCResource, + [ValidateNotNullorEmpty()] + [string]$Author = $env:username, + [Switch]$Passthru + ) + + Begin { + Write-Verbose -Message "Starting $($MyInvocation.Mycommand)" + } #begin + + Process { + + if ($PSCmdlet.ParameterSetName -eq 'Name') { + #get the resource from the name + Try { + Write-Verbose "Getting DSC Resource $Name" + $DSCResource = Get-DscResource -Name $Name -ErrorAction Stop + } + Catch { + Throw + } + } + + foreach ($resource in $DSCResource) { + + #create the entry based on resource properties + [string[]]$entry = "`n$($resource.name) {`n" + + Write-Verbose "Creating resource entry for $($resource.name)" + $entry += "`t#from module $($resource.module.name)" + $entry += foreach ($item in $resource.Properties) { + if ($item.IsMandatory) { + $resourcename = "`t*$($item.name)" + } + else { + $resourcename = "`t$($item.name)" + } + + if ($item.PropertyType -eq '[bool]') { + $possibleValues = "`$True | `$False" + } + elseif ($item.values) { + $possibleValues = "'$($item.Values -join "' | '")'" + } + else { + $possibleValues = $item.PropertyType + } + "$resourcename = $($possibleValues)" + + } #foreach + + $entry += "`n} #end $($resource.name) resource`n`n" + + $title = "DSC $($resource.name) Resource" + $description = "$($resource.name) resource from module $($resource.module) $($resource.CompanyName)" + + Write-Verbose "Creating snippet $title" + Write-Verbose $description + Write-Verbose ($entry | Out-String) + + $paramHash = @{ + Title = $Title + Description = $description + Text = ($Entry | Out-String) + Author = $Author + Force = $True + ErrorAction = "Stop" + } + + Write-Verbose ($paramHash | Out-String) + if ($PSCmdlet.ShouldProcess($Resource.name)) { + + Try { + Write-Debug "Creating snippet file" + New-IseSnippet @paramHash + + if ($Passthru) { + #build the path + $snippath = join-path -path "$env:Userprofile\documents\WindowsPowerShell\Snippets" -ChildPath "$title.snippets.ps1xml" + Get-Item -path $snippath + } + } + Catch { + Throw + } + + } #if shouldprocess + } #foreach resource + + } #process + + End { + #import the new snippets into the current session. They will + #automatically be loaded next time. + Write-Verbose "Importing new snippets" + Import-IseSnippet -Path "$env:Userprofile\documents\WindowsPowerShell\Snippets" + Write-Verbose -Message "Ending $($MyInvocation.Mycommand)" + } #end + + +} #end function \ No newline at end of file diff --git a/functions/New-FileHere.ps1 b/functions/New-FileHere.ps1 new file mode 100644 index 0000000..780372e --- /dev/null +++ b/functions/New-FileHere.ps1 @@ -0,0 +1,53 @@ + +Function New-FileHere { + + [cmdletbinding()] + Param( + [string]$Name = (New-Inputbox -Prompt "Enter a file name" -Title "New File" -Default "MyUntitled.ps1"), + [switch]$Open, + [switch]$Passthru + ) + + + if ($name -match "\w+") { + $newpath = Join-path -Path (Get-Location).Path -ChildPath $name + if (Test-Path -Path $newpath) { + Write-Warning "A file with the name $name already exists. Please try again." + } + else { + write-verbose "Adding $newFile" + $head = @" +#Requires -version $($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor) + +<# +$Name + + **************************************************************** + * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED * + * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK. IF * + * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, * + * DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING. * + **************************************************************** +#> + + +"@ + $head | Out-File -FilePath $newPath -NoClobber + + #give the file a chance to be created + start-sleep -Seconds 1 + + #Open the file + if ($Open) { + psedit $newpath + } + if ($Passthru) { + Get-Item $newpath + } + + } + } + else { + Write-host "Aborting" -ForegroundColor Yellow + } +} #end function \ No newline at end of file diff --git a/functions/New-ISEFunction.ps1 b/functions/New-ISEFunction.ps1 new file mode 100644 index 0000000..4926504 Binary files /dev/null and b/functions/New-ISEFunction.ps1 differ diff --git a/functions/New-InputBox.ps1 b/functions/New-InputBox.ps1 new file mode 100644 index 0000000..4d9fa9a --- /dev/null +++ b/functions/New-InputBox.ps1 @@ -0,0 +1,25 @@ +Function New-Inputbox { + + [cmdletbinding()] + + Param ( + [Parameter(Position = 0, Mandatory, HelpMessage = "Enter a message prompt")] + [ValidateNotNullorEmpty()] + [string]$Prompt, + [Parameter(Position = 1)] + [string]$Title = "Input", + [Parameter(Position = 2)] + [string]$Default + + ) + + Try { + Add-Type -AssemblyName "microsoft.visualbasic" -ErrorAction Stop + [microsoft.visualbasic.interaction]::InputBox($Prompt, $Title, $Default) + } + Catch { + Write-Warning "There was a problem creating the inputbox" + Write-Warning $_.Exception.Message + } + +} #end New-Inputbox \ No newline at end of file diff --git a/functions/New-PSCommand.ps1 b/functions/New-PSCommand.ps1 new file mode 100644 index 0000000..30d5c71 Binary files /dev/null and b/functions/New-PSCommand.ps1 differ diff --git a/functions/Open-SelectedInISE.ps1 b/functions/Open-SelectedInISE.ps1 new file mode 100644 index 0000000..e6e7552 --- /dev/null +++ b/functions/Open-SelectedInISE.ps1 @@ -0,0 +1,18 @@ + + +Function Open-SelectedISE { + [cmdletbinding()] + Param([string]$Text = $psise.CurrentFile.Editor.SelectedText) + + #trim off any spaces + $file = $Text.Trim() + + if (Test-Path -Path $file ) { + psedit $file + } + else { + Write-Warning "Can't find $file" + } + +} #end function + diff --git a/functions/Out-ISETab.ps1 b/functions/Out-ISETab.ps1 new file mode 100644 index 0000000..7b8d27a Binary files /dev/null and b/functions/Out-ISETab.ps1 differ diff --git a/functions/Print-ISEFile.ps1 b/functions/Print-ISEFile.ps1 new file mode 100644 index 0000000..1c7750e --- /dev/null +++ b/functions/Print-ISEFile.ps1 @@ -0,0 +1,16 @@ + + +<# +this is an alternative way using the default printer + get-content -Path $path | out-printer +#> + +Function Send-ToPrinter { + + Param([string]$path = $PSISE.CurrentFile.FullPath) + + Start-Process -filepath Notepad.exe -ArgumentList "/p", $path -WindowStyle Hidden + + +} #end function + diff --git a/functions/Reload-ISEFile.ps1 b/functions/Reload-ISEFile.ps1 new file mode 100644 index 0000000..b71c345 --- /dev/null +++ b/functions/Reload-ISEFile.ps1 @@ -0,0 +1,15 @@ + +Function Reset-ISEFile { + + Param() + #save the current file path + $path = $psise.CurrentFile.FullPath + #get current index + $i = $psise.CurrentPowerShellTab.files.IndexOf($psise.CurrentFile) + #remove the file + [void]$psise.CurrentPowerShellTab.Files.Remove($psise.CurrentFile) + [void]$psise.CurrentPowerShellTab.Files.Add($path) + #file always added to the end + [void]$psise.CurrentPowerShellTab.files.Move(($psise.CurrentPowerShellTab.files.count - 1), $i) + +} \ No newline at end of file diff --git a/functions/Sign-ISEScript.ps1 b/functions/Sign-ISEScript.ps1 new file mode 100644 index 0000000..129c76f --- /dev/null +++ b/functions/Sign-ISEScript.ps1 @@ -0,0 +1,44 @@ + + +Function Write-Signature { + + Param() + + Set-StrictMode -Version Latest + + #get the code signing certificates that have not expired + $cert = Get-ChildItem -Path Cert:\CurrentUser\My -CodeSigningCert | Where-Object {$_.Verify()} + If ($cert.Count -eq '0') { + Write-Warning 'No code signing certificate found.' + Exit + } + ElseIf ($cert.Count -gt '1') { + $cert = ($cert | Out-GridView -Title 'Select the desired code signing certificate' -OutputMode Single) + } + + #save the file if necessary + if (!$psise.CurrentFile.IsSaved) { + $psise.CurrentFile.Save() + } + + #if the file is encoded as BigEndian, resave as Unicode + if ($psise.CurrentFile.Encoding.EncodingName -match "Big-Endian") { + $psise.CurrentFile.Save([Text.Encoding]::Unicode) | Out-Null + } + + #save the filepath for the current file so it can be re-opened later + $filepath = $psise.CurrentFile.FullPath + + #sign the file + Try { + Set-AuthenticodeSignature -FilePath $filepath -Certificate $cert -errorAction Stop + #close the file + $psise.CurrentPowerShellTab.Files.Remove(($psise.CurrentFile)) | Out-Null + + #reopen the file + $psise.CurrentPowerShellTab.Files.Add(($filepath)) | Out-Null + } + Catch { + Write-Warning ("Script signing failed. {0}" -f $_.Exception.message) + } +}#end function diff --git a/functions/get-commandmetadata.ps1 b/functions/get-commandmetadata.ps1 new file mode 100644 index 0000000..734696c --- /dev/null +++ b/functions/get-commandmetadata.ps1 @@ -0,0 +1,115 @@ + + +Function Get-CommandMetadata { + + [cmdletbinding()] + [alias("gcmd")] + Param( + [Parameter(Position = 0, Mandatory, HelpMessage = "Enter the name of a PowerShell command")] + [ValidateNotNullorEmpty()] + [string]$Command, + [string]$NewName, + [switch]$NoHelp + ) + + Try { + Write-Verbose "Getting command metadata for $command" + $gcm = Get-Command -Name $command -ErrorAction Stop + #allow an alias or command name + if ($gcm.CommandType -eq 'Alias') { + $cmdName = $gcm.ResolvedCommandName + } + else { + $cmdName = $gcm.Name + } + Write-Verbose "Resolved to $cmdName" + $cmd = New-Object System.Management.Automation.CommandMetaData ($gcm) + } + Catch { + Write-Warning "Failed to create command metadata for $command" + Write-Warning $_.Exception.Message + } + + if ($cmd) { + #create the metadata + + if ($NewName) { + $Name = $NewName + } + else { + $Name = $cmd.Name + } + + if ($noHelp) { + #remove help link + $cmd.HelpUri = $Null + + Write-Verbose "Defining a new comment based help block" + #define outline for comment based help + $myHelp = @" + +.Synopsis +PUT SYNTAX HERE +.Description +PUT DESCRIPTION HERE +.Notes +Created:`t$(Get-Date -format d) + +.Example +PS C:\> $Name + +.Link +$cmdname + +"@ + Write-Verbose "Creating proxy command with help" + $metadata = [System.Management.Automation.ProxyCommand]::Create($cmd, $myHelp) + + } #nohelp + else { + Write-Verbose "Creating proxy command" + $metadata = [System.Management.Automation.ProxyCommand]::Create($cmd) + } + + Write-Verbose "Cleaning up parameter names" + [regex]$rx = "[\s+]\$\{\w+\}[,|)]" + $metadata = $metadata.split("`n") | ForEach-Object { + If ($rx.ismatch($_)) { + #strip off { } around parameter names + $rx.Match($_).Value.Replace("{", "").Replace("}", "") + # "`n" + } + else { + #just write the line + $_ + } + } #foreach + + #define the text for the new command + $text = @" +#requires -version $($PSVersionTable.psversion) + +Function $Name { + +$metadata + +} #end function $Name +"@ + if ($host.Name -match "PowerShell ISE") { + #open in a new ISE tab + $tab = $psise.CurrentPowerShellTab.Files.Add() + + Write-Verbose "Opening metadata in a new ISE tab" + $tab.editor.InsertText($Text) + + #jump to the top + $tab.Editor.SetCaretPosition(1, 1) + } + else { + $Text + } + } + Write-Verbose "Ending $($MyInvocation.MyCommand)" + +} #end function + diff --git a/images/addons-menu.png b/images/addons-menu.png new file mode 100644 index 0000000..3a291a0 Binary files /dev/null and b/images/addons-menu.png differ