Skip to content

Commit 0f10717

Browse files
v2.29.0
1 parent 8ce0fab commit 0f10717

10 files changed

+359
-22
lines changed

PSScriptTools.psd1

76 Bytes
Binary file not shown.

PSScriptToolsManual.pdf

6.05 KB
Binary file not shown.

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,23 @@ Uninstall-Module PSScriptTools -allversions
5050

5151
## General Tools
5252

53+
### [Copy-PSFunction](docs/Copy-PSFunction.md)
54+
55+
This command is designed to solve the problem when you want to run a function loaded locally on a remote computer. Copy-PSFunction will copy a PowerShell function that is loaded in your current PowerShell session to a remote PowerShell session. The remote session must already be created. The copied function only exists remotely for the duration of the remote PowerShell session.
56+
57+
```powershell
58+
$s = new-pssession -ComputerName win10 -cred $art
59+
Copy-PSFunction Get-Status -Session $s
60+
```
61+
62+
Once copied, you might use `Invoke-Command` to run it.
63+
64+
```powershell
65+
Invoke-Command { get-status -asstring } -session $s
66+
```
67+
68+
If the function relies on external or additional files, you will have to copy them to the remote session separately.
69+
5370
### [Get-PSProfile](docs/Get-PSProfile.md)
5471

5572
This command is designed for Windows systems and make it easy to identify all possible PowerShell profile scripts. Including those for hosts such as VSCode or the PowerShell ISE. The command writes a custom object to the pipeline which has defined formatting. The default view is a table.
@@ -354,7 +371,7 @@ New-PSDrivehere \\ds416\backup\ Backup
354371

355372
### [Get-MyVariable](docs/Get-MyVariable.md)
356373

357-
This function will return all variables not defined by PowerShell or by this function itself. The default is to return all user-created variables from the global scope but you can also specify a scope such as script, local or a number 0 through 5.
374+
This function will return all variables not defined by PowerShell or by this function itself. The default is to return all user-created variables from the global scope but you can also specify a scope such as `script`, `local` or a number 0 through 5.
358375

359376
```text
360377
PS C:\> Get-MyVariable
@@ -1048,7 +1065,7 @@ This is a handy command when traveling and your laptop is using a locally derive
10481065
It can be tricky sometimes to see a time in a foreign location and try to figure out what that time is locally. This command attempts to simplify this process. In addition to the remote time, you need the base UTC offset for the remote location.
10491066

10501067
```text
1051-
PS C:\> Get-TimeZone -ListAvailable | Where-Object id -match hawaii
1068+
PS C:\> Get-TimeZone -ListAvailable | Where-Object id -match Hawaii
10521069
10531070
10541071
Id : Hawaiian Standard Time
@@ -1628,7 +1645,7 @@ OperatingSystem : Microsoft Windows 10 Pro
16281645
Runtime : 40.21:12:01
16291646
```
16301647

1631-
If you run this command within VS Code and specify `-Passthru`, the resulting file will be opened in your editor.
1648+
If you run this command from Visual Studio Code and specify `-Passthru`, the resulting file will be opened in your editor.
16321649

16331650
### [Test-IsPSWindows](docs/Test-IsPSWindows.md)
16341651

@@ -1815,4 +1832,4 @@ If you find this module useful, you might also want to look at my PowerShell too
18151832

18161833
Where possible these commands have been tested with PowerShell 7, but not every platform. If you encounter problems, have suggestions or other feedback, please post an [issue](https://github.com/jdhitsolutions/PSScriptTools/issues). It is assumed you will __not__ be running these commands on any edition of PowerShell Core or any beta releases of PowerShell 7.
18171834

1818-
Last Updated *2020-09-11 12:18:44Z*
1835+
Last Updated *2020-09-29 12:53:26Z*

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# ChangeLog for PSScriptTools
22

3+
## v2.29.0
4+
5+
+ Modified `Get-WindowsVersion` to not use remoting when connecting to the local computer. (Issue #90)
6+
+ Updated help documentation for `Get-WindowsVersion` and `Get-WindowsVersionString`.
7+
+ Added command `Copy-PSFunction` with an alias of `cpfun`.
8+
39
## v2.28.0
410

511
+ Added `Compare-Script` thanks to @cohdjn.

docs/Copy-PSFunction.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
external help file: PSScriptTools-help.xml
3+
Module Name: PSScriptTools
4+
online version: https://github.com/jdhitsolutions/PSScriptTools/blob/master/docs/Copy-PSFunction.md
5+
schema: 2.0.0
6+
---
7+
8+
# Copy-PSFunction
9+
10+
## SYNOPSIS
11+
12+
Copy a local PowerShell function to a remote session.
13+
14+
## SYNTAX
15+
16+
```yaml
17+
Copy-PSFunction [-Name] <String[]> -Session <PSSession> [-Force] [<CommonParameters>]
18+
```
19+
20+
## DESCRIPTION
21+
22+
This command is designed to solve the problem when you want to run a function loaded locally on a remote computer. Copy-PSFunction will copy a PowerShell function that is loaded in your current PowerShell session to a remote PowerShell session. The remote session must already be created. The copied function only exists remotely for the duration of the remote PowerShell session.
23+
24+
If the function relies on external or additional files, you will have to copy them to the remote session separately.
25+
26+
## EXAMPLES
27+
28+
### Example 1
29+
30+
```powershell
31+
PS C:\> "Get-LastBoot","Get-DiskFree" | Copy-PSFunction -session $S
32+
```
33+
34+
Copy the local functions Get-LastBoot and Get-DiskFree to a previously created PSSession saved as $S. You could then run the function remotely using Invoke-Command.
35+
36+
## PARAMETERS
37+
38+
### -Force
39+
40+
Overwrite an existing function with the same name. The default behavior is to skip existing functions.
41+
42+
```yaml
43+
Type: SwitchParameter
44+
Parameter Sets: (All)
45+
Aliases:
46+
47+
Required: False
48+
Position: Named
49+
Default value: None
50+
Accept pipeline input: False
51+
Accept wildcard characters: False
52+
```
53+
54+
### -Name
55+
56+
Enter the name of a local function.
57+
58+
```yaml
59+
Type: String[]
60+
Parameter Sets: (All)
61+
Aliases:
62+
63+
Required: True
64+
Position: 1
65+
Default value: None
66+
Accept pipeline input: True (ByValue)
67+
Accept wildcard characters: False
68+
```
69+
70+
### -Session
71+
72+
Specify an existing PSSession.
73+
74+
```yaml
75+
Type: PSSession
76+
Parameter Sets: (All)
77+
Aliases:
78+
79+
Required: True
80+
Position: Named
81+
Default value: None
82+
Accept pipeline input: False
83+
Accept wildcard characters: False
84+
```
85+
86+
### CommonParameters
87+
88+
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).
89+
90+
## INPUTS
91+
92+
### System.String[]
93+
94+
## OUTPUTS
95+
96+
### Deserialized.System.Management.Automation.FunctionInfo
97+
98+
## NOTES
99+
100+
Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/
101+
102+
## RELATED LINKS
103+
104+
[Copy-Item]()

docs/Get-WindowsVersion.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Get-WindowsVersion [[-Computername] <String[]>] [-Credential <PSCredential>]
2222

2323
This is a PowerShell version of the winver.exe utility. This command uses PowerShell remoting to query the registry on a remote machine to retrieve Windows version information. The parameters are the same as in Invoke-Command.
2424

25+
If you are querying the local computer, all other parameters will be ignored.
26+
2527
## EXAMPLES
2628

2729
### EXAMPLE 1
@@ -68,7 +70,7 @@ Windows Server 2016 Standard ServerStandardEval 1607 14393 2/6/2020 5
6870
Evaluation
6971
```
7072

