Skip to content

Commit

Permalink
see changelog for v2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Mar 14, 2019
1 parent b30200b commit 6365005
Show file tree
Hide file tree
Showing 11 changed files with 447 additions and 27 deletions.
Binary file modified PSScriptTools.psd1
Binary file not shown.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,28 @@ Now Home Seattle New Zealand

This is a handy command when traveling and your laptop is using a locally derived time and you want to see the time in other locations. It is recommended that you set a PSDefaultParameter value for the HomeTimeZone parameter in your PowerShell profile.

### [ConvertTo-LocalTime](docs/ConvertTo-LocalTime.md)

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.

```powershell
PS C:\> get-timezone -ListAvailable | where id -match hawaii
Id : Hawaiian Standard Time
DisplayName : (UTC-10:00) Hawaii
StandardName : Hawaiian Standard Time
DaylightName : Hawaiian Daylight Time
BaseUtcOffset : -10:00:00
SupportsDaylightSavingTime : False
PS C:\> Convertto-LocalTime "10:00AM" -10:00:00
Thursday, March 14, 2019 4:00:00 PM
```

In this example, the user if first determining the UTC offset for Hawaii. Then 10:00AM in say Honolulu, is converted to local time which in this example is in the Eastern Time zone.

## Console Utilities

### [Set-ConsoleTitle](docs/Set-ConsoleTitle.md)
Expand All @@ -818,4 +840,4 @@ PS C:\> Set-ConsoleColor -background DarkGray -foreground Yellow

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.

*last updated 11 March, 2019*
*last updated 14 March, 2019*
10 changes: 9 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# Change Log for PSScriptTools

## v2.6.0

+ Modified `Convertto-WPFGrid` to set maximum size equal to total available working area (Issue #36)
+ Modified `Convertto-WPFGrid` to change cursor on refresh and display a refresh message in the title bar
+ Added InitializationScript option for `ConvertTo-WPFGrid` (Issue #42)
+ Added `ConvertTo-LocalTime` with an alias of `clt`
+ Help updates

## v2.5.0

+ fixed bug which was hiding the horizontal scroll bar in `ConvertTo-WPFGrid` (Issue #40)
+ fixed bug which prevented status bar from updating when manually refreshing in `ConvertTo-WPFGrid` (Issue #34)
+ Changed time display in `ConvertTo-WPFGrid as a timespan instead of raw seconds (Issue #41)
+ Changed time display in `ConvertTo-WPFGrid` as a timespan instead of raw seconds (Issue #41)
+ Markdown help cleanup
+ Added `Set-ConsoleTitle`
+ Added `Set-ConsoleColor`
Expand Down
2 changes: 2 additions & 0 deletions docs/Convert-CommandtoHashtable.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@ For more information, see about_CommonParameters (http://go.microsoft.com/fwlink
Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/
## RELATED LINKS
[Convert-HashTableToCode]()
3 changes: 1 addition & 2 deletions docs/ConvertTo-UTCTime.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ For more information, see about_CommonParameters (http://go.microsoft.com/fwlink
## 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
Expand Down
42 changes: 34 additions & 8 deletions docs/ConvertTo-WPFGrid.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@ Send command output to an interactive WPF-based grid.
### input (Default)

```yaml
ConvertTo-WPFGrid [[-Title] <String>] [[-Timeout] <Int32>] [-Refresh] [-UseLocalVariable <String[]>]
[-UseProfile] [<CommonParameters>]
ConvertTo-WPFGrid [[-Title] <String>] [[-Timeout] <Int32>] [-Refresh] [-InitializationScript <ScriptBlock>]
[-UseLocalVariable <String[]>] [-UseProfile] [<CommonParameters>]
```

### Input

```yaml
ConvertTo-WPFGrid [[-InputObject] <PSObject>] [[-Title] <String>] [[-Timeout] <Int32>] [-Refresh]
[-UseLocalVariable <String[]>] [-UseProfile] [<CommonParameters>]
[-InitializationScript <ScriptBlock>] [-UseLocalVariable <String[]>] [-UseProfile] [<CommonParameters>]
```

### scriptblock

```yaml
ConvertTo-WPFGrid [-Scriptblock <ScriptBlock>] [[-Title] <String>] [[-Timeout] <Int32>] [-Refresh]
[-UseLocalVariable <String[]>] [-UseProfile] [<CommonParameters>]
[-InitializationScript <ScriptBlock>] [-UseLocalVariable <String[]>] [-UseProfile] [<CommonParameters>]
```

## DESCRIPTION

This command is an alternative to Out-Gridview. It works much the same way. Run a PowerShell command and pipe it to this command. The output will be displayed in an auto-sized data grid. You can click on column headings to sort. You can resize columns and you can re-order columns. You will want to be selective about which properties you pipe through to this command. See examples.

You can specify a timeout value which will automatically close the form. If you specify a timeout and the Refresh parameter, then the contents of the datagrid will automatically refreshed using the timeout value as an integer. This will only work when you pipe a PowerShell expression to ConvertTo-WPFGrid as one command. This will fail if you break the command in the PowerShell ISE or use a nested prompt. Beginning with v2.4.0 the form now has a Refresh button which will automatically refresh the datagrid.
You can specify a timeout value which will automatically close the form. If you specify a timeout and the Refresh parameter, then the contents of the datagrid will automatically refreshed using the timeout value as an integer. This will only work when you pipe a PowerShell expression to ConvertTo-WPFGrid as one command. This will fail if you break the command in the PowerShell ISE or use a nested prompt. Beginning with v2.4.0 the form now has a Refresh button which will automatically refresh the datagrid. You should set a refresh interval that is greater than the time it takes to complete the command.

Because the grid is running in a new background runspace, it does not automatically inherit anything from your current session. However, you can use the -UserProfile parameter which will load your user profile scripts into the runspace. You can also specify a list of locally defined variables to be used in the form.
Because the grid is running in a new background runspace, it does not automatically inherit anything from your current session. However, you can use the -UserProfile parameter which will load your user profile scripts into the runspace. You can specify a list of locally defined variables to be used in the form. Use the variable name without the $. Finally, you can also use the -InitializationScript parameter and specify a scriptblock of PowerShell code to initialize the runspace. This is helpful when you need to dot source external scripts or import modules not in your module path.

This command runs the WPF grid in a new runspace so your PowerShell prompt will not be blocked. However, after closing the form you may be left with the runspace. You can use Remove-Runspace to clean up or wait until you restart PowerShell.

Expand Down Expand Up @@ -74,6 +74,14 @@ PS C:\> Get-VMData -host CHI-HVR2 | ConvertTo-WPFGrid -title "VM Data" -refresh

This example uses a hypothetical command that might be defined in a PowerShell profile script. ConvertTo-WPFGrid will load the profile scripts so that the data can be updated every 60 seconds.

### EXAMPLE 4

```powershell
PS C:\> (get-processdata -Computername $computers).where({$_.workingset -ge 100mb}) | ConvertTo-WPFGrid -Title "Process Report" -UseLocalVariable computers -InitializationScript {. C:\scripts\Get-ProcessData.ps1} -Refresh -Timeout 30
```

This command runs a function that is defined in a script file. In order for the form to refresh, it must also dot source the script which is happening with the InitializationScript parameter. The example is also loading the local $computers variable so that it too is available upon refresh.

## PARAMETERS

### -InputObject
Expand Down Expand Up @@ -126,7 +134,9 @@ Accept wildcard characters: False
### -Refresh
If you specify this parameter and a Timeout value, this command will refresh the datagrid with the PowerShell expression piped into ConvertTo-WPFGrid. This will only work if you are using this command at the end of a pipelined expression. See examples.
If you specify this parameter and a Timeout value, this command will refresh the datagrid with the PowerShell expression piped into ConvertTo-WPFGrid. You should use a value that is longer than the time it takes to complete the command that generates your data.
This parameter will only work if you are using Convertto-WPFGrid at the end of a pipelined expression. See examples.
```yaml
Type: SwitchParameter
Expand Down Expand Up @@ -188,6 +198,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -InitializationScript
Run this scriptblock to initialize the background runspace. You might need to dot source a script file or load a non-standard module.
```yaml
Type: ScriptBlock
Parameter Sets: (All)
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).
Expand All @@ -210,4 +236,4 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
[ConvertTo-HTML]()
[ConvertTo-Markdown](./ConvertTo-Markdown.md)
[ConvertTo-Markdown](./ConvertTo-Markdown.md)
115 changes: 115 additions & 0 deletions docs/Convertto-LocalTime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
external help file: PSScriptTools-help.xml
Module Name: PSScriptTools
online version:
schema: 2.0.0
---

# Convertto-LocalTime

## SYNOPSIS

Convert a foreign time to local

## SYNTAX

```yaml
Convertto-LocalTime [-Datetime] <DateTime> [-UTCOffset] <TimeSpan> [<CommonParameters>]
```

## DESCRIPTION

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. You can use Get-Timezone to help. See examples.

## EXAMPLES

### Example 1

```powershell
PS C:\> ConvertTo-LocalTime "3/15/2019 7:00AM" 8:00:00
Thursday, March 14, 2019 7:00:00 PM
```

Convert a time that is in Singapore to local (Eastern) time.

### Example 2

```powershell
PS C:\> get-timezone -ListAvailable | where id -match hawaii
Id : Hawaiian Standard Time
DisplayName : (UTC-10:00) Hawaii
StandardName : Hawaiian Standard Time
DaylightName : Hawaiian Daylight Time
BaseUtcOffset : -10:00:00
SupportsDaylightSavingTime : False
PS C:\> ConvertTo-LocalTime "10:00AM" -10:00:00
Thursday, March 14, 2019 4:00:00 PM
```

In this example, the user if first determining the UTC offset for Hawaii. Then 10:00AM in say Honolulu, is converted to local time which in this example is in the Eastern Time zone.

## PARAMETERS

### -Datetime

Enter a non-local date time

```yaml
Type: DateTime
Parameter Sets: (All)
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -UTCOffset
Enter the location's' UTC Offset. You can use Get-Timezone to discover it.
```yaml
Type: TimeSpan
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
### DateTime
## NOTES
Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/
## RELATED LINKS
[Get-TimeZone]()
[Get-MyTimeInfo]()
[ConvertFrom-UTCTime]()
[ConvertTo-UTCTime]()
10 changes: 7 additions & 3 deletions docs/PSScriptTools.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,14 @@ Convert a universal time to local time.

Display a time settings for a collection of locations.

### [Set-ConsoleTitle](./Set-ConsoleTitle)
### [Set-ConsoleTitle](./Set-ConsoleTitle.md)

Set the title bar of the current PowerShell console window.

### [Set-ConsoleColor](./Set-ConsoleColor)
### [Set-ConsoleColor](./Set-ConsoleColor.md)

Configure the foreground or background color of the current PowerShell console window.
Configure the foreground or background color of the current PowerShell console window.

### [ConvertTo-LocalTime](./ConvertTo-LocalTime.md)

Convert a non-local datetime to your local time.
Loading

0 comments on commit 6365005

Please sign in to comment.