Skip to content

Commit

Permalink
Merge pull request #301 from TheJumpCloud/SA-1824_JCDeploymentWithSDK…
Browse files Browse the repository at this point in the history
…Functions

Sa 1824 jc deployment with sdk functions
  • Loading branch information
jworkmanjc authored May 3, 2021
2 parents 5c2b5c5 + 0e5896c commit 52cd6f9
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 59 deletions.
7 changes: 3 additions & 4 deletions PowerShell/JumpCloud Module/Docs/Get-JCEvent.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Query the API for Directory Insights events
### GetExpanded (Default)
```
Get-JCEvent -Service <String[]> -StartTime <DateTime> [-EndTime <DateTime>] [-Fields <String[]>]
[-SearchAfter <String[]>] [-SearchTermAnd <Hashtable>] [-SearchTermOr <Hashtable>] [-Sort <String>] [-WhatIf]
[-Confirm] [<CommonParameters>]
[-SearchAfter <IEventQuerySearchAfterItem[]>] [-SearchTermAnd <Hashtable>] [-SearchTermOr <Hashtable>]
[-Sort <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### Get
Expand Down Expand Up @@ -137,7 +137,7 @@ Accept wildcard characters: False
Specific query to search after, see x-* response headers for next values
```yaml
Type: System.String[]
Type: JumpCloud.SDK.DirectoryInsights.Models.IEventQuerySearchAfterItem[]
Parameter Sets: GetExpanded
Aliases:

Expand Down Expand Up @@ -264,7 +264,6 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## OUTPUTS
### JumpCloud.SDK.DirectoryInsights.Models.IPost200ApplicationJsonItemsItem
### System.String
## NOTES
COMPLEX PARAMETER PROPERTIES
To create the parameters described below, construct a hash table containing the appropriate properties.
Expand Down
7 changes: 3 additions & 4 deletions PowerShell/JumpCloud Module/Docs/Get-JCEventCount.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Query the API for a count of matching events
### GetExpanded (Default)
```
Get-JCEventCount -Service <String[]> -StartTime <DateTime> [-EndTime <DateTime>] [-Fields <String[]>]
[-SearchAfter <String[]>] [-SearchTermAnd <Hashtable>] [-SearchTermOr <Hashtable>] [-Sort <String>] [-WhatIf]
[-Confirm] [<CommonParameters>]
[-SearchAfter <IEventQuerySearchAfterItem[]>] [-SearchTermAnd <Hashtable>] [-SearchTermOr <Hashtable>]
[-Sort <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### Get
Expand Down Expand Up @@ -109,7 +109,7 @@ Accept wildcard characters: False
Specific query to search after, see x-* response headers for next values
```yaml
Type: System.String[]
Type: JumpCloud.SDK.DirectoryInsights.Models.IEventQuerySearchAfterItem[]
Parameter Sets: GetExpanded
Aliases:

Expand Down Expand Up @@ -236,7 +236,6 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## OUTPUTS
### System.Int64
### System.String
## NOTES
COMPLEX PARAMETER PROPERTIES
Expand Down
2 changes: 1 addition & 1 deletion PowerShell/JumpCloud Module/Docs/JumpCloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Module Name: JumpCloud
Module Guid: 31c023d1-a901-48c4-90a3-082f91b31646
Download Help Link: https://github.com/TheJumpCloud/support/wiki
Help Version: 1.18.3
Help Version: 1.18.4
Locale: en-US
---

Expand Down
24 changes: 24 additions & 0 deletions PowerShell/JumpCloud Module/Docs/New-JCDeploymentTemplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,30 @@ New-JCDeploymentTemplate [<CommonParameters>]
## DESCRIPTION
The New-JCDeploymentTemplate command is a menu driven interactive function that guides admins through the process of creating a command deployment CSV file and assists in gathering the required information needed to populate the command deployment CSV file.

Note: Windows commands and Mac/Linux commands interpret variables differently. Windows commands with variables you wish to replace during Invoke-JCDeployment should be written as `${ENV:$variableToReplace}` within the command body. The header variables of Windows Command Deployment CSVs should be prefixed with `$`

Example valid Windows PowerShell command:
`Invoke-WebRequest -Uri $url -OutFile ${ENV:$UserPath}\${ENV:$FileName}`

