-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
176 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
version: 0.6.{build} | ||
skip_tags: true | ||
only_commits: | ||
files: | ||
- psCheckPoint/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Wait-CheckPointTask | ||
|
||
## SYNOPSIS | ||
Waits for task to complete. | ||
|
||
## SYNTAX | ||
|
||
``` | ||
Wait-CheckPointTask [-SleepTime <Int32>] [-Timeout <Int32>] -TaskID <String> [-Session] <CheckPointSession> | ||
``` | ||
|
||
## DESCRIPTION | ||
Waits for task to complete then returns the completed task details. | ||
|
||
## EXAMPLES | ||
|
||
### ---------- EXAMPLE 1 ---------- | ||
``` | ||
Install-CheckPointPolicy -Session $Session -PolicyPackage Standard -Targets MyGateway | Wait-CheckPointTask -Session $Session -Verbose | ||
``` | ||
|
||
## PARAMETERS | ||
|
||
### -Session | ||
Session object from Open-CheckPointSession | ||
|
||
```yaml | ||
Type: CheckPointSession | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: True | ||
Position: 0 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -SleepTime | ||
Time in seconds to sleep in-between checking task status | ||
```yaml | ||
Type: Int32 | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: Named | ||
Default value: 5 | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -TaskID | ||
Unique identifier of task | ||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: True | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: True (ByPropertyName, ByValue) | ||
Accept wildcard characters: False | ||
``` | ||
### -Timeout | ||
Timeout in seconds. | ||
```yaml | ||
Type: Int32 | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: Named | ||
Default value: 300 | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
## INPUTS | ||
### System.String | ||
Unique identifier of task | ||
## OUTPUTS | ||
## NOTES | ||
## RELATED LINKS | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Management.Automation; | ||
using System.Threading; | ||
|
||
namespace psCheckPoint.Objects.Misc | ||
{ | ||
/// <extra category="Misc. Commands">Wait-CheckPointTask</extra> | ||
/// <summary> | ||
/// <para type="synopsis">Waits for task to complete.</para> | ||
/// <para type="description">Waits for task to complete then returns the completed task details.</para> | ||
/// </summary> | ||
/// <example> | ||
/// <code>Install-CheckPointPolicy -Session $Session -PolicyPackage Standard -Targets MyGateway | Wait-CheckPointTask -Session $Session -Verbose</code> | ||
/// </example> | ||
[Cmdlet(VerbsLifecycle.Wait, "CheckPointTask")] | ||
public class WaitCheckPointTask : GetCheckPointTask | ||
{ | ||
/// <summary> | ||
/// <para type="description">Time in seconds to sleep in-between checking task status</para> | ||
/// </summary> | ||
[Parameter] | ||
public int SleepTime { get; set; } = 5; | ||
|
||
/// <summary> | ||
/// <para type="description">Timeout in seconds.</para> | ||
/// </summary> | ||
[Parameter] | ||
[ValidateRange(1, 3600)] | ||
public int Timeout { get; set; } = 300; | ||
|
||
private Stopwatch watch; | ||
|
||
protected override void WriteRecordResponse(CheckPointTasks result) | ||
{ | ||
if (watch == null) | ||
{ | ||
watch = Stopwatch.StartNew(); | ||
} | ||
CheckPointTask task = result.Tasks.First(); | ||
if (task == null) | ||
{ | ||
throw new System.Exception("Task not found"); | ||
} | ||
|
||
if (task.ProgressPercentage == 100) | ||
{ | ||
WriteVerbose($"Task {task.ProgressPercentage}% complete. Exiting."); | ||
WriteObject(task); | ||
} | ||
else if (watch.ElapsedMilliseconds >= Timeout * 1000) | ||
{ | ||
WriteVerbose($"Task {task.ProgressPercentage}% complete. Timeout reached, exiting."); | ||
WriteObject(task); | ||
} | ||
else | ||
{ | ||
WriteVerbose($"Task {task.ProgressPercentage}% complete"); | ||
Thread.Sleep(SleepTime * 1000); | ||
this.ProcessRecord(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters