You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -792,6 +792,28 @@ Now Home Seattle New Zealand
792
792
793
793
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.
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.
798
+
799
+
```powershell
800
+
PS C:\> get-timezone -ListAvailable | where id -match hawaii
801
+
802
+
803
+
Id : Hawaiian Standard Time
804
+
DisplayName : (UTC-10:00) Hawaii
805
+
StandardName : Hawaiian Standard Time
806
+
DaylightName : Hawaiian Daylight Time
807
+
BaseUtcOffset : -10:00:00
808
+
SupportsDaylightSavingTime : False
809
+
810
+
PS C:\> Convertto-LocalTime "10:00AM" -10:00:00
811
+
812
+
Thursday, March 14, 2019 4:00:00 PM
813
+
```
814
+
815
+
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.
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.
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.
40
40
41
-
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.
41
+
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.
42
42
43
-
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.
43
+
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.
44
44
45
45
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.
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.
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.
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.
137
+
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.
138
+
139
+
This parameter will only work if you are using Convertto-WPFGrid at the end of a pipelined expression. See examples.
130
140
131
141
```yaml
132
142
Type: SwitchParameter
@@ -188,6 +198,22 @@ Accept pipeline input: False
188
198
Accept wildcard characters: False
189
199
```
190
200
201
+
### -InitializationScript
202
+
203
+
Run this scriptblock to initialize the background runspace. You might need to dot source a script file or load a non-standard module.
204
+
205
+
```yaml
206
+
Type: ScriptBlock
207
+
Parameter Sets: (All)
208
+
Aliases:
209
+
210
+
Required: False
211
+
Position: Named
212
+
Default value: None
213
+
Accept pipeline input: False
214
+
Accept wildcard characters: False
215
+
```
216
+
191
217
### CommonParameters
192
218
193
219
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).
@@ -210,4 +236,4 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
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.
Convert a time that is in Singapore to local (Eastern) time.
35
+
36
+
### Example 2
37
+
38
+
```powershell
39
+
PS C:\> get-timezone -ListAvailable | where id -match hawaii
40
+
41
+
42
+
Id : Hawaiian Standard Time
43
+
DisplayName : (UTC-10:00) Hawaii
44
+
StandardName : Hawaiian Standard Time
45
+
DaylightName : Hawaiian Daylight Time
46
+
BaseUtcOffset : -10:00:00
47
+
SupportsDaylightSavingTime : False
48
+
49
+
PS C:\> ConvertTo-LocalTime "10:00AM" -10:00:00
50
+
51
+
Thursday, March 14, 2019 4:00:00 PM
52
+
```
53
+
54
+
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.
55
+
56
+
## PARAMETERS
57
+
58
+
### -Datetime
59
+
60
+
Enter a non-local date time
61
+
62
+
```yaml
63
+
Type: DateTime
64
+
Parameter Sets: (All)
65
+
Aliases:
66
+
67
+
Required: True
68
+
Position: 0
69
+
Default value: None
70
+
Accept pipeline input: False
71
+
Accept wildcard characters: False
72
+
```
73
+
74
+
### -UTCOffset
75
+
76
+
Enter the location's' UTC Offset. You can use Get-Timezone to discover it.
77
+
78
+
```yaml
79
+
Type: TimeSpan
80
+
Parameter Sets: (All)
81
+
Aliases:
82
+
83
+
Required: True
84
+
Position: 1
85
+
Default value: None
86
+
Accept pipeline input: False
87
+
Accept wildcard characters: False
88
+
```
89
+
90
+
### CommonParameters
91
+
92
+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
93
+
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
94
+
95
+
## INPUTS
96
+
97
+
### None
98
+
99
+
## OUTPUTS
100
+
101
+
### DateTime
102
+
103
+
## NOTES
104
+
105
+
Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/
0 commit comments