71-
Get windows version information from remote computers using an alternate credential.
73+
Get Windows version information from remote computers using an alternate credential.
7274

7375
### Example 3
7476

@@ -183,7 +185,7 @@ The default value is Default.
183185
184186
CredSSP authentication is available only in Windows Vista, Windows Server 2008, and later versions of the Windows operating system.
185187
186-
For information about the values of this parameter, see the description of the AuthenticationMechanismEnumeration (http://go.microsoft.com/fwlink/?LinkID=144382) in theMicrosoft Developer Network (MSDN) library.
188+
For information about the values of this parameter, see the description of the AuthenticationMechanismEnumeration (http://go.microsoft.com/fwlink/?LinkID=144382) in the Microsoft Developer Network (MSDN) library.
187189
188190
CAUTION: Credential Security Support Provider (CredSSP) authentication, in which the user's credentials are passed to a remote computer to be authenticated, is designed for commands that require authentication on more than one resource, such as accessing a remote network share.
189191
This mechanism increases the security risk of the remote operation. If the remote computer is compromised, the credentials that are passed to it can be used to control the network session.

docs/Get-WindowsVersionString.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Get-WindowsVersionString [[-Computername] <String[]>]
2323

2424
This is a PowerShell version of the winver.exe utility.T his command uses PowerShell remoting to query the registry on a remote machine to retrieve Windows version information. The parameters are the same as in Invoke-Command. The command writes a string of version information.
2525

26+
If you are querying the local computer, all other parameters will be ignored.
27+
2628
## EXAMPLES
2729

2830
### EXAMPLE 1
@@ -141,7 +143,7 @@ The default value is Default.
141143
142144
CredSSP authentication is available only in Windows Vista, Windows Server 2008, and later versions of the Windows operating system.
143145
144-
For information about the values of this parameter, see the description of the AuthenticationMechanismEnumeration (http://go.microsoft.com/fwlink/?LinkID=144382) in theMicrosoft Developer Network (MSDN) library.
146+
For information about the values of this parameter, see the description of the AuthenticationMechanismEnumeration (http://go.microsoft.com/fwlink/?LinkID=144382) in the Microsoft Developer Network (MSDN) library.
145147
146148
CAUTION: Credential Security Support Provider (CredSSP) authentication, in which the user's credentials are passed to a remote computer to be authenticated, is designed for commands that require authentication on more than one resource, such as accessing a remote network share.
147149
This mechanism increases the security risk of the remote operation. If the remote computer is compromised, the credentials that are passed to it can be used to control the network session.

0 commit comments

Comments
 (0)