Skip to content

Commit 9ab8c31

Browse files
authored
Merge pull request #633 from TheJumpCloud/CUT-3883_NewJCReports
CUT-3883/CUT-3884: JCReport Functions
2 parents 04e14b9 + 5ba092b commit 9ab8c31

File tree

13 files changed

+953
-121
lines changed

13 files changed

+953
-121
lines changed

PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@ $ApprovedFunctions = [Ordered]@{
1010
Name = 'Get-JcSdkEventCount';
1111
Destination = '/Public/DirectoryInsights';
1212
}
13+
# [PSCustomObject]@{
14+
# Name = 'Get-JcSdkReport';
15+
# Destination = '/Public/Reports';
16+
# },
17+
# [PSCustomObject]@{
18+
# Name = 'New-JcSdkReport';
19+
# Destination = '/Public/Reports';
20+
# }
1321
);
14-
# 'JumpCloud.SDK.V2' = @(
22+
#'JumpCloud.SDK.V2' = @(
1523
# [PSCustomObject]@{
1624
# Name = 'Get-JcSdkAppleMdm';
1725
# Destination = '/Public/AppleMdm';
@@ -60,7 +68,7 @@ $ApprovedFunctions = [Ordered]@{
6068
# Name = 'Get-JcSdkAppleMdmEnrollmentProfile';
6169
# Destination = '/Public/AppleMdm';
6270
# }
63-
# )
71+
#)
6472
}
6573
$SdkPrefix = 'JcSdk'
6674
$JumpCloudModulePrefix = 'JC'
@@ -136,6 +144,11 @@ If (-not [System.String]::IsNullOrEmpty($Modules)) {
136144
$Params = $FunctionContent | Select-String -Pattern:([regex]'(?s)( \[Parameter)(.*?)(\})') -AllMatches
137145
$ParameterContent = ($Params.Matches.Value | Where-Object { $_ -notlike '*DontShow*' -and $_ -notlike '${Limit}' -and $_ -notlike '*${Skip}*' })
138146

147+
# Check if there is only one parameter
148+
if ($ParameterContent -is [string]) {
149+
$ParameterContent = @($ParameterContent)
150+
}
151+
139152
for ($i = 0; $i -lt $ParameterContent.Count; $i++) {
140153
if ($i -ne ($ParameterContent.Count - 1 )) {
141154
$ParameterContent[$i] = $($ParameterContent[$i].Replace('}', '},'))
@@ -175,10 +188,9 @@ If (-not [System.String]::IsNullOrEmpty($Modules)) {
175188
# $EndContent = @()
176189
# Build "Begin" block
177190

178-
If (-not [System.String]::IsNullOrEmpty($BeginContent) -and -not [System.String]::IsNullOrEmpty($ProcessContent) -and -not [System.String]::IsNullOrEmpty($EndContent)) {
179-
# Build "Function"
180-
# $NewScript = $FunctionTemplate -f $PSScriptInfo, $NewCommandName, $CmdletBinding, $ParameterContent, $BeginContent, $ProcessContent, $EndContent
181-
$NewScript = @"
191+
# Build "Function"
192+
# $NewScript = $FunctionTemplate -f $PSScriptInfo, $NewCommandName, $CmdletBinding, $ParameterContent, $BeginContent, $ProcessContent, $EndContent
193+
$NewScript = @"
182194
$PSScriptInfo
183195
Function $NewCommandName {
184196
$($OutputType)
@@ -198,20 +210,20 @@ $paramString
198210
}
199211
}
200212
"@
201-
# $NewScript = $FunctionTemplate -f $PSScriptInfo, $NewCommandName, $CmdletBinding, ($ParameterContent -join ", `n`n"), ($BeginContent -join "`n"), ($ProcessContent -join "`n"), ($EndContent -join "`n")
202-
# Fix line endings
203-
# $NewScript = $NewScript.Replace("`r`n", "`n").Trim()
204-
# Export the function
205-
Write-Host ("[STATUS] Writing File: $OutputPath/$NewCommandName") -BackgroundColor:('Black') -ForegroundColor:('Magenta')
206-
$OutputFilePath = "$OutputPath/$NewCommandName.ps1"
207-
New-FolderRecursive -Path:($OutputFilePath) -Force
208-
$NewScript | Out-File -FilePath:($OutputFilePath) -Force
209-
# Validate script syntax
210-
$ScriptAnalyzerResult = Invoke-ScriptAnalyzer -Path:($OutputFilePath) -Recurse -ExcludeRule PSShouldProcess, PSAvoidTrailingWhitespace, PSAvoidUsingWMICmdlet, PSAvoidUsingPlainTextForPassword, PSAvoidUsingUsernameAndPasswordParams, PSAvoidUsingInvokeExpression, PSUseDeclaredVarsMoreThanAssignments, PSUseSingularNouns, PSAvoidGlobalVars, PSUseShouldProcessForStateChangingFunctions, PSAvoidUsingWriteHost, PSAvoidUsingPositionalParameters
211-
If ($ScriptAnalyzerResult) {
212-
$ScriptAnalyzerResults += $ScriptAnalyzerResult
213-
}
213+
# $NewScript = $FunctionTemplate -f $PSScriptInfo, $NewCommandName, $CmdletBinding, ($ParameterContent -join ", `n`n"), ($BeginContent -join "`n"), ($ProcessContent -join "`n"), ($EndContent -join "`n")
214+
# Fix line endings
215+
# $NewScript = $NewScript.Replace("`r`n", "`n").Trim()
216+
# Export the function
217+
Write-Host ("[STATUS] Writing File: $OutputPath/$NewCommandName") -BackgroundColor:('Black') -ForegroundColor:('Magenta')
218+
$OutputFilePath = "$OutputPath/$NewCommandName.ps1"
219+
New-FolderRecursive -Path:($OutputFilePath) -Force
220+
$NewScript | Out-File -FilePath:($OutputFilePath) -Force
221+
# Validate script syntax
222+
$ScriptAnalyzerResult = Invoke-ScriptAnalyzer -Path:($OutputFilePath) -Recurse -ExcludeRule PSShouldProcess, PSAvoidTrailingWhitespace, PSAvoidUsingWMICmdlet, PSAvoidUsingPlainTextForPassword, PSAvoidUsingUsernameAndPasswordParams, PSAvoidUsingInvokeExpression, PSUseDeclaredVarsMoreThanAssignments, PSUseSingularNouns, PSAvoidGlobalVars, PSUseShouldProcessForStateChangingFunctions, PSAvoidUsingWriteHost, PSAvoidUsingPositionalParameters
223+
If ($ScriptAnalyzerResult) {
224+
$ScriptAnalyzerResults += $ScriptAnalyzerResult
214225
}
226+
215227
# Copy tests?
216228
# Copy-Item -Path:($AutoRest_Tests) -Destination:($JCModule_Tests) -Force
217229
# Update .Psd1 file

PowerShell/JumpCloud Module/Docs/Connect-JCOnline.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The Connect-JCOnline function sets the global variable $JCAPIKEY
1313
## SYNTAX
1414

1515
```
16-
Connect-JCOnline [-force] [[-JumpCloudApiKey] <String>]
16+
Connect-JCOnline [-force] [-JumpCloudApiKey] <String>
1717
[[-JumpCloudOrgId] <String>] [[-JCEnvironment] <String>] [<CommonParameters>]
1818
```
1919

@@ -88,7 +88,7 @@ Type: System.String
8888
Parameter Sets: (All)
8989
Aliases:
9090

91-
Required: False
91+
Required: True
9292
Position: 1
9393
Default value: None
9494
Accept pipeline input: True (ByPropertyName)
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
external help file: JumpCloud-help.xml
3+
Module Name: JumpCloud
4+
online version: https://github.com/TheJumpCloud/support/wiki/
5+
schema: 2.0.0
6+
---
7+
8+
# Get-JCReport
9+
10+
## SYNOPSIS
11+
Ordered list of report metadata
12+
13+
## SYNTAX
14+
15+
### List (Default)
16+
```
17+
Get-JCReport [-Sort <Sort>] [<CommonParameters>]
18+
```
19+
20+
### Report
21+
```
22+
Get-JCReport [-Sort <Sort>] -ReportID <String> -Type <String>
23+
[<CommonParameters>]
24+
```
25+
26+
## DESCRIPTION
27+
Ordered list of report metadata
28+
29+
## EXAMPLES
30+
31+
### EXAMPLE 1
32+
```
33+
Get-JCReport
34+
```
35+
36+
Returns a list of all available reports
37+
38+
### EXAMPLE 2
39+
```
40+
Get-JCReport -Sort 'CREATED_AT'
41+
```
42+
43+
Returns a list of all available reports, sorted by the most recently created report
44+
45+
### EXAMPLE 3
46+
```
47+
$lastReport = Get-JCReport -Sort 'CREATED_AT' | Select -First 1
48+
$reportContent = Get-JCReport -reportID $lastReport.id -type 'json'
49+
```
50+
51+
Returns the report's content in JSON format from the last generated report
52+
53+
### EXAMPLE 4
54+
```
55+
$lastReport = Get-JCReport -Sort 'CREATED_AT' | Select -First 1
56+
$reportContent = Get-JCReport -reportID $lastReport.id -type 'csv'
57+
```
58+
59+
Returns the report's content in CSV format from the last generated report
60+
61+
## PARAMETERS
62+
63+
### -ReportID
64+
ID of the Report request.
65+
66+
```yaml
67+
Type: System.String
68+
Parameter Sets: Report
69+
Aliases: id
70+
71+
Required: True
72+
Position: Named
73+
Default value: None
74+
Accept pipeline input: True (ByPropertyName)
75+
Accept wildcard characters: False
76+
```
77+
78+
### -Sort
79+
Sort type and direction.
80+
Default sort is descending, prefix with - to sort ascending.
81+
82+
```yaml
83+
Type: JumpCloud.SDK.DirectoryInsights.Support.Sort
84+
Parameter Sets: (All)
85+
Aliases:
86+
87+
Required: False
88+
Position: Named
89+
Default value: None
90+
Accept pipeline input: False
91+
Accept wildcard characters: False
92+
```
93+
94+
### -Type
95+
Output type of the report content, either CSV or JSON
96+
97+
```yaml
98+
Type: System.String
99+
Parameter Sets: Report
100+
Aliases:
101+
102+
Required: True
103+
Position: Named
104+
Default value: None
105+
Accept pipeline input: False
106+
Accept wildcard characters: False
107+
```
108+
109+
### CommonParameters
110+
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).
111+
112+
## INPUTS
113+
114+
## OUTPUTS
115+
116+
### JumpCloud.SDK.DirectoryInsights.Models.IGet200ApplicationJsonItemsItem
117+
## NOTES
118+
119+
## RELATED LINKS
120+
121+
[https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/docs/exports/Get-JcSdkReport.md](https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/docs/exports/Get-JcSdkReport.md)

PowerShell/JumpCloud Module/Docs/JumpCloud.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Module Name: JumpCloud
33
Module Guid: 31c023d1-a901-48c4-90a3-082f91b31646
44
Download Help Link: https://github.com/TheJumpCloud/support/wiki
5-
Help Version: 2.16.0
5+
Help Version: 2.17.0
66
Locale: en-Us
77
---
88

@@ -110,6 +110,9 @@ Returns the Radius reply attributes associated with a JumpCloud user group.
110110
### [Get-JCRadiusServer](Get-JCRadiusServer.md)
111111
Return JumpCloud radius server information.
112112

113+
### [Get-JCReport](Get-JCReport.md)
114+
Ordered list of report metadata
115+
113116
### [Get-JCScheduledUserstate](Get-JCScheduledUserstate.md)
114117
Returns scheduled userstate changes by state or returns a user's scheduled userstate changes
115118

@@ -181,6 +184,9 @@ This endpoint allows you to create a new Policy Group.
181184
### [New-JCRadiusServer](New-JCRadiusServer.md)
182185
Creates a JumpCloud radius server.
183186

187+
### [New-JCReport](New-JCReport.md)
188+
Request a JumpCloud report to be generated asynchronously
189+
184190
### [New-JCSystemGroup](New-JCSystemGroup.md)
185191
Creates a JumpCloud System Group
186192

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
---
2+
external help file: JumpCloud-help.xml
3+
Module Name: JumpCloud
4+
online version: https://github.com/TheJumpCloud/support/wiki/
5+
schema: 2.0.0
6+
---
7+
8+
# New-JCReport
9+
10+
## SYNOPSIS
11+
Request a JumpCloud report to be generated asynchronously
12+
13+
## SYNTAX
14+
15+
### Create (Default)
16+
```
17+
New-JCReport -ReportType <ReportType1> [-WhatIf] [-Confirm]
18+
[<CommonParameters>]
19+
```
20+
21+
### CreateViaIdentity
22+
```
23+
New-JCReport -InputObject <IDirectoryInsightsApiIdentity> [-WhatIf]
24+
[-Confirm] [<CommonParameters>]
25+
```
26+
27+
## DESCRIPTION
28+
Request a JumpCloud report to be generated asynchronously
29+
30+
## EXAMPLES
31+
32+
### EXAMPLE 1
33+
```
34+
New-JCReport -ReportType 'users-to-sso-applications'
35+
```
36+
37+
Queues creation of an user-to-sso-application report
38+
39+
### EXAMPLE 2
40+
```
41+
New-JCReport -ReportType 'users-to-devices'
42+
```
43+
44+
Queues creation of an users-to-devices report
45+
46+
## PARAMETERS
47+
48+
### -InputObject
49+
Identity Parameter
50+
To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
51+
52+
```yaml
53+
Type: JumpCloud.SDK.DirectoryInsights.Models.IDirectoryInsightsApiIdentity
54+
Parameter Sets: CreateViaIdentity
55+
Aliases:
56+
57+
Required: True
58+
Position: Named
59+
Default value: None
60+
Accept pipeline input: True (ByValue)
61+
Accept wildcard characters: False
62+
```
63+
64+
### -ReportType
65+
Report Type
66+
67+
```yaml
68+
Type: JumpCloud.SDK.DirectoryInsights.Support.ReportType1
69+
Parameter Sets: Create
70+
Aliases:
71+
72+
Required: True
73+
Position: Named
74+
Default value: None
75+
Accept pipeline input: False
76+
Accept wildcard characters: False
77+
```
78+
79+
### -Confirm
80+
Prompts you for confirmation before running the cmdlet.
81+
82+
```yaml
83+
Type: System.Management.Automation.SwitchParameter
84+
Parameter Sets: (All)
85+
Aliases: cf
86+
87+
Required: False
88+
Position: Named
89+
Default value: None
90+
Accept pipeline input: False
91+
Accept wildcard characters: False
92+
```
93+
94+
### -WhatIf
95+
Shows what would happen if the cmdlet runs.
96+
The cmdlet is not run.
97+
98+
```yaml
99+
Type: System.Management.Automation.SwitchParameter
100+
Parameter Sets: (All)
101+
Aliases: wi
102+
103+
Required: False
104+
Position: Named
105+
Default value: None
106+
Accept pipeline input: False
107+
Accept wildcard characters: False
108+
```
109+
110+
### CommonParameters
111+
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).
112+
113+
## INPUTS
114+
115+
### JumpCloud.SDK.DirectoryInsights.Models.IDirectoryInsightsApiIdentity
116+
## OUTPUTS
117+
118+
### JumpCloud.SDK.DirectoryInsights.Models.IPathsE6Q3GdReportsReportTypePostResponses202ContentApplicationJsonSchema
119+
## NOTES
120+
COMPLEX PARAMETER PROPERTIES
121+
122+
To create the parameters described below, construct a hash table containing the appropriate properties.
123+
For information on hash tables, run Get-Help about_Hash_Tables.
124+
125+
INPUTOBJECT \<IDirectoryInsightsApiIdentity\>: Identity Parameter
126+
\[ReportType \<ReportType1?\>\]: Report Type
127+
128+
## RELATED LINKS
129+
130+
[https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/docs/exports/New-JcSdkReport.md](https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/docs/exports/New-JcSdkReport.md)

0 commit comments

Comments
 (0)