Example Valid Mac/Linux CSV:
| "SystemID" | "$UserPath" | "$FileName" |
|-------------------------- |------------------------- |----------------------- |
| 602c4806e87bc117c434fb71 | "C:\Users\Joe\Desktop" | "PDF_JoeToSign.pdf" |
| 60623c9d0bab5a18614d4d6d | "C:\Users\Bob\Desktop" | "PDF_BobToSign.pdf" |
| 6025b5aa115b9917f6903436 | "C:\Users\Steve\Desktop" | "PDF_SteveToSign.pdf" |

Mac and Linux commands work similarly in the sense that command body variables such as `$variableToReplace` will be replaced when running Invoke-JCDeployment. The header variables of a Mac/Linux Command Deployment CSV do not need to be prefixed with `$`

Example valid Mac/Linux command:
`curl -L -o $UserPath/$FileName $url >/dev/null`

Example Valid Mac/Linux CSV:
| "SystemID" | "UserPath" | "FileName" |
|-------------------------- |------------------------- |----------------------- |
| 602c4806e87bc117c434fb71 | "/Users/Joe/Desktop" | "PDF_JoeToSign.pdf" |
| 60623c9d0bab5a18614d4d6d | "/Users/Bob/Desktop" | "PDF_BobToSign.pdf" |
| 6025b5aa115b9917f6903436 | "/Users/Steve/Desktop" | "PDF_SteveToSign.pdf" |

## EXAMPLES

### Example 1
Expand Down
2 changes: 1 addition & 1 deletion PowerShell/JumpCloud Module/JumpCloud.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>JumpCloud</id>
<version>1.18.3</version>
<version>1.18.4</version>
<description>PowerShell functions to manage a JumpCloud Directory-as-a-Service</description>
<authors>JumpCloud Solutions Architect Team</authors>
<owners>JumpCloud</owners>
Expand Down
4 changes: 2 additions & 2 deletions PowerShell/JumpCloud Module/JumpCloud.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: JumpCloud Solutions Architect Team
#
# Generated on: 2/9/2021
# Generated on: 5/3/2021
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = 'JumpCloud.psm1'

# Version number of this module.
ModuleVersion = '1.18.3'
ModuleVersion = '1.18.4'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,18 @@ The CommandID will be the 24 character string populated for the _id field.')]
{
$trigger = Get-Date -Format MMddyyTHHmmss

$Command = Set-JCCommand -CommandID $CommandID -launchType trigger -trigger $trigger
# Get existing data, type, Shell from command
$ExistingCommand = Get-JCSDKCommand -Id $CommandID

# set command w/ origional type and new trigger
$Command = Set-JCSDKCommand -ID $CommandID -launchType trigger -trigger $trigger -Command $ExistingCommand.Command1 -CommandType $ExistingCommand.CommandType -Shell $ExistingCommand.Shell

$DeploymentInfo = Import-Csv $CSVFilePath

$Variables = $DeploymentInfo[0].psobject.Properties.Name | Where-Object {$_ -ne "SystemID"}

[int]$NumberOfVariables = $Variables.Count

[int]$ProgressCounter = 0

[int]$SystemCount = $DeploymentInfo.SystemID.Count

foreach ($Target in $DeploymentInfo)
Expand All @@ -172,10 +174,9 @@ The CommandID will be the 24 character string populated for the _id field.')]

[int]$Counter = 1


foreach ($Var in $Variables)
{
Write-Verbose "Adding PARAMETER: $Var to DEPLOY COMMAND"
Write-Verbose "Adding PARAMETER: $Var with value $($Target | Select-Object -ExpandProperty $var) to DEPLOY COMMAND"

$DeploymentParams.Add("Variable" + $($Counter) + "_name", "$Var")
$DeploymentParams.Add("Variable" + $($Counter) + "_value", "$($Target | Select-Object -ExpandProperty $var)")
Expand Down Expand Up @@ -206,12 +207,8 @@ The CommandID will be the 24 character string populated for the _id field.')]

$resultsArray += $SingleResult


}

$null = Set-JCCommand -CommandID $CommandID -launchType manual


$null = Set-JCSDKCommand -ID $CommandID -launchType manual -Command $ExistingCommand.Command1 -CommandType $ExistingCommand.CommandType -Shell $ExistingCommand.Shell
}

