Skip to content

Commit 692ec44

Browse files
see changelog for v2.8.0
1 parent 387275b commit 692ec44

18 files changed

Lines changed: 822 additions & 110 deletions

PSScriptTools.psd1

132 Bytes
Binary file not shown.

PSScriptTools.psm1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
#enable verbose messaging in the psm1 file
2+
if ($myinvocation.line -match "-verbose") {
3+
$VerbosePreference = "continue"
4+
}
5+
Write-Verbose "Loading public functions"
16

27
Get-ChildItem -path $PSScriptRoot\functions\*.ps1 | foreach-object -process {
8+
write-verbose $_.fullname
39
. $_.FullName
410
}
511

612
#add ToDo options to the ISE or VS Code
713
if ($psEditor) {
14+
write-verbose "Defining VSCode additions"
815
$sb = {
916
Param(
1017
[Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context
@@ -20,6 +27,7 @@ if ($psEditor) {
2027

2128
}
2229
elseif ($psise) {
30+
write-verbose "Defining ISE additions"
2331
$action = {
2432

2533
$prompt = "What do you need to do?"
@@ -28,9 +36,9 @@ elseif ($psise) {
2836
$todo = "# [$(Get-Date)] TODO: $item"
2937
$psise.CurrentFile.Editor.InsertText($todo)
3038
#jump cursor to the end
31-
$psise.CurrentFile.editor.SetCaretPosition($psise.CurrentFile.Editor.CaretLine,$psise.CurrentFile.Editor.CaretColumn)
39+
$psise.CurrentFile.editor.SetCaretPosition($psise.CurrentFile.Editor.CaretLine, $psise.CurrentFile.Editor.CaretColumn)
3240
}
3341

3442
#add the action to the Add-Ons menu
35-
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("ToDo",$Action,"Ctrl+Alt+2" ) | Out-Null
43+
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("ToDo", $Action, "Ctrl+Alt+2" ) | Out-Null
3644
}

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Install-Module PSScriptTools
1515
or in PowerShell Core:
1616

1717
```powershell
18-
Install-Module PSScriptTools -scope currentuser
18+
Install-Module PSScriptTools -scope CurrentUser
1919
```
2020

2121
Starting in v2.2.0, the module was restructured to better support Desktop and Core editions. It is recommended that you uninstall any version older than 2.2.0 and then install the latest version from the PowerShell Gallery.
@@ -60,6 +60,18 @@ ExecutionPolicy : RemoteSigned
6060
Culture : en-US
6161
```
6262

63+
## [Get-FileItem](./Get-FileItem.md)
64+
65+
A PowerShell version of the CLI `where.exe` command. You can search with a simple or regex pattern.
66+
67+
```powershell
68+
PS C:\> pswhere winword.exe -Path c:\ -Recurse -first
69+
70+
C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE
71+
```
72+
73+
Note that you might see errors for directories where you don't have access permission. This is normal.
74+
6375
## [New-CustomFileName](docs/New-CustomFileName.md)
6476

6577
This command will generate a custom file name based on a template string that you provide.
@@ -716,7 +728,7 @@ Runtime : 40.21:12:01
716728
During the course of your PowerShell work, you may discover that some commands and scripts can leave behind runspaces. You may even deliberately be creating additional runspaces. These runspaces will remain until you exit your PowerShell session. Or use this command to cleanly close and dispose of runspaces.
717729

718730
```powershell
719-
PS C:\> get-runspace | where ID -gt 1 | Remove-Runspace
731+
PS C:\> Get-RunSpace | where ID -gt 1 | Remove-RunSpace
720732
```
721733

722734
Get all runspaces with an ID greater than 1, which is typically your session, and remove the runspace.
@@ -891,4 +903,4 @@ PS C:\> Set-ConsoleColor -background DarkGray -foreground Yellow
891903

892904
Where possible these commands have been tested with PowerShell Core, but not every platform. If you encounter problems, have suggestions or other feedback, please post an issue.
893905

894-
*last updated 15 March, 2019*
906+
*last updated 18 June, 2019*

changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Change Log for PSScriptTools
22

3+
## v2.8.0
4+
5+
+ Added `Get-FileItem` with an alias of `pswhere`
6+
+ Renamed `timezonedata.format.ps1xml` to all lower case.
7+
+ Replaced using `Out-Null` to use `[void]` in `Convertto-WPFGrid`,
8+
`New-PSFormatXML`, `Copy-Command`,`New-WPFMessageBox`, `Write-Detail`,
9+
`Test-Expression`,`Invoke-Inputbox` (Issue #47)
10+
+ Revised warning message in `New-PSFormatXML` (Issue #50)
11+
+ Fixed icon path error in `New-WPFMessageBox`
12+
313
## v2.7.0
414

515
+ Modified `ConvertTo-LocalTime` to allow for locations supporting Daylight Saving Time (Issue #44)

docs/Get-FileItem.md

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
---
2+
external help file: PSScriptTools-help.xml
3+
Module Name: PSScriptTools
4+
online version:
5+
schema: 2.0.0
6+
---
7+
8+
# Get-FileItem
9+
10+
## SYNOPSIS
11+
12+
A PowerShell version of the Where CLI command
13+
14+
## SYNTAX
15+
16+
### Default (Default)
17+
18+
```yaml
19+
Get-FileItem [-Pattern] <String[]> [-Regex] [-Full] [-Quiet] [-First] [<CommonParameters>]
20+
```
21+
22+
### Path
23+
24+
```yaml
25+
Get-FileItem [-Pattern] <String[]> [-Regex] [-Path <String[]>] [-Recurse] [-Full] [-Quiet] [-First]
26+
[<CommonParameters>]
27+
```
28+
29+
## DESCRIPTION
30+
31+
This is an enhanced, PowerShell version of the WHERE command from the traditional CLI which will find files in %PATH% that match a particular pattern.
32+
33+
## EXAMPLES
34+
35+
### EXAMPLE 1
36+
37+
```powershell
38+
PS C:\> Get-Fileitem notepad.exe
39+
40+
C:\Windows\system32\notepad.exe
41+
C:\Windows\notepad.exe
42+
```
43+
44+
Find notepad.exe in %path% and return the full file name. This is the default behavior.
45+
46+
### EXAMPLE 2
47+
48+
```powershell
49+
PS C:\> PSWhere calculator.exe -quiet
50+
51+
False
52+
```
53+
54+
Search for calculator.exe and return $True if found. This command is using the PSWhere alias.
55+
56+
### EXAMPLE 3
57+
58+
```powershell
59+
PS C:\> Get-FileItem "^\d+\S+\.txt" -Regex -path c:\scripts -full
60+
61+
Directory: C:\scripts
62+
63+
64+
Mode LastWriteTime Length Name
65+
---- ------------- ------ ----
66+
-a--- 12/5/2007 2:19 PM 30146 1000FemaleNames.txt
67+
-a--- 12/5/2007 2:19 PM 29618 1000MaleNames.txt
68+
-a--- 6/2/2010 11:02 AM 31206 1000names.txt
69+
-a--- 6/3/2010 8:52 AM 3154 100names.txt
70+
-a--- 4/13/2012 10:27 AM 3781 13ScriptBlocks-v2.txt
71+
-a--- 8/13/2010 10:41 AM 3958 13ScriptBlocks.txt
72+
-a--- 2/7/2011 1:37 PM 78542 2500names.txt
73+
-a--- 2/8/2011 9:43 AM 157396 5000names.txt
74+
```
75+
76+
Find all TXT files in C:\Scripts that start with a number and display full file information.
77+
78+
## PARAMETERS
79+
80+
### -Pattern
81+
82+
The name of the file to find. Separate multiple entries with a comma.
83+
Wildcards are allowed. You can also specify a regular expression pattern by including the -REGEX parameter.
84+
85+
```yaml
86+
Type: String[]
87+
Parameter Sets: (All)
88+
Aliases:
89+
90+
Required: True
91+
Position: 1
92+
Default value: None
93+
Accept pipeline input: False
94+
Accept wildcard characters: False
95+
```
96+
97+
### -Regex
98+
99+
Indicates that the pattern is a regular expression.
100+
101+
```yaml
102+
Type: SwitchParameter
103+
Parameter Sets: (All)
104+
Aliases:
105+
106+
Required: False
107+
Position: Named
108+
Default value: False
109+
Accept pipeline input: False
110+
Accept wildcard characters: False
111+
```
112+
113+
### -Path
114+
115+
The folders to search other than %PATH%.
116+
117+
```yaml
118+
Type: String[]
119+
Parameter Sets: Path
120+
Aliases:
121+
122+
Required: False
123+
Position: Named
124+
Default value: None
125+
Accept pipeline input: False
126+
Accept wildcard characters: False
127+
```
128+
129+
### -Recurse
130+
131+
Used with -Path to indicate a recursive search.
132+
133+
```yaml
134+
Type: SwitchParameter
135+
Parameter Sets: Path
136+
Aliases:
137+
138+
Required: False
139+
Position: Named
140+
Default value: False
141+
Accept pipeline input: False
142+
Accept wildcard characters: False
143+
```
144+
145+
### -Full
146+
147+
Write the full file object to the pipeline. The default is just the full name.
148+
149+
```yaml
150+
Type: SwitchParameter
151+
Parameter Sets: (All)
152+
Aliases:
153+
154+
Required: False
155+
Position: Named
156+
Default value: False
157+
Accept pipeline input: False
158+
Accept wildcard characters: False
159+
```
160+
161+
### -Quiet
162+
163+
Returns True if a match is made. This parameter will override -Full.
164+
165+
```yaml
166+
Type: SwitchParameter
167+
Parameter Sets: (All)
168+
Aliases:
169+
170+
Required: False
171+
Position: Named
172+
Default value: False
173+
Accept pipeline input: False
174+
Accept wildcard characters: False
175+
```
176+
177+
### -First
178+
179+
Stop searching after the pattern is found. Don't search any more paths.
180+
181+
```yaml
182+
Type: SwitchParameter
183+
Parameter Sets: (All)
184+
Aliases:
185+
186+
Required: False
187+
Position: Named
188+
Default value: False
189+
Accept pipeline input: False
190+
Accept wildcard characters: False
191+
```
192+
193+
### CommonParameters
194+
195+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
196+
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
197+
198+
## INPUTS
199+
200+
### Strings
201+
202+
## OUTPUTS
203+
204+
### String, Boolean or File
205+
206+
## NOTES
207+
208+
Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/
209+
210+
## RELATED LINKS
211+
212+
[Get-ChildItem]()
213+
214+
[Where.exe]()

docs/New-PSFormatXML.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
external help file: PSScriptTools-help.xml
33
Module Name: PSScriptTools
4-
online version:
4+
online version: https://github.com/jdhitsolutions/PSScriptTools/blob/master/docs/New-PSFormatXML.md
55
schema: 2.0.0
66
---
77

docs/PSScriptTools.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,8 @@ Get a list of time zone areas.
201201

202202
### [Get-TZData](./Get-TZData.md)
203203

204-
Get details of a give time zone area.
204+
Get details of a give time zone area.
205+
206+
### [Get-FileItem](./Get-FileItem.md)
207+
208+
A PowerShell version of the CLI where.exe command.

0 commit comments

Comments
 (0)