diff --git a/Changelog.md b/Changelog.md index 7acb44e..a383012 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,11 @@ # ChangeLog for ISEScriptingGeek Module +## 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. diff --git a/ISEScriptingGeek.psd1 b/ISEScriptingGeek.psd1 index bacb960..a320a3c 100644 --- a/ISEScriptingGeek.psd1 +++ b/ISEScriptingGeek.psd1 @@ -5,7 +5,7 @@ RootModule = 'ISEScriptingGeek.psm1' # Version number of this module. -ModuleVersion = '3.4.0' +ModuleVersion = '3.4.1' # ID used to uniquely identify this module GUID = '6d1078ea-36c8-443a-9476-6d6c4d6ac834' @@ -82,7 +82,7 @@ CmdletsToExport = @() VariablesToExport = 'MySnippets', 'MyModules', 'MyPowerShell', 'CurrentProjectList' # Aliases to export from this module -AliasesToExport = 'ccs','gcfg','gcfgs','gcmd','glcm','pbcfg','rtcfg','sacfg','slcm','tab','tcfg','upcfg','sd' +AliasesToExport = 'ccs','gcmd','glcm''tab','sd' # DSC resources to export from this module # DscResourcesToExport = @() diff --git a/ISEScriptingGeek.psm1 b/ISEScriptingGeek.psm1 index f90b535..ff75e35 100644 Binary files a/ISEScriptingGeek.psm1 and b/ISEScriptingGeek.psm1 differ diff --git a/README.md b/README.md index ad7d505..9fd4c13 100644 --- a/README.md +++ b/README.md @@ -2,20 +2,19 @@ [![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 PowerShell 4.0 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._ ## Themes -The themes can be found and imported from the Themes subfolder of the module. +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 subfolders: +A number of the add-ons fall into grouped sub-folders: ### Bookmarks @@ -41,9 +40,10 @@ A set of functions for working with open files and their associated folders A set of functions for creating and managing a "work list" of files -### Misc +### 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 @@ -52,4 +52,4 @@ There are also other scripts directly off the **ISE Scripting Geek** menu, these Please submit issues for defects, enhancements, or documentation. -*Last updated 21 February 2019* \ No newline at end of file +*Last 2019-06-24 14:25:59Z UTC* \ No newline at end of file diff --git a/functions/Bookmarks.ps1 b/functions/Bookmarks.ps1 index 9d4a39a..51a65af 100644 --- a/functions/Bookmarks.ps1 +++ b/functions/Bookmarks.ps1 @@ -2,116 +2,116 @@ #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?" -} + [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() + [cmdletbinding()] + Param() + + $bookmark = Get-ISEBookmark -$bookmark = Get-ISEBookmark + if ($bookmark) { + Write-Verbose "Processing bookmark $($bookmark.name) for $($bookmark.path)" -if ($bookmark) { - Write-Verbose "Processing bookmark $($bookmark.name) for $($bookmark.path)" - - #open the file - psedit $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}) + #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] + #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 + #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() + [cmdletbinding(SupportsShouldProcess)] + Param() -$bookmark = Get-ISEBookmark + $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) { + 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 + } #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 + [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 + $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 index 43fd7e3..20e8963 100644 --- a/functions/CIMScriptMaker.ps1 +++ b/functions/CIMScriptMaker.ps1 @@ -25,15 +25,15 @@ Function New-CIMCommand { #browse namespaces Write-Host "Enumerating namspaces on $computername....please wait..." -ForegroundColor Cyan - $ns = Get-Namespace -CimSession $cimsess | Sort | + $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 {$_.cimclassname -notmatch "^__" -AND $_.CimClassProperties.Name -notcontains "Antecedent"} | - Sort CimClassName | Select CimClassName, CimClassProperties | + 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 } @@ -69,7 +69,7 @@ Function New-CIMCommand { $cmd = "Get-CimInstance @cimParam" #create a filter - $filterProperty = $class.CimClassProperties | Select Name, CimType, Flags | + $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) { @@ -89,7 +89,7 @@ Function New-CIMCommand { #show properties Write-Host "Getting class properties" -ForegroundColor Cyan - $properties = $class.CimClassProperties | select Name, CimType, Flags | + $properties = $class.CimClassProperties | Select-Object Name, CimType, Flags | Out-Gridview -Title "$($class.CimClassName) : Select one or more properties. Cancel will select *" -PassThru if ($properties) { diff --git a/functions/CloseAllFiles.ps1 b/functions/CloseAllFiles.ps1 index 7ff5300..2c94368 100644 --- a/functions/CloseAllFiles.ps1 +++ b/functions/CloseAllFiles.ps1 @@ -9,7 +9,7 @@ Function CloseAllFiles { $saved = $psISE.CurrentPowerShellTab.Files.Where( {$_.isSaved}) foreach ($file in $saved) { write-Verbose "closing $($file.FullPath)" - $psISE.CurrentPowerShellTab.files.Remove($file) | out-null + [void]$psISE.CurrentPowerShellTab.files.Remove($file) } } #end function @@ -22,7 +22,7 @@ Function CloseAllFilesButCurrent { $saved = $psISE.CurrentPowerShellTab.Files.Where( {$_.isSaved -AND $_.fullpath -ne $psISE.CurrentFile.FullPath }) foreach ($file in $saved) { write-Verbose "closing $($file.FullPath)" - $psISE.CurrentPowerShellTab.files.Remove($file) | out-null + [void]$psISE.CurrentPowerShellTab.files.Remove($file) } } #end function \ No newline at end of file diff --git a/functions/ConvertAll.ps1 b/functions/ConvertAll.ps1 index 06a4705..082dd41 100644 Binary files a/functions/ConvertAll.ps1 and b/functions/ConvertAll.ps1 differ diff --git a/functions/ConvertTo-CommentHelp.ps1 b/functions/ConvertTo-CommentHelp.ps1 index ea2ae9c..7735872 100644 --- a/functions/ConvertTo-CommentHelp.ps1 +++ b/functions/ConvertTo-CommentHelp.ps1 @@ -1,7 +1,7 @@  Function ConvertTo-CommentHelp { - + [cmdletbinding()] Param() Add-Type -AssemblyName "microsoft.visualbasic" -ErrorAction Stop diff --git a/functions/ConvertTo-TextFile.ps1 b/functions/ConvertTo-TextFile.ps1 index a01bba2..e1d80b0 100644 Binary files a/functions/ConvertTo-TextFile.ps1 and b/functions/ConvertTo-TextFile.ps1 differ diff --git a/functions/Copy-ToWord.ps1 b/functions/Copy-ToWord.ps1 index ad6ba7d..c148188 100644 --- a/functions/Copy-ToWord.ps1 +++ b/functions/Copy-ToWord.ps1 @@ -3,55 +3,54 @@ #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() + [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 - \ No newline at end of file diff --git a/functions/CycleISETabs.ps1 b/functions/CycleISETabs.ps1 index 40deba0..d081cbe 100644 --- a/functions/CycleISETabs.ps1 +++ b/functions/CycleISETabs.ps1 @@ -3,30 +3,30 @@ #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 + [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 index 855b590..3c29458 100644 --- a/functions/Edit-Snippet.ps1 +++ b/functions/Edit-Snippet.ps1 @@ -4,12 +4,12 @@ ) #display snippets by name without the .snippet.ps1xml extension - $snips = dir $path | Select @{Name = "Name"; Expression = {$_.name.split(".")[0]}} | + $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" - psedit $file + Open-EditorFile $file } } diff --git a/functions/Find-InFile.ps1 b/functions/Find-InFile.ps1 index b0fe0bd..b2c008a 100644 Binary files a/functions/Find-InFile.ps1 and b/functions/Find-InFile.ps1 differ diff --git a/functions/Get-ASTScriptProfile.ps1 b/functions/Get-ASTScriptProfile.ps1 index c46df55..606c7c2 100644 --- a/functions/Get-ASTScriptProfile.ps1 +++ b/functions/Get-ASTScriptProfile.ps1 @@ -44,7 +44,7 @@ Function Get-ASTProfile { if ($ast.ParamBlock.Parameters ) { write-verbose "Parameters detected" $foundParams = $(($ast.ParamBlock.Parameters | - Select Name, DefaultValue, StaticType, Attributes | + Select-Object Name, DefaultValue, StaticType, Attributes | Format-List | Out-String).Trim() ) } @@ -76,10 +76,10 @@ $foundparams $unresolved = @() $genericCommands = $astTokens | - where {$_.tokenflags -eq 'commandname' -AND $_.kind -eq 'generic'} + Where-Object {$_.tokenflags -eq 'commandname' -AND $_.kind -eq 'generic'} $aliases = $astTokens | - where {$_.tokenflags -eq 'commandname' -AND $_.kind -eq 'identifier'} + Where-Object {$_.tokenflags -eq 'commandname' -AND $_.kind -eq 'identifier'} Write-Verbose "Parsing commands" foreach ($command in $genericCommands) { @@ -94,7 +94,7 @@ $foundparams foreach ($command in $aliases) { Try { $commands += Get-Command -Name $command.text -erroraction Stop | - foreach { + ForEach-Object { #get the resolved command Get-Command -Name $_.Definition } @@ -116,7 +116,7 @@ $(($Commands | Sort -Unique | Format-Table -autosize | Out-String).Trim()) Write-Verbose "Unresolved commands" if ($unresolved) { - $unresolvedText = $Unresolved | Sort -Unique | Format-Table -autosize | Out-String + $unresolvedText = $Unresolved | Sort-Object -Unique | Format-Table -autosize | Out-String } else { $unresolvedText = "-->None detected" @@ -136,7 +136,7 @@ $unresolvedtext "Disable", "Deny", "Unpublish", "Dismount", "Reset", "Resize", "Rename", "Redo", "Lock", "Hide", "Clear" - $danger = $commands | where {$danger -contains $_.verb} | Sort Name | Get-Unique + $danger = $commands | Where-Object {$danger -contains $_.verb} | Sort-Object Name | Get-Unique if ($danger) { $dangercommands = $($danger | Format-Table -AutoSize | Out-String).Trim() @@ -148,11 +148,11 @@ $unresolvedtext #get type names, some of which may come from parameters Write-Verbose "Typenames" - $typetokens = $asttokens | where {$_.tokenflags -eq 'TypeName'} + $typetokens = $asttokens | Where-Object {$_.tokenflags -eq 'TypeName'} if ($typetokens ) { $foundTypes = $typetokens | - Sort @{expression = {$_.text.toupper()}} -unique | - Select -ExpandProperty Text | foreach { "[$_]"} | Out-String + Sort-Object @{expression = {$_.text.toupper()}} -unique | + Select-Object -ExpandProperty Text | ForEach-Object { "[$_]"} | Out-String } else { $foundTypes = "-->None detected" diff --git a/functions/New-CommentHelp.ps1 b/functions/New-CommentHelp.ps1 index a7a165c..a8a2e4c 100644 --- a/functions/New-CommentHelp.ps1 +++ b/functions/New-CommentHelp.ps1 @@ -4,7 +4,7 @@ #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()] @@ -39,7 +39,7 @@ Function New-CommentHelp { $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 {$_ -notmatch $common} + $params = $command.parameters.keys | Where-Object {$_ -notmatch $common} } Catch { #otherwise prompt @@ -47,7 +47,7 @@ Function New-CommentHelp { if ($scriptname) { Try { $command = Get-Command -Name $scriptname -ErrorAction Stop - $params = $command.parameters.keys | where {$_ -notmatch $common} + $params = $command.parameters.keys | Where-Object {$_ -notmatch $common} } Catch { Write-Warning "Failed to find $scriptname" @@ -69,7 +69,7 @@ Function New-CommentHelp { #get aliases from the command $aliases = $command.parameters[$param].aliases #get parameter attribute - $pa = $command.parameters[$param].Attributes | where {$_.GetType().name -eq "ParameterAttribute"} + $pa = $command.parameters[$param].Attributes | Where-Object {$_.GetType().name -eq "ParameterAttribute"} #extract any parameter help messages if ($pa.HelpMessage) { [string]$paramDesc = $pa.HelpMessage diff --git a/functions/New-ISEFunction.ps1 b/functions/New-ISEFunction.ps1 index bbc3aa4..4926504 100644 Binary files a/functions/New-ISEFunction.ps1 and b/functions/New-ISEFunction.ps1 differ diff --git a/functions/New-PSCommand.ps1 b/functions/New-PSCommand.ps1 index 66ba214..30d5c71 100644 Binary files a/functions/New-PSCommand.ps1 and b/functions/New-PSCommand.ps1 differ diff --git a/functions/Reload-ISEFile.ps1 b/functions/Reload-ISEFile.ps1 index 9cbeb47..b71c345 100644 --- a/functions/Reload-ISEFile.ps1 +++ b/functions/Reload-ISEFile.ps1 @@ -7,9 +7,9 @@ Function Reset-ISEFile { #get current index $i = $psise.CurrentPowerShellTab.files.IndexOf($psise.CurrentFile) #remove the file - $psise.CurrentPowerShellTab.Files.Remove($psise.CurrentFile) | out-null - $psise.CurrentPowerShellTab.Files.Add($path) | out-null + [void]$psise.CurrentPowerShellTab.Files.Remove($psise.CurrentFile) + [void]$psise.CurrentPowerShellTab.Files.Add($path) #file always added to the end - $psise.CurrentPowerShellTab.files.Move(($psise.CurrentPowerShellTab.files.count - 1), $i) | out-Null + [void]$psise.CurrentPowerShellTab.files.Move(($psise.CurrentPowerShellTab.files.count - 1), $i) } \ No newline at end of file diff --git a/functions/get-commandmetadata.ps1 b/functions/get-commandmetadata.ps1 index ec1af6b..734696c 100644 --- a/functions/get-commandmetadata.ps1 +++ b/functions/get-commandmetadata.ps1 @@ -73,7 +73,7 @@ $cmdname Write-Verbose "Cleaning up parameter names" [regex]$rx = "[\s+]\$\{\w+\}[,|)]" - $metadata = $metadata.split("`n") | foreach { + $metadata = $metadata.split("`n") | ForEach-Object { If ($rx.ismatch($_)) { #strip off { } around parameter names $rx.Match($_).Value.Replace("{", "").Replace("}", "")