end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ Get all events filtered by organization_update term between a date range
JumpCloud.SDK.DirectoryInsights.Models.IEventQuery
.Outputs
JumpCloud.SDK.DirectoryInsights.Models.IPost200ApplicationJsonItemsItem
.Outputs
System.String
.Notes
COMPLEX PARAMETER PROPERTIES
Expand All @@ -53,7 +51,7 @@ BODY <IEventQuery>: EventQuery is the users' command to search our auth logs
[EndTime <DateTime?>]: optional query end time, UTC in RFC3339 format
[Fields <String[]>]: optional list of fields to return from query
[Limit <Int64?>]: Max number of rows to return
[SearchAfter <String[]>]: Specific query to search after, see x-* response headers for next values
[SearchAfter <IEventQuerySearchAfterItem[]>]: Specific query to search after, see x-* response headers for next values
[SearchTermAnd <ITermConjunction>]: TermConjunction represents a conjunction (and/or) NOTE: the validator limits what the operator can be, not the object for future-proof-ness and a list of sub-values
[(Any) <Object>]: This indicates any property can be added to this object.
[SearchTermOr <ITermConjunction>]: TermConjunction represents a conjunction (and/or) NOTE: the validator limits what the operator can be, not the object for future-proof-ness and a list of sub-values
Expand All @@ -63,7 +61,7 @@ https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/Jum
#>
Function Get-JCEvent
{
[OutputType([JumpCloud.SDK.DirectoryInsights.Models.IPost200ApplicationJsonItemsItem], [System.String])]
[OutputType([JumpCloud.SDK.DirectoryInsights.Models.IPost200ApplicationJsonItemsItem])]
[CmdletBinding(DefaultParameterSetName='GetExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
Param(
[Parameter(ParameterSetName='GetExpanded', Mandatory)]
Expand Down Expand Up @@ -93,7 +91,7 @@ Function Get-JCEvent

[Parameter(ParameterSetName='GetExpanded')]
[JumpCloud.SDK.DirectoryInsights.Category('Body')]
[System.String[]]
[JumpCloud.SDK.DirectoryInsights.Models.IEventQuerySearchAfterItem[]]
# Specific query to search after, see x-* response headers for next values
${SearchAfter},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ Get only group_create event counts the last thirty days
JumpCloud.SDK.DirectoryInsights.Models.IEventQuery
.Outputs
System.Int64
.Outputs
System.String
.Notes
COMPLEX PARAMETER PROPERTIES
Expand All @@ -37,7 +35,7 @@ BODY <IEventQuery>: EventQuery is the users' command to search our auth logs
[EndTime <DateTime?>]: optional query end time, UTC in RFC3339 format
[Fields <String[]>]: optional list of fields to return from query
[Limit <Int64?>]: Max number of rows to return
[SearchAfter <String[]>]: Specific query to search after, see x-* response headers for next values
[SearchAfter <IEventQuerySearchAfterItem[]>]: Specific query to search after, see x-* response headers for next values
[SearchTermAnd <ITermConjunction>]: TermConjunction represents a conjunction (and/or) NOTE: the validator limits what the operator can be, not the object for future-proof-ness and a list of sub-values
[(Any) <Object>]: This indicates any property can be added to this object.
[SearchTermOr <ITermConjunction>]: TermConjunction represents a conjunction (and/or) NOTE: the validator limits what the operator can be, not the object for future-proof-ness and a list of sub-values
Expand All @@ -47,7 +45,7 @@ https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/Jum
#>
Function Get-JCEventCount
{
[OutputType([System.Int64], [System.String])]
[OutputType([System.Int64])]
[CmdletBinding(DefaultParameterSetName='GetExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
Param(
[Parameter(ParameterSetName='GetExpanded', Mandatory)]
Expand Down Expand Up @@ -77,7 +75,7 @@ Function Get-JCEventCount

[Parameter(ParameterSetName='GetExpanded')]
[JumpCloud.SDK.DirectoryInsights.Category('Body')]
[System.String[]]
[JumpCloud.SDK.DirectoryInsights.Models.IEventQuerySearchAfterItem[]]
# Specific query to search after, see x-* response headers for next values
${SearchAfter},

Expand Down
9 changes: 7 additions & 2 deletions PowerShell/JumpCloud Module/Tests/SetupOrg.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Try
SystemWindows = Get-JCSystem -displayName:($PesterParams_SystemNameWindows)
CommandResults = Get-JCCommandResult
}

$PesterParamsHash_Associations = @{
PolicySystemGroupMembership = $PesterParamsHash_BuildOrg.MultiplePolicy | ForEach-Object {
If (-not (Get-JCAssociation -Type:('policy') -Id:($_.id) -TargetType:('system_group') | Where-Object { $_.targetId -eq $PesterParamsHash_BuildOrg.SystemGroup.id })) { New-JCAssociation -Type:('policy') -Id:($_.id) -TargetType:('system_group') -TargetId:($PesterParamsHash_BuildOrg.SystemGroup.id) -force; };
Expand All @@ -92,7 +93,7 @@ Try
Command2SystemGroupMembership = If (-not (Get-JCAssociation -Type:('command') -Id:($PesterParamsHash_BuildOrg.Command2._id) -TargetType:('system_group') | Where-Object { $_.targetId -eq $PesterParamsHash_BuildOrg.SystemGroup.id })) { New-JCAssociation -Type:('command') -Id:($PesterParamsHash_BuildOrg.Command2._id) -TargetType:('system_group') -TargetId:($PesterParamsHash_BuildOrg.SystemGroup.id) -force; };
Command3SystemGroupMembership = If (-not (Get-JCAssociation -Type:('command') -Id:($PesterParamsHash_BuildOrg.Command3._id) -TargetType:('system_group') | Where-Object { $_.targetId -eq $PesterParamsHash_BuildOrg.SystemGroup.id })) { New-JCAssociation -Type:('command') -Id:($PesterParamsHash_BuildOrg.Command3._id) -TargetType:('system_group') -TargetId:($PesterParamsHash_BuildOrg.SystemGroup.id) -force; };
}
# Generate command results of they dont exist
# Generate command results if they dont exist
If ([System.String]::IsNullOrEmpty($PesterParamsHash_BuildOrg.CommandResults) -or $PesterParamsHash_BuildOrg.CommandResults.Count -lt $PesterParams_CommandResultCount)
{
If (-not (Get-JCAssociation -Type:('command') -Id:($PesterParamsHash_BuildOrg.Command1._id) -TargetType:('system') | Where-Object { $_.targetId -eq $PesterParamsHash_BuildOrg.SystemLinux._id }))
Expand Down Expand Up @@ -121,5 +122,9 @@ Try
}
Catch
{
Write-Error ($_)
Write-Error ($_.Exception)
Write-Error ($_.FullyQualifiedErrorId)
Write-Error ($_.ScriptStackTrace)
Write-Error ($_.TargetObject)
Write-Error ($_.PSMessageDetails)
}
38 changes: 14 additions & 24 deletions PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4050,9 +4050,9 @@ PS C:\&gt; $BackupJcOrganizationResults.User</dev:code>
<maml:description>
<maml:para>Specific query to search after, see x-* response headers for next values</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue>
<command:parameterValue required="true" variableLength="false">JumpCloud.SDK.DirectoryInsights.Models.IEventQuerySearchAfterItem[]</command:parameterValue>
<dev:type>
<maml:name>System.String[]</maml:name>
<maml:name>JumpCloud.SDK.DirectoryInsights.Models.IEventQuerySearchAfterItem[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
Expand Down Expand Up @@ -4183,9 +4183,9 @@ PS C:\&gt; $BackupJcOrganizationResults.User</dev:code>
<maml:description>
<maml:para>Specific query to search after, see x-* response headers for next values</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue>
<command:parameterValue required="true" variableLength="false">JumpCloud.SDK.DirectoryInsights.Models.IEventQuerySearchAfterItem[]</command:parameterValue>
<dev:type>
<maml:name>System.String[]</maml:name>
<maml:name>JumpCloud.SDK.DirectoryInsights.Models.IEventQuerySearchAfterItem[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
Expand Down Expand Up @@ -4294,14 +4294,6 @@ PS C:\&gt; $BackupJcOrganizationResults.User</dev:code>
<maml:para></maml:para>
</maml:description>
</command:returnValue>
<command:returnValue>
<dev:type>
<maml:name>System.String</maml:name>
</dev:type>
<maml:description>
<maml:para></maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<maml:alertSet>
<maml:alert>
Expand Down Expand Up @@ -4455,9 +4447,9 @@ PS C:\&gt; $BackupJcOrganizationResults.User</dev:code>
<maml:description>
<maml:para>Specific query to search after, see x-* response headers for next values</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue>
<command:parameterValue required="true" variableLength="false">JumpCloud.SDK.DirectoryInsights.Models.IEventQuerySearchAfterItem[]</command:parameterValue>
<dev:type>
<maml:name>System.String[]</maml:name>
<maml:name>JumpCloud.SDK.DirectoryInsights.Models.IEventQuerySearchAfterItem[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
Expand Down Expand Up @@ -4588,9 +4580,9 @@ PS C:\&gt; $BackupJcOrganizationResults.User</dev:code>
<maml:description>
<maml:para>Specific query to search after, see x-* response headers for next values</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue>
<command:parameterValue required="true" variableLength="false">JumpCloud.SDK.DirectoryInsights.Models.IEventQuerySearchAfterItem[]</command:parameterValue>
<dev:type>
<maml:name>System.String[]</maml:name>
<maml:name>JumpCloud.SDK.DirectoryInsights.Models.IEventQuerySearchAfterItem[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
Expand Down Expand Up @@ -4699,14 +4691,6 @@ PS C:\&gt; $BackupJcOrganizationResults.User</dev:code>
<maml:para></maml:para>
</maml:description>
</command:returnValue>
<command:returnValue>
<dev:type>
<maml:name>System.String</maml:name>
</dev:type>
<maml:description>
<maml:para></maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<maml:alertSet>
<maml:alert>
Expand Down Expand Up @@ -9199,6 +9183,12 @@ SystemID CommandID Status
</command:details>
<maml:description>
<maml:para>The New-JCDeploymentTemplate command is a menu driven interactive function that guides admins through the process of creating a command deployment CSV file and assists in gathering the required information needed to populate the command deployment CSV file.</maml:para>
<maml:para>Note: Windows commands and Mac/Linux commands interpret variables differently. Windows commands with variables you wish to replace during Invoke-JCDeployment should be written as `${ENV:$variableToReplace}` within the command body. The header variables of Windows Command Deployment CSVs should be prefixed with `$`</maml:para>
<maml:para>Example valid Windows PowerShell command: `Invoke-WebRequest -Uri $url -OutFile ${ENV:$UserPath}\${ENV:$FileName}`</maml:para>
<maml:para>Example Valid Mac/Linux CSV: | "SystemID" | "$UserPath" | "$FileName" | |-------------------------- |------------------------- |----------------------- | | 602c4806e87bc117c434fb71 | "C:\Users\Joe\Desktop" | "PDF_JoeToSign.pdf" | | 60623c9d0bab5a18614d4d6d | "C:\Users\Bob\Desktop" | "PDF_BobToSign.pdf" | | 6025b5aa115b9917f6903436 | "C:\Users\Steve\Desktop" | "PDF_SteveToSign.pdf" |</maml:para>
<maml:para>Mac and Linux commands work similarly in the sense that command body variables such as `$variableToReplace` will be replaced when running Invoke-JCDeployment. The header variables of a Mac/Linux Command Deployment CSV do not need to be prefixed with `$`</maml:para>
<maml:para>Example valid Mac/Linux command: `curl -L -o $UserPath/$FileName $url &gt;/dev/null`</maml:para>
<maml:para>Example Valid Mac/Linux CSV: | "SystemID" | "UserPath" | "FileName" | |-------------------------- |------------------------- |----------------------- | | 602c4806e87bc117c434fb71 | "/Users/Joe/Desktop" | "PDF_JoeToSign.pdf" | | 60623c9d0bab5a18614d4d6d | "/Users/Bob/Desktop" | "PDF_BobToSign.pdf" | | 6025b5aa115b9917f6903436 | "/Users/Steve/Desktop" | "PDF_SteveToSign.pdf" |</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
Expand Down
2 changes: 1 addition & 1 deletion PowerShell/ModuleBanner.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#### Latest Version

```
1.18.3
1.18.4
```

#### Banner Current
Expand Down
Loading

0 comments on commit 52cd6f9

Please sign in to comment.