Skip to content

Commit c980922

Browse files
v2.10.0
1 parent dee649a commit c980922

File tree

103 files changed

+6611
-68
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+6611
-68
lines changed

PSScriptTools.psd1

244 Bytes
Binary file not shown.

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,28 @@ TotalMemGB FreeMemGB PctFree
861861

862862
## Scripting Tools
863863

864+
### [Test-WithCulture](docs/Test-WithCulture.md)
865+
866+
When writing PowerShell commands, sometimes the culture you are running under becomes critical. For example, European countries use a different datetime format than North Americans which might present a problem with your script or command. Unless you have a separate computer running under the foreign culture, it is difficult to test. This command will allow you to test a scriptblock or even a file under a different culture, such as DE-DE for German.
867+
868+
```powershell
869+
PS C\> Test-WithCulture fr-fr -Scriptblock {
870+
Get-winEvent -log system -max 500 |
871+
Select-Object -Property TimeCreated,ID,OpCodeDisplayname,Message |
872+
Sort-Object -property TimeCreated |
873+
Group-Object {$_.timecreated.toshortdatestring()} -noelement }
874+
875+
Count Name
876+
----- ----
877+
165 10/07/2019
878+
249 11/07/2019
879+
17 12/07/2019
880+
16 13/07/2019
881+
20 14/07/2019
882+
26 15/07/2019
883+
7 16/07/2019
884+
```
885+
864886
### [Copy-Command](docs/Copy-Command.md)
865887

866888
This command will copy a PowerShell command, including parameters and help to a new user-specified command. You can use this to create a "wrapper" function or to easily create a proxy function. The default behavior is to create a copy of the command complete with the original comment-based help block.
@@ -971,4 +993,4 @@ Begin {
971993

972994
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.
973995

974-
*last updated 2019-06-20 20:22:43Z UTC*
996+
last updated 2019-07-16 14:10:05Z UTC

changelog.md

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

3+
## 2.10.0
4+
5+
+ Added `Test-WithCulture`
6+
+ Fixed typo in `Copy-Command` help
7+
+ Created yaml formatted help files
8+
+ Updated `README.md`
9+
+ Updated help documentation with online links
10+
+ Updated `PSScriptTools.md`
11+
312
## v2.9.0
413

514
+ Added `ConvertFrom-Text` and its alias `cft` (Issue #53)
@@ -224,4 +233,4 @@
224233

225234
## v0.1.0
226235

227-
+ initial module
236+
+ initial module

docs-yaml/Add-Border.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
examples:
2+
- name: EXAMPLE 1
3+
preCode: ''
4+
code: >-
5+
PS C:\> add-border "PowerShell Wins!"
6+
7+
8+
9+
********************
10+
11+
* PowerShell Wins! *
12+
13+
********************
14+
postCode: ''
15+
- name: EXAMPLE 2
16+
preCode: ''
17+
code: >-
18+
PS C:\> add-border "PowerShell Wins!" -tab 1
19+
20+
21+
22+
********************
23+
24+
* PowerShell Wins! *
25+
26+
********************
27+
postCode: Note that this EXAMPLE may not format properly in the console.
28+
- name: EXAMPLE 3
29+
preCode: ''
30+
code: >-
31+
PS C:\> add-border "PowerShell Wins!" -character "-" -insertBlanks
32+
33+
34+
35+
--------------------
36+
37+
- -
38+
39+
- PowerShell Wins! -
40+
41+
- -
42+
43+
--------------------
44+
postCode: ''
45+
- name: EXAMPLE 4
46+
preCode: ''
47+
code: >-
48+
PS C:\> add-border -textblock (get-service win* | out-string).trim()
49+
50+
51+
52+
**********************************************************************
53+
54+
* Status Name DisplayName *
55+
56+
* ------ ---- ----------- *
57+
58+
* Stopped WinDefend Windows Defender Antivirus Service *
59+
60+
* Running WinHttpAutoProx... WinHTTP Web Proxy Auto-Discovery Se... *
61+
62+
* Running Winmgmt Windows Management Instrumentation *
63+
64+
* Stopped WinRM Windows Remote Management (WS-Manag... *
65+
66+
**********************************************************************
67+
postCode: Create a border around the output of a Get-Service command.
68+
inputs:
69+
- type: None
70+
description: ''
71+
links:
72+
- href: https://github.com/jdhitsolutions/PSScriptTools/blob/master/docs/Add-Border.md
73+
text: 'Online Version:'
74+
module:
75+
name: PSScriptTools
76+
name: Add-Border
77+
notes: 'Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/'
78+
optionalParameters:
79+
- name: Character
80+
aliases: []
81+
defaultValue: '*'
82+
description: The character to use for the border. It must be a single character.
83+
parameterValueGroup: []
84+
pipelineInput: False
85+
position: Named
86+
type: String
87+
- name: InsertBlanks
88+
aliases: []
89+
defaultValue: False
90+
description: Insert blank lines before and after the text. The default behavior is to create a border box close to the text. See examples.
91+
parameterValueGroup: []
92+
pipelineInput: False
93+
position: Named
94+
type: SwitchParameter
95+
- name: Tab
96+
aliases: []
97+
defaultValue: 0
98+
description: Insert X number of tabs.
99+
parameterValueGroup: []
100+
pipelineInput: False
101+
position: Named
102+
type: Int32
103+
outputs:
104+
- type: System.String
105+
description: ''
106+
requiredParameters:
107+
- name: Text
108+
aliases: []
109+
defaultValue: None
110+
description: A single line of text that will be wrapped in a border.
111+
parameterValueGroup: []
112+
pipelineInput: True (ByValue)
113+
position: 1
114+
type: String
115+
- name: TextBlock
116+
aliases: []
117+
defaultValue: None
118+
description: A multi-line block of text. You might want to trim blank lines from the beginning, end or both.
119+
parameterValueGroup: []
120+
pipelineInput: False
121+
position: 1
122+
type: String[]
123+
remarks: This command will create a character or text based border around a line of text. You might use this to create a formatted text report or to improve the display of information to the screen.
124+
summary: Create a text border around a string.
125+
syntaxes:
126+
- parameterValueGroup: single
127+
parameters:
128+
- Text
129+
- Character
130+
- InsertBlanks
131+
- Tab
132+
- parameterValueGroup: block
133+
parameters:
134+
- TextBlock
135+
- Character
136+
- InsertBlanks
137+
- Tab

docs-yaml/Compare-Module.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
examples:
2+
- name: EXAMPLE 1
3+
preCode: ''
4+
code: >-
5+
PS C:\> Compare-Module | Where-object {$_.UpdateNeeded}
6+
7+
8+
9+
Name : DNSSuffix
10+
11+
OnlineVersion : 0.4.1
12+
13+
InstalledVersion : 0.2.0
14+
15+
PublishedDate : 10/22/2018 8:21:46 PM
16+
17+
UpdateNeeded : True
18+
19+
20+
21+
Name : InvokeBuild
22+
23+
OnlineVersion : 5.4.2
24+
25+
InstalledVersion : 3.2.2
26+
27+
PublishedDate : 12/7/2018 1:30:46 AM
28+
29+
UpdateNeeded : True
30+
31+
...
32+
postCode: List all modules that could be updated.
33+
- name: EXAMPLE 2
34+
preCode: ''
35+
code: PS C:\> Compare-Module | Where UpdateNeeded | Out-Gridview -title "Select modules to update" -outputMode multiple | Foreach { Update-Module $_.name }
36+
postCode: Compare modules and send results to Out-Gridview. Use Out-Gridview as an object picker to decide what modules to update.
37+
- name: EXAMPLE 3
38+
preCode: ''
39+
code: >-
40+
PS C:\> compare-module -name xWin* | format-table
41+
42+
43+
44+
Name OnlineVersion InstalledVersion PublishedDate UpdateNeeded
45+
46+
---- ------------- ---------------- ------------- ------------
47+
48+
xWindowsUpdate 2.7.0.0 2.7.0.0,2.5.0.0 7/12/2017 10:43:54 PM False
49+
50+
xWinEventLog 1.2.0.0 1.2.0.0 6/13/2018 8:06:45 PM False
51+
postCode: Compare all modules that start with xWin* and display results in a table format.
52+
- name: EXAMPLE 4
53+
preCode: ''
54+
code: >-
55+
PS C:\> get-dscresource xAD* | Select moduleName -Unique | compare-module
56+
57+
58+
59+
Name : xActiveDirectory
60+
61+
OnlineVersion : 2.22.0.0
62+
63+
InstalledVersion : 2.16.0.0,2.14.0.0
64+
65+
PublishedDate : 10/25/2018 5:25:24 PM
66+
67+
UpdateNeeded : True
68+
69+
70+
71+
Name : xAdcsDeployment
72+
73+
OnlineVersion : 1.4.0.0
74+
75+
InstalledVersion : 1.1.0.0,1.0.0.0
76+
77+
PublishedDate : 12/20/2017 10:10:43 PM
78+
79+
UpdateNeeded : True
80+
postCode: Get all DSC Resources that start with xAD and select the corresponding module name. Since the module name will be listed for every resource, get a unique list and pipe that to Compare-Module.
81+
inputs:
82+
- type: '[string]'
83+
description: ''
84+
links:
85+
- href: https://github.com/jdhitsolutions/PSScriptTools/blob/master/docs/Compare-Module.md
86+
text: 'Online Version:'
87+
- href: ''
88+
text: Find-Module
89+
- href: ''
90+
text: Get-Module
91+
- href: ''
92+
text: Update-Module
93+
module:
94+
name: PSScriptTools
95+
name: Compare-Module
96+
notes: 'Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/'
97+
optionalParameters:
98+
- name: Name
99+
acceptWildcardCharacters: true
100+
aliases:
101+
- modulename
102+
defaultValue: None
103+
description: The name of a module to check. Wildcards are permitted.
104+
parameterValueGroup: []
105+
pipelineInput: True (ByPropertyName)
106+
position: 1
107+
type: String
108+
- name: Gallery
109+
aliases: []
110+
defaultValue: PSGallery
111+
description: Specify the remote repository or gallery to check.
112+
parameterValueGroup: []
113+
pipelineInput: False
114+
position: Named
115+
type: String
116+
outputs:
117+
- type: PSCustomObject
118+
description: ''
119+
requiredParameters: []
120+
remarks: Use this command to compare module versions between what is installed against an online repository like the PSGallery. Results will be automatically sorted by module name.
121+
summary: Compare PowerShell module versions.
122+
syntaxes:
123+
- parameters:
124+
- Name
125+
- Gallery
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
examples:
2+
- name: Example 1
3+
preCode: ''
4+
code: >-
5+
PS C:\> Convert-CommandtoHashtable -Text "get-eventlog -listlog -computername a,b,c,d -erroraction stop"
6+
7+
8+
9+
$paramHash = @{
10+
11+
listlog = $True
12+
13+
computername = "a","b","c","d"
14+
15+
erroraction = "stop"
16+
17+
}
18+
19+
20+
21+
Get-EventLog @paramHash
22+
postCode: ''
23+
inputs:
24+
- type: None
25+
description: ''
26+
links:
27+
- href: https://github.com/jdhitsolutions/PSScriptTools/blob/master/docs/Convert-CommandtoHashtable.md
28+
text: 'Online Version:'
29+
- href: ''
30+
text: Convert-HashTableToCode
31+
module:
32+
name: PSScriptTools
33+
name: Convert-CommandtoHashtable
34+
notes: 'Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/'
35+
optionalParameters: []
36+
outputs:
37+
- type: '[Hashtable]'
38+
description: ''
39+
requiredParameters:
40+
- name: Text
41+
aliases: []
42+
defaultValue: None
43+
description: A PowerShell expression, preferably with named parameters.
44+
parameterValueGroup: []
45+
pipelineInput: False
46+
position: 0
47+
type: String
48+
remarks: This command is intended to convert a long PowerShell expression with named parameters into a splatting alternative.
49+
summary: Convert a PowerShell expression into a hashtable.
50+
syntaxes:
51+
- parameters:
52+
- Text

0 commit comments

Comments
 (0)