From 4aa93b3c53233a772f6ea5db121226708f58804d Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Mon, 13 Jul 2020 09:04:56 -0600 Subject: [PATCH 01/29] Conditionally load ssl profile --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- PowerShell/JumpCloud Module/JumpCloud.psm1 | 19 +++++++++---------- PowerShell/ModuleBanner.md | 2 +- PowerShell/ModuleChangelog.md | 16 ++++++++++++++++ 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 45b930302..2ec4f6ef4 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '1.17.4' +ModuleVersion = '1.17.5' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PowerShell/JumpCloud Module/JumpCloud.psm1 b/PowerShell/JumpCloud Module/JumpCloud.psm1 index 4dbc3c4c8..5e8ffeb24 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psm1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psm1 @@ -1,14 +1,11 @@ # Load all functions from public and private folders $Public = @( Get-ChildItem -Path "$PSScriptRoot/Public/*.ps1" -Recurse ) $Private = @( Get-ChildItem -Path "$PSScriptRoot/Private/*.ps1" -Recurse) -Foreach ($Import in @($Public + $Private)) -{ - Try - { +Foreach ($Import in @($Public + $Private)) { + Try { . $Import.FullName } - Catch - { + Catch { Write-Error -Message "Failed to import function $($Import.FullName): $_" } } @@ -34,9 +31,10 @@ If ($PSVersionTable.PSEdition -eq 'Core') $PSDefaultParameterValues['Invoke-WebRequest:MaximumRetryCount'] = 5 $PSDefaultParameterValues['Invoke-WebRequest:RetryIntervalSec'] = 5 } -Else -{ - #Ignore SSL errors +Else { + #Ignore SSL errors / do not add policy if it exists + if (-Not [System.Net.ServicePointManager]::CertificatePolicy) + { Add-Type @" using System.Net; using System.Security.Cryptography.X509Certificates; @@ -48,7 +46,8 @@ Else } } "@ - [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy + [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy + } } # Set function aliases Set-Alias -Name:('New-JCAssociation') -Value:('Add-JCAssociation') diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index 03228d400..9e8656789 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,7 +1,7 @@ #### Latest Version ``` -1.17.4 +1.17.5 ``` #### Banner Current diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 8eedb03e4..90ad7d76c 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,19 @@ +## 1.17.5 + +Release Date: July 13, 2020 + +#### RELEASE NOTES + +Use Get-JCSystemInsight to query additional System Insights tables. + +#### FEATURES + +#### IMPROVEMENTS + +#### BUG FIXES + +Fix for windows PowerShell Update-JCModule function + ## 1.17.4 Release Date: July 9, 2020 From 99ee1efee25e813f30ad112df6947db0a90571d9 Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Mon, 13 Jul 2020 16:40:01 -0600 Subject: [PATCH 02/29] work in progress --- PowerShell/Deploy/Get-Config.ps1 | 3 + .../Deploy/SdkSync/jcapiToSupportSync.ps1 | 115 ++++++++++ PowerShell/Deploy/Setup-Dependencies.ps1 | 18 ++ PowerShell/JumpCloud Module/JumpCloud.psd1 | 207 +++++++++--------- 4 files changed, 239 insertions(+), 104 deletions(-) create mode 100644 PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 create mode 100644 PowerShell/Deploy/Setup-Dependencies.ps1 diff --git a/PowerShell/Deploy/Get-Config.ps1 b/PowerShell/Deploy/Get-Config.ps1 index c19887674..2a636f5c3 100755 --- a/PowerShell/Deploy/Get-Config.ps1 +++ b/PowerShell/Deploy/Get-Config.ps1 @@ -40,6 +40,9 @@ $RequiredFiles | ForEach-Object { # Get module function names $Functions_Public = If (Test-Path -Path:($FolderPath_Public)) { Get-ChildItem -Path:($FolderPath_Public + '/' + '*.ps1') -Recurse } $Functions_Private = If (Test-Path -Path:($FolderPath_Private)) { Get-ChildItem -Path:($FolderPath_Private + '/' + '*.ps1') -Recurse } +# Get psd1 contents +$Psd1 = Import-PowerShellDataFile -Path:($FilePath_psd1) +$RequiredModules = $Psd1.RequiredModules # Load deploy functions $DeployFunctions = @(Get-ChildItem -Path:($PSScriptRoot + '/Functions/*.ps1') -Recurse) Foreach ($DeployFunction In $DeployFunctions) diff --git a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 new file mode 100644 index 000000000..c1ac035ef --- /dev/null +++ b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 @@ -0,0 +1,115 @@ +#Requires -PSEdition Core +$GitHubRoot = 'C:/Users/epanipinto/Documents/GitHub' #ex: C:/Users/epanipinto/Documents/GitHub +# $xapikeyPester = '' +# $xapikeyMTP = '' +$env:moduleRootFolder = "$GitHubRoot/support/PowerShell" +$env:deployFolder = "$env:moduleRootFolder/Deploy" +$env:MODULENAME = 'JumpCloud' +$env:MODULEFOLDERNAME = 'JumpCloud Module' +$env:RELEASETYPE = 'Minor' +# # $env:XAPIKEY_PESTER = $xapikeyPester +# # $env:XAPIKEY_MTP = $xapikeyMTP +# #################################################################################### +# #################################################################################### +# $AutoRest_Example = "$GitHubRoot/jcapi-powershell/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/examples/Get-JcSdkEvent.md" +# $AutoRest_Function = "$GitHubRoot/jcapi-powershell/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/exports/Get-JcSdkEvent.ps1" +# $AutoRest_HelpFile = "$GitHubRoot/jcapi-powershell/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/docs/exports/Get-JcSdkEvent.md" +# $AutoRest_Tests = "$GitHubRoot/jcapi-powershell/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/test/Get-JcSdkEvent.Tests.ps1" +# $Transformed_Function = "$GitHubRoot/jcapi-powershell/JumpCloud/JumpCloudV2/Get/Get-JCEvent.ps1" +# $JCModule_Function = "$GitHubRoot/support/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1" +# $JCModule_HelpFile = "$GitHubRoot/support/PowerShell/JumpCloud Module/Docs/Get-JCEvent.md" +# $JCModule_Tests = "$GitHubRoot/support/PowerShell/JumpCloud Module/Tests/Public/DirectoryInsights/Get-JCEvent.Tests.ps1" +# # Invoke-Item -Path:($JCModule_Function) +# #################################################################################### +# #################################################################################### +# .("$GitHubRoot/jcapi-powershell/SetupDependencies.ps1") +# .("$GitHubRoot/jcapi-powershell/BuildAutoRest.ps1") +# #################################################################################### +# # Restart your PowerShell session +# #################################################################################### +# .("$GitHubRoot/jcapi-powershell/JumpCloud/Install-Module.ps1") +# .("$GitHubRoot/jcapi-powershell/JumpCloud/Build-Module.ps1") +# Copy-Item -Path:($Transformed_Function) -Destination:($JCModule_Function) -Force +# Copy-Item -Path:($AutoRest_Tests) -Destination:($JCModule_Tests) -Force +# (Get-Content -Path:($JCModule_Tests) -Raw).Replace('JcSdk', 'JC').Replace('.ToJsonString() | ConvertFrom-Json', '').Replace("Describe 'Get-JCEvent'", "Describe 'Get-JCEvent' -Tag:('JCEvent')").Replace('$loadEnvPath = Join-Path $PSScriptRoot ''loadEnv.ps1'' +# if (-Not (Test-Path -Path $loadEnvPath)) +# { +# $loadEnvPath = Join-Path $PSScriptRoot ''..\loadEnv.ps1'' +# } +# . ($loadEnvPath) +# $TestRecordingFile = Join-Path $PSScriptRoot ''Get-JCEvent.Recording.json'' +# $currentPath = $PSScriptRoot +# while (-not $mockingPath) +# { +# $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include ''HttpPipelineMocking.ps1'' -File +# $currentPath = Split-Path -Path $currentPath -Parent +# } +# . ($mockingPath | Select-Object -First 1).FullName + +# ', '') | Set-Content -Path:($JCModule_Tests) +# Remove-Item -Path:($JCModule_HelpFile) +# #################################################################################### +# # Restart your PowerShell session +# #################################################################################### +# # Pipeline Steps +# # .("$env:deployFolder/Build-Module.ps1") +# # .("$env:deployFolder/Build-HelpFiles.ps1") +# # .("$env:deployFolder/Build-PesterTestFiles.ps1") +# # .("$env:moduleRootFolder/JumpCloud Module/Tests/InvokePester.ps1") -TestOrgAPIKey:($env:XAPIKEY_PESTER) -MultiTenantAPIKey:($env:XAPIKEY_MTP) -IncludeTagList:('ModuleValidation') +# # .("$env:moduleRootFolder/JumpCloud Module/Tests/InvokePester.ps1") -TestOrgAPIKey:($env:XAPIKEY_PESTER) -MultiTenantAPIKey:($env:XAPIKEY_MTP) -ExcludeTagList:('ModuleValidation', 'JCAssociation', 'JCUsersFromCSV') # -IncludeTagList:('') +# #################################################################################### +# #################################################################################### + +. 'C:\Users\epanipinto\Documents\GitHub\support\PowerShell\Deploy\Setup-Dependencies.ps1' +$ApprovedFunctions = [Ordered]@{ + 'JumpCloud.SDK.DirectoryInsights' = @('Get-JcSdkEvent') +} +$Modules = Get-Module -Name:($Psd1.RequiredModules) +ForEach ($Module In $Modules) +{ + $ModuleName = $Module.Name + $ModulePath = $Module.ModuleBase + ForEach ($FunctionName In $ApprovedFunctions.$ModuleName) + { + $Command = Get-Command -Name:($FunctionName) + # Get content from sdk function + $CommandFilePath = $Command.ScriptBlock.File + $CommandFilePathContent = Get-Content -Path:($CommandFilePath) -Raw + $FunctionContent = If ($CommandFilePath -like '*ProxyCmdletDefinitions.ps1') + { + <# When the autorest generated module has been installed and imported from the PSGallery all the + cmdlets will exist in a single ProxyCmdletDefinitions.ps1 file. We need to parse + out the specific function in order to gather the parts we need to copy over. #> + $CommandFilePathContent.Replace($MSCopyrightHeader, $Divider).Split($Divider).Where( { $_ -like ('*' + "function $CommandName {" + '*') }) + } + Else + { + <# When the autorest generated module has been imported from a local psd1 module the function will + remain in their individual files. #> + $CommandFilePathContent + } + $Params = $FunctionContent | Select-String -Pattern:('(?s)( \[Parameter)(.*?)(\})') -AllMatches + + } + # $ModulePath + # Copy-Item -Path:($Transformed_Function) -Destination:($JCModule_Function) -Force + # Copy-Item -Path:($AutoRest_Tests) -Destination:($JCModule_Tests) -Force + # (Get-Content -Path:($JCModule_Tests) -Raw).Replace('JcSdk', 'JC').Replace('.ToJsonString() | ConvertFrom-Json', '').Replace("Describe 'Get-JCEvent'", "Describe 'Get-JCEvent' -Tag:('JCEvent')").Replace('$loadEnvPath = Join-Path $PSScriptRoot ''loadEnv.ps1'' + # if (-Not (Test-Path -Path $loadEnvPath)) + # { + # $loadEnvPath = Join-Path $PSScriptRoot ''..\loadEnv.ps1'' + # } + # . ($loadEnvPath) + # $TestRecordingFile = Join-Path $PSScriptRoot ''Get-JCEvent.Recording.json'' + # $currentPath = $PSScriptRoot + # while (-not $mockingPath) + # { + # $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include ''HttpPipelineMocking.ps1'' -File + # $currentPath = Split-Path -Path $currentPath -Parent + # } + # . ($mockingPath | Select-Object -First 1).FullName + + # ', '') | Set-Content -Path:($JCModule_Tests) + # Remove-Item -Path:($JCModule_HelpFile) + +} \ No newline at end of file diff --git a/PowerShell/Deploy/Setup-Dependencies.ps1 b/PowerShell/Deploy/Setup-Dependencies.ps1 new file mode 100644 index 000000000..df8afb3a1 --- /dev/null +++ b/PowerShell/Deploy/Setup-Dependencies.ps1 @@ -0,0 +1,18 @@ +. ($PSScriptRoot + '/' + 'Get-Config.ps1') +########################################################################### +ForEach ($RequiredModule In $RequiredModules) +{ + Write-Host("Setting up dependency '$RequiredModule'") + # Check to see if the module is installed + If ([System.String]::IsNullOrEmpty((Get-InstalledModule).Where( { $_.Name -eq $RequiredModule }))) + { + Write-Host("Installing '$RequiredModule'") + Install-Module -Name:($RequiredModule) -Force + } + # Get-Module -Refresh -ListAvailable + If ([System.String]::IsNullOrEmpty((Get-Module).Where( { $_.Name -eq $RequiredModule }))) + { + Write-Host("Importing '$RequiredModule'") + Import-Module -Name:($RequiredModule) -Force + } +} \ No newline at end of file diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 45b930302..35fe01435 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,153 +3,152 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 7/9/2020 +# Generated on: 6/255555/2020 # @{ -# Script module or binary module file associated with this manifest. -RootModule = 'JumpCloud.psm1' + # Script module or binary module file associated with this manifest. + RootModule = 'JumpCloud.psm1' -# Version number of this module. -ModuleVersion = '1.17.4' + # Version number of this module. + ModuleVersion = '1.17.4' -# Supported PSEditions -# CompatiblePSEditions = @() + # Supported PSEditions + # CompatiblePSEditions = @() -# ID used to uniquely identify this module -GUID = '31c023d1-a901-48c4-90a3-082f91b31646' + # ID used to uniquely identify this module + GUID = '31c023d1-a901-48c4-90a3-082f91b31646' -# Author of this module -Author = 'JumpCloud Solutions Architect Team' + # Author of this module + Author = 'JumpCloud Solutions Architect Team' -# Company or vendor of this module -CompanyName = 'JumpCloud' + # Company or vendor of this module + CompanyName = 'JumpCloud' -# Copyright statement for this module -Copyright = '(c) JumpCloud. All rights reserved.' + # Copyright statement for this module + Copyright = '(c) JumpCloud. All rights reserved.' -# Description of the functionality provided by this module -Description = 'PowerShell functions to manage a JumpCloud Directory-as-a-Service' + # Description of the functionality provided by this module + Description = 'PowerShell functions to manage a JumpCloud Directory-as-a-Service' -# Minimum version of the PowerShell engine required by this module -PowerShellVersion = '4.0' + # Minimum version of the PowerShell engine required by this module + PowerShellVersion = '4.0' -# Name of the PowerShell host required by this module -# PowerShellHostName = '' + # Name of the PowerShell host required by this module + # PowerShellHostName = '' -# Minimum version of the PowerShell host required by this module -# PowerShellHostVersion = '' + # Minimum version of the PowerShell host required by this module + # PowerShellHostVersion = '' -# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. -# DotNetFrameworkVersion = '' + # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # DotNetFrameworkVersion = '' -# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. -# ClrVersion = '' + # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # ClrVersion = '' -# Processor architecture (None, X86, Amd64) required by this module -# ProcessorArchitecture = '' + # Processor architecture (None, X86, Amd64) required by this module + # ProcessorArchitecture = '' -# Modules that must be imported into the global environment prior to importing this module -RequiredModules = @('JumpCloud.SDK.DirectoryInsights') + # Modules that must be imported into the global environment prior to importing this module + RequiredModules = @('JumpCloud.SDK.DirectoryInsights', 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2') -# Assemblies that must be loaded prior to importing this module -# RequiredAssemblies = @() + # Assemblies that must be loaded prior to importing this module + # RequiredAssemblies = @() -# Script files (.ps1) that are run in the caller's environment prior to importing this module. -# ScriptsToProcess = @() + # Script files (.ps1) that are run in the caller's environment prior to importing this module. + # ScriptsToProcess = @() -# Type files (.ps1xml) to be loaded when importing this module -# TypesToProcess = @() + # Type files (.ps1xml) to be loaded when importing this module + # TypesToProcess = @() -# Format files (.ps1xml) to be loaded when importing this module -# FormatsToProcess = @() + # Format files (.ps1xml) to be loaded when importing this module + # FormatsToProcess = @() -# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess -# NestedModules = @() + # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess + # NestedModules = @() -# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. -FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget', - 'Add-JCRadiusReplyAttribute', 'Add-JCSystemGroupMember', - 'Add-JCSystemUser', 'Add-JCUserGroupMember', 'Connect-JCOnline', - 'Copy-JCAssociation', 'Get-JCAssociation', 'Get-JCBackup', - 'Get-JCCommand', 'Get-JCCommandResult', 'Get-JCCommandTarget', - 'Get-JCEvent', 'Get-JCGroup', 'Get-JCOrganization', 'Get-JCPolicy', - 'Get-JCPolicyResult', 'Get-JCPolicyTargetGroup', - 'Get-JCPolicyTargetSystem', 'Get-JCRadiusReplyAttribute', - 'Get-JCRadiusServer', 'Get-JCSystem', 'Get-JCSystemGroupMember', - 'Get-JCSystemInsights', 'Get-JCSystemUser', 'Get-JCUser', - 'Get-JCUserGroupMember', 'Import-JCCommand', 'Import-JCUsersFromCSV', - 'Invoke-JCCommand', 'Invoke-JCDeployment', 'New-JCCommand', - 'New-JCDeploymentTemplate', 'New-JCImportTemplate', - 'New-JCRadiusServer', 'New-JCSystemGroup', 'New-JCUser', - 'New-JCUserGroup', 'Remove-JCAssociation', 'Remove-JCCommand', - 'Remove-JCCommandResult', 'Remove-JCCommandTarget', - 'Remove-JCRadiusReplyAttribute', 'Remove-JCRadiusServer', - 'Remove-JCSystem', 'Remove-JCSystemGroup', - 'Remove-JCSystemGroupMember', 'Remove-JCSystemUser', 'Remove-JCUser', - 'Remove-JCUserGroup', 'Remove-JCUserGroupMember', - 'Send-JCPasswordReset', 'Set-JCCommand', 'Set-JCOrganization', - 'Set-JCRadiusReplyAttribute', 'Set-JCRadiusServer', 'Set-JCSystem', - 'Set-JCSystemUser', 'Set-JCUser', 'Set-JCUserGroupLDAP', - 'Update-JCModule', 'Update-JCUsersFromCSV' + # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. + FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget', + 'Add-JCRadiusReplyAttribute', 'Add-JCSystemGroupMember', + 'Add-JCSystemUser', 'Add-JCUserGroupMember', 'Connect-JCOnline', + 'Copy-JCAssociation', 'Get-JCAssociation', 'Get-JCBackup', + 'Get-JCCommand', 'Get-JCCommandResult', 'Get-JCCommandTarget', + 'Get-JCEvent', 'Get-JCGroup', 'Get-JCOrganization', 'Get-JCPolicy', + 'Get-JCPolicyResult', 'Get-JCPolicyTargetGroup', + 'Get-JCPolicyTargetSystem', 'Get-JCRadiusReplyAttribute', + 'Get-JCRadiusServer', 'Get-JCSystem', 'Get-JCSystemGroupMember', + 'Get-JCSystemInsights', 'Get-JCSystemUser', 'Get-JCUser', + 'Get-JCUserGroupMember', 'Import-JCCommand', 'Import-JCUsersFromCSV', + 'Invoke-JCCommand', 'Invoke-JCDeployment', 'New-JCCommand', + 'New-JCDeploymentTemplate', 'New-JCImportTemplate', + 'New-JCRadiusServer', 'New-JCSystemGroup', 'New-JCUser', + 'New-JCUserGroup', 'Remove-JCAssociation', 'Remove-JCCommand', + 'Remove-JCCommandResult', 'Remove-JCCommandTarget', + 'Remove-JCRadiusReplyAttribute', 'Remove-JCRadiusServer', + 'Remove-JCSystem', 'Remove-JCSystemGroup', + 'Remove-JCSystemGroupMember', 'Remove-JCSystemUser', 'Remove-JCUser', + 'Remove-JCUserGroup', 'Remove-JCUserGroupMember', + 'Send-JCPasswordReset', 'Set-JCCommand', 'Set-JCOrganization', + 'Set-JCRadiusReplyAttribute', 'Set-JCRadiusServer', 'Set-JCSystem', + 'Set-JCSystemUser', 'Set-JCUser', 'Set-JCUserGroupLDAP', + 'Update-JCModule', 'Update-JCUsersFromCSV' -# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. -CmdletsToExport = @() + # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. + CmdletsToExport = @() -# Variables to export from this module -VariablesToExport = '*' + # Variables to export from this module + VariablesToExport = '*' -# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. -AliasesToExport = 'New-JCAssociation' + # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. + AliasesToExport = 'New-JCAssociation' -# DSC resources to export from this module -# DscResourcesToExport = @() + # DSC resources to export from this module + # DscResourcesToExport = @() -# List of all modules packaged with this module -# ModuleList = @() + # List of all modules packaged with this module + # ModuleList = @() -# List of all files packaged with this module -# FileList = @() + # List of all files packaged with this module + # FileList = @() -# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. -PrivateData = @{ + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ - PSData = @{ + PSData = @{ - # Tags applied to this module. These help with module discovery in online galleries. - Tags = 'JumpCloud', 'DaaS', 'Jump', 'Cloud', 'Directory' + # Tags applied to this module. These help with module discovery in online galleries. + Tags = 'JumpCloud', 'DaaS', 'Jump', 'Cloud', 'Directory' - # A URL to the license for this module. - LicenseUri = 'https://github.com/TheJumpCloud/support/blob/master/PowerShell/LICENSE' + # A URL to the license for this module. + LicenseUri = 'https://github.com/TheJumpCloud/support/blob/master/PowerShell/LICENSE' - # A URL to the main website for this project. - ProjectUri = 'https://github.com/TheJumpCloud/support/wiki' + # A URL to the main website for this project. + ProjectUri = 'https://github.com/TheJumpCloud/support/wiki' - # A URL to an icon representing this module. - IconUri = 'https://avatars1.githubusercontent.com/u/4927461?s=200&v=4' + # A URL to an icon representing this module. + IconUri = 'https://avatars1.githubusercontent.com/u/4927461?s=200&v=4' - # ReleaseNotes of this module - ReleaseNotes = 'https://git.io/jc-pwsh-releasenotes' + # ReleaseNotes of this module + ReleaseNotes = 'https://git.io/jc-pwsh-releasenotes' - # Prerelease string of this module - # Prerelease = '' + # Prerelease string of this module + # Prerelease = '' - # Flag to indicate whether the module requires explicit user acceptance for install/update/save - # RequireLicenseAcceptance = $false + # Flag to indicate whether the module requires explicit user acceptance for install/update/save + # RequireLicenseAcceptance = $false - # External dependent modules of this module - # ExternalModuleDependencies = @() + # External dependent modules of this module + # ExternalModuleDependencies = @() - } # End of PSData hashtable + } # End of PSData hashtable -} # End of PrivateData hashtable + } # End of PrivateData hashtable -# HelpInfo URI of this module -HelpInfoURI = 'https://github.com/TheJumpCloud/support/wiki' + # HelpInfo URI of this module + HelpInfoURI = 'https://github.com/TheJumpCloud/support/wiki' -# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. -# DefaultCommandPrefix = '' + # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. + # DefaultCommandPrefix = '' } - From 0a7dab58944a65fa67d6508c1ddf427575d427ea Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Tue, 14 Jul 2020 09:34:30 -0600 Subject: [PATCH 03/29] add intergrate script --- .../Deploy/SdkSync/jcapiToSupportSync.ps1 | 154 ++++++++---------- .../Public/DirectoryInsights/Get-JCEvent.ps1 | 129 ++++----------- .../DirectoryInsights/Get-JCEventCount.ps1 | 127 +++++++++++++++ 3 files changed, 222 insertions(+), 188 deletions(-) create mode 100644 PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 diff --git a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 index c1ac035ef..61de38bfb 100644 --- a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 +++ b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 @@ -1,77 +1,39 @@ -#Requires -PSEdition Core -$GitHubRoot = 'C:/Users/epanipinto/Documents/GitHub' #ex: C:/Users/epanipinto/Documents/GitHub -# $xapikeyPester = '' -# $xapikeyMTP = '' -$env:moduleRootFolder = "$GitHubRoot/support/PowerShell" -$env:deployFolder = "$env:moduleRootFolder/Deploy" -$env:MODULENAME = 'JumpCloud' -$env:MODULEFOLDERNAME = 'JumpCloud Module' -$env:RELEASETYPE = 'Minor' -# # $env:XAPIKEY_PESTER = $xapikeyPester -# # $env:XAPIKEY_MTP = $xapikeyMTP -# #################################################################################### -# #################################################################################### -# $AutoRest_Example = "$GitHubRoot/jcapi-powershell/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/examples/Get-JcSdkEvent.md" -# $AutoRest_Function = "$GitHubRoot/jcapi-powershell/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/exports/Get-JcSdkEvent.ps1" -# $AutoRest_HelpFile = "$GitHubRoot/jcapi-powershell/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/docs/exports/Get-JcSdkEvent.md" -# $AutoRest_Tests = "$GitHubRoot/jcapi-powershell/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/test/Get-JcSdkEvent.Tests.ps1" -# $Transformed_Function = "$GitHubRoot/jcapi-powershell/JumpCloud/JumpCloudV2/Get/Get-JCEvent.ps1" -# $JCModule_Function = "$GitHubRoot/support/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1" -# $JCModule_HelpFile = "$GitHubRoot/support/PowerShell/JumpCloud Module/Docs/Get-JCEvent.md" -# $JCModule_Tests = "$GitHubRoot/support/PowerShell/JumpCloud Module/Tests/Public/DirectoryInsights/Get-JCEvent.Tests.ps1" -# # Invoke-Item -Path:($JCModule_Function) -# #################################################################################### -# #################################################################################### -# .("$GitHubRoot/jcapi-powershell/SetupDependencies.ps1") -# .("$GitHubRoot/jcapi-powershell/BuildAutoRest.ps1") -# #################################################################################### -# # Restart your PowerShell session -# #################################################################################### -# .("$GitHubRoot/jcapi-powershell/JumpCloud/Install-Module.ps1") -# .("$GitHubRoot/jcapi-powershell/JumpCloud/Build-Module.ps1") -# Copy-Item -Path:($Transformed_Function) -Destination:($JCModule_Function) -Force -# Copy-Item -Path:($AutoRest_Tests) -Destination:($JCModule_Tests) -Force -# (Get-Content -Path:($JCModule_Tests) -Raw).Replace('JcSdk', 'JC').Replace('.ToJsonString() | ConvertFrom-Json', '').Replace("Describe 'Get-JCEvent'", "Describe 'Get-JCEvent' -Tag:('JCEvent')").Replace('$loadEnvPath = Join-Path $PSScriptRoot ''loadEnv.ps1'' -# if (-Not (Test-Path -Path $loadEnvPath)) -# { -# $loadEnvPath = Join-Path $PSScriptRoot ''..\loadEnv.ps1'' -# } -# . ($loadEnvPath) -# $TestRecordingFile = Join-Path $PSScriptRoot ''Get-JCEvent.Recording.json'' -# $currentPath = $PSScriptRoot -# while (-not $mockingPath) -# { -# $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include ''HttpPipelineMocking.ps1'' -File -# $currentPath = Split-Path -Path $currentPath -Parent -# } -# . ($mockingPath | Select-Object -First 1).FullName - -# ', '') | Set-Content -Path:($JCModule_Tests) -# Remove-Item -Path:($JCModule_HelpFile) -# #################################################################################### -# # Restart your PowerShell session -# #################################################################################### -# # Pipeline Steps -# # .("$env:deployFolder/Build-Module.ps1") -# # .("$env:deployFolder/Build-HelpFiles.ps1") -# # .("$env:deployFolder/Build-PesterTestFiles.ps1") -# # .("$env:moduleRootFolder/JumpCloud Module/Tests/InvokePester.ps1") -TestOrgAPIKey:($env:XAPIKEY_PESTER) -MultiTenantAPIKey:($env:XAPIKEY_MTP) -IncludeTagList:('ModuleValidation') -# # .("$env:moduleRootFolder/JumpCloud Module/Tests/InvokePester.ps1") -TestOrgAPIKey:($env:XAPIKEY_PESTER) -MultiTenantAPIKey:($env:XAPIKEY_MTP) -ExcludeTagList:('ModuleValidation', 'JCAssociation', 'JCUsersFromCSV') # -IncludeTagList:('') -# #################################################################################### -# #################################################################################### - -. 'C:\Users\epanipinto\Documents\GitHub\support\PowerShell\Deploy\Setup-Dependencies.ps1' $ApprovedFunctions = [Ordered]@{ - 'JumpCloud.SDK.DirectoryInsights' = @('Get-JcSdkEvent') + 'JumpCloud.SDK.DirectoryInsights' = @( + [PSCustomObject]@{ + Destination = '/Public/DirectoryInsights' + Name = 'Get-JcSdkEvent' + }, + [PSCustomObject]@{ + Destination = '/Public/DirectoryInsights' + Name = 'Get-JcSdkEventCount' + } + ) } -$Modules = Get-Module -Name:($Psd1.RequiredModules) +$SdkPrefix = 'JcSdk' +$JumpCloudModulePrefix = 'JC' +$IndentChar = ' ' +$MSCopyrightHeader = "`n# ----------------------------------------------------------------------------------`n#`n# Copyright Microsoft Corporation`n# Licensed under the Apache License, Version 2.0 (the ""License"");`n# you may not use this file except in compliance with the License.`n# You may obtain a copy of the License at`n# http://www.apache.org/licenses/LICENSE-2.0`n# Unless required by applicable law or agreed to in writing, software`n# distributed under the License is distributed on an ""AS IS"" BASIS,`n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.`n# See the License for the specific language governing permissions and`n# limitations under the License.`n# ----------------------------------------------------------------------------------`n" +$Divider = '|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|' +$FunctionTemplate = "{0}`nFunction {1}`n{{`n$($IndentChar){2}`n$($IndentChar)Param(`n{3}`n$($IndentChar))`n$($IndentChar)Begin`n$($IndentChar){{`n{4}`n$($IndentChar)}}`n$($IndentChar)Process`n$($IndentChar){{`n{5}`n$($IndentChar)}}`n$($IndentChar)End`n$($IndentChar){{`n{6}`n$($IndentChar)}}`n}}" +$ScriptAnalyzerResults = @() +$JumpCloudModulePath = (Get-Item -Path:($PSScriptRoot)).Parent.Parent.FullName + '/JumpCloud Module' +##################################################################### +. ((Get-Item -Path:($PSScriptRoot)).Parent.FullName + '/Setup-Dependencies.ps1') +##################################################################### +$Modules = Get-Module -Name:($Psd1.RequiredModules | Where-Object { $_ -in $ApprovedFunctions.Keys }) ForEach ($Module In $Modules) { $ModuleName = $Module.Name - $ModulePath = $Module.ModuleBase - ForEach ($FunctionName In $ApprovedFunctions.$ModuleName) + ForEach ($Function In $ApprovedFunctions.$ModuleName) { + $FunctionName = $Function.Name + $FunctionDestination = $Function.Destination + $OutputPath = "$JumpCloudModulePath/$FunctionDestination" $Command = Get-Command -Name:($FunctionName) + $CommandName = $Command.Name + $NewCommandName = $CommandName.Replace($SdkPrefix, $JumpCloudModulePrefix) + Write-Host ("[STATUS] Building: $NewCommandName") -BackgroundColor:('Black') -ForegroundColor:('Magenta') # Get content from sdk function $CommandFilePath = $Command.ScriptBlock.File $CommandFilePathContent = Get-Content -Path:($CommandFilePath) -Raw @@ -88,28 +50,42 @@ ForEach ($Module In $Modules) remain in their individual files. #> $CommandFilePathContent } + $PSScriptInfo = ($FunctionContent | Select-String -Pattern:('(?s)(<#)(.*?)(#>)')).Matches.Value $Params = $FunctionContent | Select-String -Pattern:('(?s)( \[Parameter)(.*?)(\})') -AllMatches - + $ParameterContent = ($Params.Matches.Value | Where-Object { $_ -notlike '*DontShow*' -and $_ -notlike '*Limit*' -and $_ -notlike '*Skip*' }) + $OutputType = ($FunctionContent | Select-String -Pattern:('(\[OutputType)(.*?)(\]\r)')).Matches.Value + $CmdletBinding = ($FunctionContent | Select-String -Pattern:('(\[CmdletBinding)(.*?)(\]\r)')).Matches.Value + $PSScriptInfo = $PSScriptInfo.Replace($SdkPrefix, $JumpCloudModulePrefix) + # Build CmdletBinding + If (-not [System.String]::IsNullOrEmpty($OutputType)) { $CmdletBinding = "$($OutputType)`n$($IndentChar)$($CmdletBinding)" } + # Build $BeginContent, $ProcessContent, and $EndContent + $BeginContent = @() + $ProcessContent = @() + $EndContent = @() + # Build "Begin" block + $BeginContent += "$($IndentChar)$($IndentChar)Connect-JCOnline -force | Out-Null" + $BeginContent += "$($IndentChar)$($IndentChar)`$Results = @()" + # Build "Process" block + $ProcessContent += "$($IndentChar)$($IndentChar)`$Results = $($ModuleName)\$($CommandName) @PSBoundParameters" + # Build "End" block + $EndContent += "$($IndentChar)$($IndentChar)Return `$Results" + If (-not [System.String]::IsNullOrEmpty($BeginContent) -and -not [System.String]::IsNullOrEmpty($ProcessContent) -and -not [System.String]::IsNullOrEmpty($EndContent)) + { + # Build "Function" + $NewScript = $FunctionTemplate -f $PSScriptInfo, $NewCommandName, $CmdletBinding, ($ParameterContent -join ",`n`n"), ($BeginContent -join "`n"), ($ProcessContent -join "`n"), ($EndContent -join "`n") + # Fix line endings + $NewScript = $NewScript.Replace("`r`n", "`n").Trim() + # Export the function + $OutputFilePath = "$OutputPath/$NewCommandName.ps1" + $NewScript | Out-File -FilePath:($OutputFilePath) -Force + # Validate script syntax + $ScriptAnalyzerResult = Invoke-ScriptAnalyzer -Path:($OutputFilePath) -Recurse -ExcludeRule PSShouldProcess, PSAvoidTrailingWhitespace, PSAvoidUsingWMICmdlet, PSAvoidUsingPlainTextForPassword, PSAvoidUsingUsernameAndPasswordParams, PSAvoidUsingInvokeExpression, PSUseDeclaredVarsMoreThanAssignments, PSUseSingularNouns, PSAvoidGlobalVars, PSUseShouldProcessForStateChangingFunctions, PSAvoidUsingWriteHost, PSAvoidUsingPositionalParameters + If ($ScriptAnalyzerResult) + { + $ScriptAnalyzerResults += $ScriptAnalyzerResult + } + } + # Copy tests? + # Copy-Item -Path:($AutoRest_Tests) -Destination:($JCModule_Tests) -Force } - # $ModulePath - # Copy-Item -Path:($Transformed_Function) -Destination:($JCModule_Function) -Force - # Copy-Item -Path:($AutoRest_Tests) -Destination:($JCModule_Tests) -Force - # (Get-Content -Path:($JCModule_Tests) -Raw).Replace('JcSdk', 'JC').Replace('.ToJsonString() | ConvertFrom-Json', '').Replace("Describe 'Get-JCEvent'", "Describe 'Get-JCEvent' -Tag:('JCEvent')").Replace('$loadEnvPath = Join-Path $PSScriptRoot ''loadEnv.ps1'' - # if (-Not (Test-Path -Path $loadEnvPath)) - # { - # $loadEnvPath = Join-Path $PSScriptRoot ''..\loadEnv.ps1'' - # } - # . ($loadEnvPath) - # $TestRecordingFile = Join-Path $PSScriptRoot ''Get-JCEvent.Recording.json'' - # $currentPath = $PSScriptRoot - # while (-not $mockingPath) - # { - # $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include ''HttpPipelineMocking.ps1'' -File - # $currentPath = Split-Path -Path $currentPath -Parent - # } - # . ($mockingPath | Select-Object -First 1).FullName - - # ', '') | Set-Content -Path:($JCModule_Tests) - # Remove-Item -Path:($JCModule_HelpFile) - } \ No newline at end of file diff --git a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 index 56dbe635c..51c47e8ea 100644 --- a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 +++ b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 @@ -4,35 +4,35 @@ Query the API for Directory Insights events .Description Query the API for Directory Insights events .Example -PS C:\> (Get-JCEvent -Service:('all') -StartTime:((Get-date).AddDays(-30))) +PS C:\> Get-JCEvent -Service:('all') -StartTime:((Get-date).AddDays(-30)) Pull all event records from the last thirty days .Example -PS C:\> (Get-JCEvent -Service:('directory') -StartTime:((Get-date).AddHours(-1)) -Limit:('10')) +PS C:\> Get-JCEvent -Service:('directory') -StartTime:((Get-date).AddHours(-1)) -Limit:('10') Get directory results from the last hour limit to the last 10 results in the time range .Example -PS C:\> (Get-JCEvent -Service:('directory') -StartTime:((Get-date).AddDays(-30)) -Sort:("DESC") -EndTime:((Get-date).AddDays(-5))) +PS C:\> Get-JCEvent -Service:('directory') -StartTime:((Get-date).AddDays(-30)) -Sort:("DESC") -EndTime:((Get-date).AddDays(-5)) Get directory results between 30 and 5 days ago, sort timestamp by descending value .Example -PS C:\> (Get-JCEvent -Service:('directory') -StartTime:((Get-date).AddDays(-30)) -Limit:('10') -searchTermAnd:@{"event_type" = "group_create"}) +PS C:\> Get-JCEvent -Service:('directory') -StartTime:((Get-date).AddDays(-30)) -Limit:('10') -searchTermAnd:@{"event_type" = "group_create"} Get only group_create from the last thirty days .Example -PS C:\> (Get-JCEvent -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermOr @{"initiated_by.username" = @("user.1", "user.2")}) +PS C:\> Get-JCEvent -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermOr @{"initiated_by.username" = @("user.1", "user.2")} Get login events initiated by either "user.1" or "user.2" between a universal time zone range .Example -PS C:\> (Get-JCEvent -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"event_type" = "admin_login_attempt"; "resource.email" = "admin.user@adminbizorg.com"}) +PS C:\> Get-JCEvent -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"event_type" = "admin_login_attempt"; "resource.email" = "admin.user@adminbizorg.com"} Get all events between a date range and match event_type = admin_login_attempt and resource.email = admin.user@adminbizorg.com .Example -PS C:\> (Get-JCEvent -Service:('sso') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"initiated_by.username" = "user.1"}) +PS C:\> Get-JCEvent -Service:('sso') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"initiated_by.username" = "user.1"} Get sso events with the search term initiated_by: username with value "user.1" .Example -PS C:\> (Get-JCEvent -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"event_type" = "organization_update"}) +PS C:\> Get-JCEvent -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"event_type" = "organization_update"} Get all events filtered by organization_update term between a date range @@ -44,9 +44,12 @@ 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. For information on hash tables, run Get-Help about_Hash_Tables. -EVENTQUERYBODY : EventQuery is the users' command to search our auth logs +BODY : EventQuery is the users' command to search our auth logs + Service : service name to query. Known services: systems,radius,sso,directory,ldap,all + StartTime : query start time, UTC in RFC3339 format [EndTime ]: optional query end time, UTC in RFC3339 format [Fields ]: optional list of fields to return from query [Limit ]: Max number of rows to return @@ -55,24 +58,27 @@ EVENTQUERYBODY : EventQuery is the users' command to search our aut [(Any) ]: This indicates any property can be added to this object. [SearchTermOr ]: list of event terms. If any term matches, the event will be returned by the service. [(Any) ]: This indicates any property can be added to this object. - [Service ]: service name to query. Known services: systems,radius,sso,directory,ldap,all [Sort ]: ASC or DESC order for timestamp - [StartTime ]: query start time, UTC in RFC3339 format .Link -https://github.com/TheJumpCloud/support/wiki/Get-JCEvent +https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/jumpcloud.sdk.directoryinsights/get-jcsdkevent #> Function Get-JCEvent { - #Requires -Modules JumpCloud.SDK.DirectoryInsights [OutputType([JumpCloud.SDK.DirectoryInsights.Models.IPost200ApplicationJsonItemsItem], [System.String])] [CmdletBinding(DefaultParameterSetName='GetExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] Param( - [Parameter(ParameterSetName='Get', Mandatory, ValueFromPipeline)] + [Parameter(ParameterSetName='GetExpanded', Mandatory)] [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [JumpCloud.SDK.DirectoryInsights.Models.IEventQuery] - # EventQuery is the users' command to search our auth logs - # To construct, see NOTES section for EVENTQUERYBODY properties and create a hash table. - ${EventQueryBody}, + [System.String[]] + # service name to query. + # Known services: systems,radius,sso,directory,ldap,all + ${Service}, + + [Parameter(ParameterSetName='GetExpanded', Mandatory)] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.DateTime] + # query start time, UTC in RFC3339 format + ${StartTime}, [Parameter(ParameterSetName='GetExpanded')] [JumpCloud.SDK.DirectoryInsights.Category('Body')] @@ -86,12 +92,6 @@ Function Get-JCEvent # optional list of fields to return from query ${Fields}, - [Parameter(ParameterSetName='GetExpanded')] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [System.Int64] - # Max number of rows to return - ${Limit}, - [Parameter(ParameterSetName='GetExpanded')] [JumpCloud.SDK.DirectoryInsights.Category('Body')] [System.String[]] @@ -114,99 +114,30 @@ Function Get-JCEvent # If any term matches, the event will be returned by the service. ${SearchTermOr}, - [Parameter(ParameterSetName='GetExpanded')] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [System.String[]] - # service name to query. - # Known services: systems,radius,sso,directory,ldap,all - ${Service}, - [Parameter(ParameterSetName='GetExpanded')] [JumpCloud.SDK.DirectoryInsights.Category('Body')] [System.String] # ASC or DESC order for timestamp ${Sort}, - [Parameter(ParameterSetName='GetExpanded')] + [Parameter(ParameterSetName='Get', Mandatory, ValueFromPipeline)] [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [System.DateTime] - # query start time, UTC in RFC3339 format - ${StartTime}, - - [System.Boolean] - # Set to $true to return all results. - $Paginate = $true + [JumpCloud.SDK.DirectoryInsights.Models.IEventQuery] + # EventQuery is the users' command to search our auth logs + # To construct, see NOTES section for BODY properties and create a hash table. + ${Body} ) Begin { Connect-JCOnline -force | Out-Null $Results = @() - $PSBoundParameters.Add('HttpPipelineAppend', { - param($req, $callback, $next) - # call the next step in the Pipeline - $ResponseTask = $next.SendAsync($req, $callback) - $global:JCHttpRequest = $req - $global:JCHttpRequestContent = $req.Content.ReadAsStringAsync() - $global:JCHttpResponse = $ResponseTask - Return $ResponseTask - } - ) } Process { - If ($Paginate) - { - $PSBoundParameters.Remove('Paginate') | Out-Null - Do - { - $Result = Get-JcSdkEvent @PSBoundParameters - If (-not [System.String]::IsNullOrEmpty($Result)) - { - $XResultSearchAfter = ($JCHttpResponse.Result.Headers.GetValues('X-Search_after') | ConvertFrom-Json); - If ([System.String]::IsNullOrEmpty($PSBoundParameters.SearchAfter)) - { - If ([System.String]::IsNullOrEmpty($PSBoundParameters.EventQueryBody)) - { - $PSBoundParameters.Add('SearchAfter', $XResultSearchAfter) - } - Else - { - $PSBoundParameters.EventQueryBody.SearchAfter = $XResultSearchAfter - } - } - Else - { - $PSBoundParameters.SearchAfter = $XResultSearchAfter - } - $XResultCount = $JCHttpResponse.Result.Headers.GetValues('X-Result-Count') - $XLimit = $JCHttpResponse.Result.Headers.GetValues('X-Limit') - $Results += ($Result).ToJsonString() | ConvertFrom-Json; - } - Write-Debug ("ResultCount: $($XResultCount); Limit: $($XLimit); XResultSearchAfter: $($XResultSearchAfter); "); - Write-Debug ('HttpRequest: ' + $JCHttpRequest); - Write-Debug ('HttpRequestContent: ' + $JCHttpRequestContent.Result); - } - While ($XResultCount -eq $XLimit -and $Result) - } - Else - { - $PSBoundParameters.Remove('Paginate') | Out-Null - $Result = Get-JcSdkEvent @PSBoundParameters - Write-Debug ('HttpRequest: ' + $JCHttpRequest); - Write-Debug ('HttpRequestContent: ' + $JCHttpRequestContent.Result); - If (-not [System.String]::IsNullOrEmpty($Result)) - { - $Results += ($Result).ToJsonString() | ConvertFrom-Json; - } - } + $Results = JumpCloud.SDK.DirectoryInsights\Get-JcSdkEvent @PSBoundParameters } End { - # Clean up global variables - $GlobalVars = @('JCHttpRequest', 'JCHttpRequestContent', 'JCHttpResponse') - $GlobalVars | ForEach-Object { - If ((Get-Variable -Scope:('Global')).Where( { $_.Name -eq $_ })) { Remove-Variable -Name:($_) -Scope:('Global') } - } Return $Results } } diff --git a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 new file mode 100644 index 000000000..52b4d6956 --- /dev/null +++ b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 @@ -0,0 +1,127 @@ +<# +.Synopsis +Query the API for a count of matching events +.Description +Query the API for a count of matching events +.Example +PS C:\> Get-JCEventCount -Service:('all') -StartTime:((Get-date).AddDays(-30)) + +Pull all event records from a specified time and count the results +.Example +PS C:\> Get-JCEventCount -Service:('sso') -StartTime:('2020-04-14T00:00:00Z') + +Pull all SSO event records from a specified time and count the results +.Example +PS C:\> Get-JCEventCount -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"event_type" = "admin_login_attempt"; "resource.email" = "admin.user@adminbizorg.com"} + +Get all events counts between a date range and match event_type = admin_login_attempt and resource.email = admin.user@adminbizorg.com +.Example +PS C:\> Get-JCEventCount -Service:('directory') -StartTime:((Get-date).AddDays(-30)) -searchTermAnd:@{"event_type" = "group_create"} + +Get only group_create event counts the last thirty days + +.Inputs +JumpCloud.SDK.DirectoryInsights.Models.IEventQuery +.Outputs +System.Int64 +.Outputs +System.String +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +BODY : EventQuery is the users' command to search our auth logs + Service : service name to query. Known services: systems,radius,sso,directory,ldap,all + StartTime : query start time, UTC in RFC3339 format + [EndTime ]: optional query end time, UTC in RFC3339 format + [Fields ]: optional list of fields to return from query + [Limit ]: Max number of rows to return + [SearchAfter ]: Specific query to search after, see x-* response headers for next values + [SearchTermAnd ]: list of event terms. If all terms match the event will be returned by the service. + [(Any) ]: This indicates any property can be added to this object. + [SearchTermOr ]: list of event terms. If any term matches, the event will be returned by the service. + [(Any) ]: This indicates any property can be added to this object. + [Sort ]: ASC or DESC order for timestamp +.Link +https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/jumpcloud.sdk.directoryinsights/get-jcsdkeventcount +#> +Function Get-JCEventCount +{ + [OutputType([System.Int64], [System.String])] + [CmdletBinding(DefaultParameterSetName='GetExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] + Param( + [Parameter(ParameterSetName='GetExpanded', Mandatory)] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.String[]] + # service name to query. + # Known services: systems,radius,sso,directory,ldap,all + ${Service}, + + [Parameter(ParameterSetName='GetExpanded', Mandatory)] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.DateTime] + # query start time, UTC in RFC3339 format + ${StartTime}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.DateTime] + # optional query end time, UTC in RFC3339 format + ${EndTime}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.String[]] + # optional list of fields to return from query + ${Fields}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.String[]] + # Specific query to search after, see x-* response headers for next values + ${SearchAfter}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [JumpCloud.SDK.DirectoryInsights.Runtime.Info(PossibleTypes=([JumpCloud.SDK.DirectoryInsights.Models.ISearchTermAnd]))] + [System.Collections.Hashtable] + # list of event terms. + # If all terms match the event will be returned by the service. + ${SearchTermAnd}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [JumpCloud.SDK.DirectoryInsights.Runtime.Info(PossibleTypes=([JumpCloud.SDK.DirectoryInsights.Models.ISearchTermOr]))] + [System.Collections.Hashtable] + # list of event terms. + # If any term matches, the event will be returned by the service. + ${SearchTermOr}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.String] + # ASC or DESC order for timestamp + ${Sort}, + + [Parameter(ParameterSetName='Get', Mandatory, ValueFromPipeline)] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [JumpCloud.SDK.DirectoryInsights.Models.IEventQuery] + # EventQuery is the users' command to search our auth logs + # To construct, see NOTES section for BODY properties and create a hash table. + ${Body} + ) + Begin + { + Connect-JCOnline -force | Out-Null + $Results = @() + } + Process + { + $Results = JumpCloud.SDK.DirectoryInsights\Get-JcSdkEventCount @PSBoundParameters + } + End + { + Return $Results + } +} From 862d987b90b5cf261188b22a2ebcc234aa196412 Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Tue, 14 Jul 2020 09:51:04 -0600 Subject: [PATCH 04/29] test if value is null --- PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 index 61de38bfb..dd1797759 100644 --- a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 +++ b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 @@ -55,7 +55,10 @@ ForEach ($Module In $Modules) $ParameterContent = ($Params.Matches.Value | Where-Object { $_ -notlike '*DontShow*' -and $_ -notlike '*Limit*' -and $_ -notlike '*Skip*' }) $OutputType = ($FunctionContent | Select-String -Pattern:('(\[OutputType)(.*?)(\]\r)')).Matches.Value $CmdletBinding = ($FunctionContent | Select-String -Pattern:('(\[CmdletBinding)(.*?)(\]\r)')).Matches.Value - $PSScriptInfo = $PSScriptInfo.Replace($SdkPrefix, $JumpCloudModulePrefix) + If (-not [System.String]::IsNullOrEmpty($PSScriptInfo)) + { + $PSScriptInfo = $PSScriptInfo.Replace($SdkPrefix, $JumpCloudModulePrefix) + } # Build CmdletBinding If (-not [System.String]::IsNullOrEmpty($OutputType)) { $CmdletBinding = "$($OutputType)`n$($IndentChar)$($CmdletBinding)" } # Build $BeginContent, $ProcessContent, and $EndContent From 059d3e956a31106404492e106340fe6c00e853f6 Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Tue, 14 Jul 2020 09:58:41 -0600 Subject: [PATCH 05/29] add script analyzer --- PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 index dd1797759..c234dd130 100644 --- a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 +++ b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 @@ -1,3 +1,4 @@ +Install-Module -Name:('PSScriptAnalyzer') $ApprovedFunctions = [Ordered]@{ 'JumpCloud.SDK.DirectoryInsights' = @( [PSCustomObject]@{ @@ -18,9 +19,6 @@ $Divider = '|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|' $FunctionTemplate = "{0}`nFunction {1}`n{{`n$($IndentChar){2}`n$($IndentChar)Param(`n{3}`n$($IndentChar))`n$($IndentChar)Begin`n$($IndentChar){{`n{4}`n$($IndentChar)}}`n$($IndentChar)Process`n$($IndentChar){{`n{5}`n$($IndentChar)}}`n$($IndentChar)End`n$($IndentChar){{`n{6}`n$($IndentChar)}}`n}}" $ScriptAnalyzerResults = @() $JumpCloudModulePath = (Get-Item -Path:($PSScriptRoot)).Parent.Parent.FullName + '/JumpCloud Module' -##################################################################### -. ((Get-Item -Path:($PSScriptRoot)).Parent.FullName + '/Setup-Dependencies.ps1') -##################################################################### $Modules = Get-Module -Name:($Psd1.RequiredModules | Where-Object { $_ -in $ApprovedFunctions.Keys }) ForEach ($Module In $Modules) { From 22256a668c011de19d3fdbb828147696a8ee9a9a Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Tue, 14 Jul 2020 10:29:25 -0600 Subject: [PATCH 06/29] add force --- PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 index c234dd130..d6f6bb669 100644 --- a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 +++ b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 @@ -1,4 +1,4 @@ -Install-Module -Name:('PSScriptAnalyzer') +Install-Module -Name:('PSScriptAnalyzer') -Force $ApprovedFunctions = [Ordered]@{ 'JumpCloud.SDK.DirectoryInsights' = @( [PSCustomObject]@{ From 83e4e1493cb94200c409634177567b0417dcca80 Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Tue, 14 Jul 2020 10:34:03 -0600 Subject: [PATCH 07/29] add get-config --- PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 index d6f6bb669..7303aa738 100644 --- a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 +++ b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 @@ -1,3 +1,5 @@ +. ($PSScriptRoot + '/' + 'Get-Config.ps1') +########################################################################### Install-Module -Name:('PSScriptAnalyzer') -Force $ApprovedFunctions = [Ordered]@{ 'JumpCloud.SDK.DirectoryInsights' = @( From 7118678f4580ae52276c0d7d6b0f76e52afdc0ee Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Tue, 14 Jul 2020 10:37:25 -0600 Subject: [PATCH 08/29] fix path --- PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 index 7303aa738..009d2153c 100644 --- a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 +++ b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 @@ -1,4 +1,4 @@ -. ($PSScriptRoot + '/' + 'Get-Config.ps1') +. ((Get-Item -Path:($PSScriptRoot)).Parent.FullName + '/' + 'Get-Config.ps1') ########################################################################### Install-Module -Name:('PSScriptAnalyzer') -Force $ApprovedFunctions = [Ordered]@{ From 486a4a433840e6a3185606200448c3071f8c74cb Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Tue, 14 Jul 2020 10:43:06 -0600 Subject: [PATCH 09/29] test removing files --- .../Public/DirectoryInsights/Get-JCEvent.ps1 | 143 ------------------ .../DirectoryInsights/Get-JCEventCount.ps1 | 127 ---------------- 2 files changed, 270 deletions(-) delete mode 100644 PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 delete mode 100644 PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 diff --git a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 deleted file mode 100644 index 51c47e8ea..000000000 --- a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 +++ /dev/null @@ -1,143 +0,0 @@ -<# -.Synopsis -Query the API for Directory Insights events -.Description -Query the API for Directory Insights events -.Example -PS C:\> Get-JCEvent -Service:('all') -StartTime:((Get-date).AddDays(-30)) - -Pull all event records from the last thirty days -.Example -PS C:\> Get-JCEvent -Service:('directory') -StartTime:((Get-date).AddHours(-1)) -Limit:('10') - -Get directory results from the last hour limit to the last 10 results in the time range -.Example -PS C:\> Get-JCEvent -Service:('directory') -StartTime:((Get-date).AddDays(-30)) -Sort:("DESC") -EndTime:((Get-date).AddDays(-5)) - -Get directory results between 30 and 5 days ago, sort timestamp by descending value -.Example -PS C:\> Get-JCEvent -Service:('directory') -StartTime:((Get-date).AddDays(-30)) -Limit:('10') -searchTermAnd:@{"event_type" = "group_create"} - -Get only group_create from the last thirty days -.Example -PS C:\> Get-JCEvent -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermOr @{"initiated_by.username" = @("user.1", "user.2")} - -Get login events initiated by either "user.1" or "user.2" between a universal time zone range -.Example -PS C:\> Get-JCEvent -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"event_type" = "admin_login_attempt"; "resource.email" = "admin.user@adminbizorg.com"} - -Get all events between a date range and match event_type = admin_login_attempt and resource.email = admin.user@adminbizorg.com -.Example -PS C:\> Get-JCEvent -Service:('sso') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"initiated_by.username" = "user.1"} - -Get sso events with the search term initiated_by: username with value "user.1" -.Example -PS C:\> Get-JCEvent -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"event_type" = "organization_update"} - -Get all events filtered by organization_update term between a date range - -.Inputs -JumpCloud.SDK.DirectoryInsights.Models.IEventQuery -.Outputs -JumpCloud.SDK.DirectoryInsights.Models.IPost200ApplicationJsonItemsItem -.Outputs -System.String -.Notes -COMPLEX PARAMETER PROPERTIES - -To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. - -BODY : EventQuery is the users' command to search our auth logs - Service : service name to query. Known services: systems,radius,sso,directory,ldap,all - StartTime : query start time, UTC in RFC3339 format - [EndTime ]: optional query end time, UTC in RFC3339 format - [Fields ]: optional list of fields to return from query - [Limit ]: Max number of rows to return - [SearchAfter ]: Specific query to search after, see x-* response headers for next values - [SearchTermAnd ]: list of event terms. If all terms match the event will be returned by the service. - [(Any) ]: This indicates any property can be added to this object. - [SearchTermOr ]: list of event terms. If any term matches, the event will be returned by the service. - [(Any) ]: This indicates any property can be added to this object. - [Sort ]: ASC or DESC order for timestamp -.Link -https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/jumpcloud.sdk.directoryinsights/get-jcsdkevent -#> -Function Get-JCEvent -{ - [OutputType([JumpCloud.SDK.DirectoryInsights.Models.IPost200ApplicationJsonItemsItem], [System.String])] - [CmdletBinding(DefaultParameterSetName='GetExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] - Param( - [Parameter(ParameterSetName='GetExpanded', Mandatory)] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [System.String[]] - # service name to query. - # Known services: systems,radius,sso,directory,ldap,all - ${Service}, - - [Parameter(ParameterSetName='GetExpanded', Mandatory)] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [System.DateTime] - # query start time, UTC in RFC3339 format - ${StartTime}, - - [Parameter(ParameterSetName='GetExpanded')] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [System.DateTime] - # optional query end time, UTC in RFC3339 format - ${EndTime}, - - [Parameter(ParameterSetName='GetExpanded')] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [System.String[]] - # optional list of fields to return from query - ${Fields}, - - [Parameter(ParameterSetName='GetExpanded')] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [System.String[]] - # Specific query to search after, see x-* response headers for next values - ${SearchAfter}, - - [Parameter(ParameterSetName='GetExpanded')] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [JumpCloud.SDK.DirectoryInsights.Runtime.Info(PossibleTypes=([JumpCloud.SDK.DirectoryInsights.Models.ISearchTermAnd]))] - [System.Collections.Hashtable] - # list of event terms. - # If all terms match the event will be returned by the service. - ${SearchTermAnd}, - - [Parameter(ParameterSetName='GetExpanded')] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [JumpCloud.SDK.DirectoryInsights.Runtime.Info(PossibleTypes=([JumpCloud.SDK.DirectoryInsights.Models.ISearchTermOr]))] - [System.Collections.Hashtable] - # list of event terms. - # If any term matches, the event will be returned by the service. - ${SearchTermOr}, - - [Parameter(ParameterSetName='GetExpanded')] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [System.String] - # ASC or DESC order for timestamp - ${Sort}, - - [Parameter(ParameterSetName='Get', Mandatory, ValueFromPipeline)] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [JumpCloud.SDK.DirectoryInsights.Models.IEventQuery] - # EventQuery is the users' command to search our auth logs - # To construct, see NOTES section for BODY properties and create a hash table. - ${Body} - ) - Begin - { - Connect-JCOnline -force | Out-Null - $Results = @() - } - Process - { - $Results = JumpCloud.SDK.DirectoryInsights\Get-JcSdkEvent @PSBoundParameters - } - End - { - Return $Results - } -} diff --git a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 deleted file mode 100644 index 52b4d6956..000000000 --- a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 +++ /dev/null @@ -1,127 +0,0 @@ -<# -.Synopsis -Query the API for a count of matching events -.Description -Query the API for a count of matching events -.Example -PS C:\> Get-JCEventCount -Service:('all') -StartTime:((Get-date).AddDays(-30)) - -Pull all event records from a specified time and count the results -.Example -PS C:\> Get-JCEventCount -Service:('sso') -StartTime:('2020-04-14T00:00:00Z') - -Pull all SSO event records from a specified time and count the results -.Example -PS C:\> Get-JCEventCount -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"event_type" = "admin_login_attempt"; "resource.email" = "admin.user@adminbizorg.com"} - -Get all events counts between a date range and match event_type = admin_login_attempt and resource.email = admin.user@adminbizorg.com -.Example -PS C:\> Get-JCEventCount -Service:('directory') -StartTime:((Get-date).AddDays(-30)) -searchTermAnd:@{"event_type" = "group_create"} - -Get only group_create event counts the last thirty days - -.Inputs -JumpCloud.SDK.DirectoryInsights.Models.IEventQuery -.Outputs -System.Int64 -.Outputs -System.String -.Notes -COMPLEX PARAMETER PROPERTIES - -To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. - -BODY : EventQuery is the users' command to search our auth logs - Service : service name to query. Known services: systems,radius,sso,directory,ldap,all - StartTime : query start time, UTC in RFC3339 format - [EndTime ]: optional query end time, UTC in RFC3339 format - [Fields ]: optional list of fields to return from query - [Limit ]: Max number of rows to return - [SearchAfter ]: Specific query to search after, see x-* response headers for next values - [SearchTermAnd ]: list of event terms. If all terms match the event will be returned by the service. - [(Any) ]: This indicates any property can be added to this object. - [SearchTermOr ]: list of event terms. If any term matches, the event will be returned by the service. - [(Any) ]: This indicates any property can be added to this object. - [Sort ]: ASC or DESC order for timestamp -.Link -https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/jumpcloud.sdk.directoryinsights/get-jcsdkeventcount -#> -Function Get-JCEventCount -{ - [OutputType([System.Int64], [System.String])] - [CmdletBinding(DefaultParameterSetName='GetExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] - Param( - [Parameter(ParameterSetName='GetExpanded', Mandatory)] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [System.String[]] - # service name to query. - # Known services: systems,radius,sso,directory,ldap,all - ${Service}, - - [Parameter(ParameterSetName='GetExpanded', Mandatory)] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [System.DateTime] - # query start time, UTC in RFC3339 format - ${StartTime}, - - [Parameter(ParameterSetName='GetExpanded')] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [System.DateTime] - # optional query end time, UTC in RFC3339 format - ${EndTime}, - - [Parameter(ParameterSetName='GetExpanded')] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [System.String[]] - # optional list of fields to return from query - ${Fields}, - - [Parameter(ParameterSetName='GetExpanded')] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [System.String[]] - # Specific query to search after, see x-* response headers for next values - ${SearchAfter}, - - [Parameter(ParameterSetName='GetExpanded')] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [JumpCloud.SDK.DirectoryInsights.Runtime.Info(PossibleTypes=([JumpCloud.SDK.DirectoryInsights.Models.ISearchTermAnd]))] - [System.Collections.Hashtable] - # list of event terms. - # If all terms match the event will be returned by the service. - ${SearchTermAnd}, - - [Parameter(ParameterSetName='GetExpanded')] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [JumpCloud.SDK.DirectoryInsights.Runtime.Info(PossibleTypes=([JumpCloud.SDK.DirectoryInsights.Models.ISearchTermOr]))] - [System.Collections.Hashtable] - # list of event terms. - # If any term matches, the event will be returned by the service. - ${SearchTermOr}, - - [Parameter(ParameterSetName='GetExpanded')] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [System.String] - # ASC or DESC order for timestamp - ${Sort}, - - [Parameter(ParameterSetName='Get', Mandatory, ValueFromPipeline)] - [JumpCloud.SDK.DirectoryInsights.Category('Body')] - [JumpCloud.SDK.DirectoryInsights.Models.IEventQuery] - # EventQuery is the users' command to search our auth logs - # To construct, see NOTES section for BODY properties and create a hash table. - ${Body} - ) - Begin - { - Connect-JCOnline -force | Out-Null - $Results = @() - } - Process - { - $Results = JumpCloud.SDK.DirectoryInsights\Get-JcSdkEventCount @PSBoundParameters - } - End - { - Return $Results - } -} From 1ebab1fc9b1ae670e84d4313fddfd3cf5c112fc5 Mon Sep 17 00:00:00 2001 From: AzurePipelines Date: Tue, 14 Jul 2020 16:49:12 +0000 Subject: [PATCH 10/29] Push to refs/heads/SA-1239-Intergrate-SDKs;[skip ci] --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 209 +++++++++++---------- 1 file changed, 106 insertions(+), 103 deletions(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 35fe01435..2353d9413 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,152 +3,155 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 6/255555/2020 +# Generated on: 7/14/2020 # @{ - # Script module or binary module file associated with this manifest. - RootModule = 'JumpCloud.psm1' +# Script module or binary module file associated with this manifest. +RootModule = 'JumpCloud.psm1' - # Version number of this module. - ModuleVersion = '1.17.4' +# Version number of this module. +ModuleVersion = '1.17.4' - # Supported PSEditions - # CompatiblePSEditions = @() +# Supported PSEditions +# CompatiblePSEditions = @() - # ID used to uniquely identify this module - GUID = '31c023d1-a901-48c4-90a3-082f91b31646' +# ID used to uniquely identify this module +GUID = '31c023d1-a901-48c4-90a3-082f91b31646' - # Author of this module - Author = 'JumpCloud Solutions Architect Team' +# Author of this module +Author = 'JumpCloud Solutions Architect Team' - # Company or vendor of this module - CompanyName = 'JumpCloud' +# Company or vendor of this module +CompanyName = 'JumpCloud' - # Copyright statement for this module - Copyright = '(c) JumpCloud. All rights reserved.' +# Copyright statement for this module +Copyright = '(c) JumpCloud. All rights reserved.' - # Description of the functionality provided by this module - Description = 'PowerShell functions to manage a JumpCloud Directory-as-a-Service' +# Description of the functionality provided by this module +Description = 'PowerShell functions to manage a JumpCloud Directory-as-a-Service' - # Minimum version of the PowerShell engine required by this module - PowerShellVersion = '4.0' +# Minimum version of the PowerShell engine required by this module +PowerShellVersion = '4.0' - # Name of the PowerShell host required by this module - # PowerShellHostName = '' +# Name of the PowerShell host required by this module +# PowerShellHostName = '' - # Minimum version of the PowerShell host required by this module - # PowerShellHostVersion = '' +# Minimum version of the PowerShell host required by this module +# PowerShellHostVersion = '' - # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. - # DotNetFrameworkVersion = '' +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# DotNetFrameworkVersion = '' - # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. - # ClrVersion = '' +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# ClrVersion = '' - # Processor architecture (None, X86, Amd64) required by this module - # ProcessorArchitecture = '' +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' - # Modules that must be imported into the global environment prior to importing this module - RequiredModules = @('JumpCloud.SDK.DirectoryInsights', 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2') +# Modules that must be imported into the global environment prior to importing this module +RequiredModules = @('JumpCloud.SDK.DirectoryInsights', + 'JumpCloud.SDK.V1', + 'JumpCloud.SDK.V2') - # Assemblies that must be loaded prior to importing this module - # RequiredAssemblies = @() +# Assemblies that must be loaded prior to importing this module +# RequiredAssemblies = @() - # Script files (.ps1) that are run in the caller's environment prior to importing this module. - # ScriptsToProcess = @() +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() - # Type files (.ps1xml) to be loaded when importing this module - # TypesToProcess = @() +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() - # Format files (.ps1xml) to be loaded when importing this module - # FormatsToProcess = @() +# Format files (.ps1xml) to be loaded when importing this module +# FormatsToProcess = @() - # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess - # NestedModules = @() +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() - # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. - FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget', - 'Add-JCRadiusReplyAttribute', 'Add-JCSystemGroupMember', - 'Add-JCSystemUser', 'Add-JCUserGroupMember', 'Connect-JCOnline', - 'Copy-JCAssociation', 'Get-JCAssociation', 'Get-JCBackup', - 'Get-JCCommand', 'Get-JCCommandResult', 'Get-JCCommandTarget', - 'Get-JCEvent', 'Get-JCGroup', 'Get-JCOrganization', 'Get-JCPolicy', - 'Get-JCPolicyResult', 'Get-JCPolicyTargetGroup', - 'Get-JCPolicyTargetSystem', 'Get-JCRadiusReplyAttribute', - 'Get-JCRadiusServer', 'Get-JCSystem', 'Get-JCSystemGroupMember', - 'Get-JCSystemInsights', 'Get-JCSystemUser', 'Get-JCUser', - 'Get-JCUserGroupMember', 'Import-JCCommand', 'Import-JCUsersFromCSV', - 'Invoke-JCCommand', 'Invoke-JCDeployment', 'New-JCCommand', - 'New-JCDeploymentTemplate', 'New-JCImportTemplate', - 'New-JCRadiusServer', 'New-JCSystemGroup', 'New-JCUser', - 'New-JCUserGroup', 'Remove-JCAssociation', 'Remove-JCCommand', - 'Remove-JCCommandResult', 'Remove-JCCommandTarget', - 'Remove-JCRadiusReplyAttribute', 'Remove-JCRadiusServer', - 'Remove-JCSystem', 'Remove-JCSystemGroup', - 'Remove-JCSystemGroupMember', 'Remove-JCSystemUser', 'Remove-JCUser', - 'Remove-JCUserGroup', 'Remove-JCUserGroupMember', - 'Send-JCPasswordReset', 'Set-JCCommand', 'Set-JCOrganization', - 'Set-JCRadiusReplyAttribute', 'Set-JCRadiusServer', 'Set-JCSystem', - 'Set-JCSystemUser', 'Set-JCUser', 'Set-JCUserGroupLDAP', - 'Update-JCModule', 'Update-JCUsersFromCSV' +# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. +FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget', + 'Add-JCRadiusReplyAttribute', 'Add-JCSystemGroupMember', + 'Add-JCSystemUser', 'Add-JCUserGroupMember', 'Connect-JCOnline', + 'Copy-JCAssociation', 'Get-JCAssociation', 'Get-JCBackup', + 'Get-JCCommand', 'Get-JCCommandResult', 'Get-JCCommandTarget', + 'Get-JCGroup', 'Get-JCOrganization', 'Get-JCPolicy', + 'Get-JCPolicyResult', 'Get-JCPolicyTargetGroup', + 'Get-JCPolicyTargetSystem', 'Get-JCRadiusReplyAttribute', + 'Get-JCRadiusServer', 'Get-JCSystem', 'Get-JCSystemGroupMember', + 'Get-JCSystemInsights', 'Get-JCSystemUser', 'Get-JCUser', + 'Get-JCUserGroupMember', 'Import-JCCommand', 'Import-JCUsersFromCSV', + 'Invoke-JCCommand', 'Invoke-JCDeployment', 'New-JCCommand', + 'New-JCDeploymentTemplate', 'New-JCImportTemplate', + 'New-JCRadiusServer', 'New-JCSystemGroup', 'New-JCUser', + 'New-JCUserGroup', 'Remove-JCAssociation', 'Remove-JCCommand', + 'Remove-JCCommandResult', 'Remove-JCCommandTarget', + 'Remove-JCRadiusReplyAttribute', 'Remove-JCRadiusServer', + 'Remove-JCSystem', 'Remove-JCSystemGroup', + 'Remove-JCSystemGroupMember', 'Remove-JCSystemUser', 'Remove-JCUser', + 'Remove-JCUserGroup', 'Remove-JCUserGroupMember', + 'Send-JCPasswordReset', 'Set-JCCommand', 'Set-JCOrganization', + 'Set-JCRadiusReplyAttribute', 'Set-JCRadiusServer', 'Set-JCSystem', + 'Set-JCSystemUser', 'Set-JCUser', 'Set-JCUserGroupLDAP', + 'Update-JCModule', 'Update-JCUsersFromCSV' - # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. - CmdletsToExport = @() +# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. +CmdletsToExport = @() - # Variables to export from this module - VariablesToExport = '*' +# Variables to export from this module +VariablesToExport = '*' - # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. - AliasesToExport = 'New-JCAssociation' +# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. +AliasesToExport = 'New-JCAssociation' - # DSC resources to export from this module - # DscResourcesToExport = @() +# DSC resources to export from this module +# DscResourcesToExport = @() - # List of all modules packaged with this module - # ModuleList = @() +# List of all modules packaged with this module +# ModuleList = @() - # List of all files packaged with this module - # FileList = @() +# List of all files packaged with this module +# FileList = @() - # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. - PrivateData = @{ +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ - PSData = @{ + PSData = @{ - # Tags applied to this module. These help with module discovery in online galleries. - Tags = 'JumpCloud', 'DaaS', 'Jump', 'Cloud', 'Directory' + # Tags applied to this module. These help with module discovery in online galleries. + Tags = 'JumpCloud', 'DaaS', 'Jump', 'Cloud', 'Directory' - # A URL to the license for this module. - LicenseUri = 'https://github.com/TheJumpCloud/support/blob/master/PowerShell/LICENSE' + # A URL to the license for this module. + LicenseUri = 'https://github.com/TheJumpCloud/support/blob/master/PowerShell/LICENSE' - # A URL to the main website for this project. - ProjectUri = 'https://github.com/TheJumpCloud/support/wiki' + # A URL to the main website for this project. + ProjectUri = 'https://github.com/TheJumpCloud/support/wiki' - # A URL to an icon representing this module. - IconUri = 'https://avatars1.githubusercontent.com/u/4927461?s=200&v=4' + # A URL to an icon representing this module. + IconUri = 'https://avatars1.githubusercontent.com/u/4927461?s=200&v=4' - # ReleaseNotes of this module - ReleaseNotes = 'https://git.io/jc-pwsh-releasenotes' + # ReleaseNotes of this module + ReleaseNotes = 'https://git.io/jc-pwsh-releasenotes' - # Prerelease string of this module - # Prerelease = '' + # Prerelease string of this module + # Prerelease = '' - # Flag to indicate whether the module requires explicit user acceptance for install/update/save - # RequireLicenseAcceptance = $false + # Flag to indicate whether the module requires explicit user acceptance for install/update/save + # RequireLicenseAcceptance = $false - # External dependent modules of this module - # ExternalModuleDependencies = @() + # External dependent modules of this module + # ExternalModuleDependencies = @() - } # End of PSData hashtable + } # End of PSData hashtable - } # End of PrivateData hashtable +} # End of PrivateData hashtable - # HelpInfo URI of this module - HelpInfoURI = 'https://github.com/TheJumpCloud/support/wiki' +# HelpInfo URI of this module +HelpInfoURI = 'https://github.com/TheJumpCloud/support/wiki' - # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. - # DefaultCommandPrefix = '' +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' } + From eaf96d0f6454e944e9dc5f3796b38b50aadf9743 Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Tue, 14 Jul 2020 11:05:25 -0600 Subject: [PATCH 11/29] add error catching --- .../Deploy/SdkSync/jcapiToSupportSync.ps1 | 125 +++++++++--------- 1 file changed, 66 insertions(+), 59 deletions(-) diff --git a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 index 009d2153c..1bea59cf3 100644 --- a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 +++ b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 @@ -22,73 +22,80 @@ $FunctionTemplate = "{0}`nFunction {1}`n{{`n$($IndentChar){2}`n$($IndentChar)Par $ScriptAnalyzerResults = @() $JumpCloudModulePath = (Get-Item -Path:($PSScriptRoot)).Parent.Parent.FullName + '/JumpCloud Module' $Modules = Get-Module -Name:($Psd1.RequiredModules | Where-Object { $_ -in $ApprovedFunctions.Keys }) -ForEach ($Module In $Modules) +If (-not [System.String]::IsNullOrEmpty($Modules)) { - $ModuleName = $Module.Name - ForEach ($Function In $ApprovedFunctions.$ModuleName) + ForEach ($Module In $Modules) { - $FunctionName = $Function.Name - $FunctionDestination = $Function.Destination - $OutputPath = "$JumpCloudModulePath/$FunctionDestination" - $Command = Get-Command -Name:($FunctionName) - $CommandName = $Command.Name - $NewCommandName = $CommandName.Replace($SdkPrefix, $JumpCloudModulePrefix) - Write-Host ("[STATUS] Building: $NewCommandName") -BackgroundColor:('Black') -ForegroundColor:('Magenta') - # Get content from sdk function - $CommandFilePath = $Command.ScriptBlock.File - $CommandFilePathContent = Get-Content -Path:($CommandFilePath) -Raw - $FunctionContent = If ($CommandFilePath -like '*ProxyCmdletDefinitions.ps1') + $ModuleName = $Module.Name + ForEach ($Function In $ApprovedFunctions.$ModuleName) { - <# When the autorest generated module has been installed and imported from the PSGallery all the + $FunctionName = $Function.Name + $FunctionDestination = $Function.Destination + $OutputPath = "$JumpCloudModulePath/$FunctionDestination" + $Command = Get-Command -Name:($FunctionName) + $CommandName = $Command.Name + $NewCommandName = $CommandName.Replace($SdkPrefix, $JumpCloudModulePrefix) + Write-Host ("[STATUS] Building: $NewCommandName") -BackgroundColor:('Black') -ForegroundColor:('Magenta') + # Get content from sdk function + $CommandFilePath = $Command.ScriptBlock.File + $CommandFilePathContent = Get-Content -Path:($CommandFilePath) -Raw + $FunctionContent = If ($CommandFilePath -like '*ProxyCmdletDefinitions.ps1') + { + <# When the autorest generated module has been installed and imported from the PSGallery all the cmdlets will exist in a single ProxyCmdletDefinitions.ps1 file. We need to parse out the specific function in order to gather the parts we need to copy over. #> - $CommandFilePathContent.Replace($MSCopyrightHeader, $Divider).Split($Divider).Where( { $_ -like ('*' + "function $CommandName {" + '*') }) - } - Else - { - <# When the autorest generated module has been imported from a local psd1 module the function will + $CommandFilePathContent.Replace($MSCopyrightHeader, $Divider).Split($Divider).Where( { $_ -like ('*' + "function $CommandName {" + '*') }) + } + Else + { + <# When the autorest generated module has been imported from a local psd1 module the function will remain in their individual files. #> - $CommandFilePathContent - } - $PSScriptInfo = ($FunctionContent | Select-String -Pattern:('(?s)(<#)(.*?)(#>)')).Matches.Value - $Params = $FunctionContent | Select-String -Pattern:('(?s)( \[Parameter)(.*?)(\})') -AllMatches - $ParameterContent = ($Params.Matches.Value | Where-Object { $_ -notlike '*DontShow*' -and $_ -notlike '*Limit*' -and $_ -notlike '*Skip*' }) - $OutputType = ($FunctionContent | Select-String -Pattern:('(\[OutputType)(.*?)(\]\r)')).Matches.Value - $CmdletBinding = ($FunctionContent | Select-String -Pattern:('(\[CmdletBinding)(.*?)(\]\r)')).Matches.Value - If (-not [System.String]::IsNullOrEmpty($PSScriptInfo)) - { - $PSScriptInfo = $PSScriptInfo.Replace($SdkPrefix, $JumpCloudModulePrefix) - } - # Build CmdletBinding - If (-not [System.String]::IsNullOrEmpty($OutputType)) { $CmdletBinding = "$($OutputType)`n$($IndentChar)$($CmdletBinding)" } - # Build $BeginContent, $ProcessContent, and $EndContent - $BeginContent = @() - $ProcessContent = @() - $EndContent = @() - # Build "Begin" block - $BeginContent += "$($IndentChar)$($IndentChar)Connect-JCOnline -force | Out-Null" - $BeginContent += "$($IndentChar)$($IndentChar)`$Results = @()" - # Build "Process" block - $ProcessContent += "$($IndentChar)$($IndentChar)`$Results = $($ModuleName)\$($CommandName) @PSBoundParameters" - # Build "End" block - $EndContent += "$($IndentChar)$($IndentChar)Return `$Results" - If (-not [System.String]::IsNullOrEmpty($BeginContent) -and -not [System.String]::IsNullOrEmpty($ProcessContent) -and -not [System.String]::IsNullOrEmpty($EndContent)) - { - # Build "Function" - $NewScript = $FunctionTemplate -f $PSScriptInfo, $NewCommandName, $CmdletBinding, ($ParameterContent -join ",`n`n"), ($BeginContent -join "`n"), ($ProcessContent -join "`n"), ($EndContent -join "`n") - # Fix line endings - $NewScript = $NewScript.Replace("`r`n", "`n").Trim() - # Export the function - $OutputFilePath = "$OutputPath/$NewCommandName.ps1" - $NewScript | Out-File -FilePath:($OutputFilePath) -Force - # Validate script syntax - $ScriptAnalyzerResult = Invoke-ScriptAnalyzer -Path:($OutputFilePath) -Recurse -ExcludeRule PSShouldProcess, PSAvoidTrailingWhitespace, PSAvoidUsingWMICmdlet, PSAvoidUsingPlainTextForPassword, PSAvoidUsingUsernameAndPasswordParams, PSAvoidUsingInvokeExpression, PSUseDeclaredVarsMoreThanAssignments, PSUseSingularNouns, PSAvoidGlobalVars, PSUseShouldProcessForStateChangingFunctions, PSAvoidUsingWriteHost, PSAvoidUsingPositionalParameters - If ($ScriptAnalyzerResult) + $CommandFilePathContent + } + $PSScriptInfo = ($FunctionContent | Select-String -Pattern:('(?s)(<#)(.*?)(#>)')).Matches.Value + $Params = $FunctionContent | Select-String -Pattern:('(?s)( \[Parameter)(.*?)(\})') -AllMatches + $ParameterContent = ($Params.Matches.Value | Where-Object { $_ -notlike '*DontShow*' -and $_ -notlike '*Limit*' -and $_ -notlike '*Skip*' }) + $OutputType = ($FunctionContent | Select-String -Pattern:('(\[OutputType)(.*?)(\]\r)')).Matches.Value + $CmdletBinding = ($FunctionContent | Select-String -Pattern:('(\[CmdletBinding)(.*?)(\]\r)')).Matches.Value + If (-not [System.String]::IsNullOrEmpty($PSScriptInfo)) { - $ScriptAnalyzerResults += $ScriptAnalyzerResult + $PSScriptInfo = $PSScriptInfo.Replace($SdkPrefix, $JumpCloudModulePrefix) } + # Build CmdletBinding + If (-not [System.String]::IsNullOrEmpty($OutputType)) { $CmdletBinding = "$($OutputType)`n$($IndentChar)$($CmdletBinding)" } + # Build $BeginContent, $ProcessContent, and $EndContent + $BeginContent = @() + $ProcessContent = @() + $EndContent = @() + # Build "Begin" block + $BeginContent += "$($IndentChar)$($IndentChar)Connect-JCOnline -force | Out-Null" + $BeginContent += "$($IndentChar)$($IndentChar)`$Results = @()" + # Build "Process" block + $ProcessContent += "$($IndentChar)$($IndentChar)`$Results = $($ModuleName)\$($CommandName) @PSBoundParameters" + # Build "End" block + $EndContent += "$($IndentChar)$($IndentChar)Return `$Results" + If (-not [System.String]::IsNullOrEmpty($BeginContent) -and -not [System.String]::IsNullOrEmpty($ProcessContent) -and -not [System.String]::IsNullOrEmpty($EndContent)) + { + # Build "Function" + $NewScript = $FunctionTemplate -f $PSScriptInfo, $NewCommandName, $CmdletBinding, ($ParameterContent -join ",`n`n"), ($BeginContent -join "`n"), ($ProcessContent -join "`n"), ($EndContent -join "`n") + # Fix line endings + $NewScript = $NewScript.Replace("`r`n", "`n").Trim() + # Export the function + $OutputFilePath = "$OutputPath/$NewCommandName.ps1" + $NewScript | Out-File -FilePath:($OutputFilePath) -Force + # Validate script syntax + $ScriptAnalyzerResult = Invoke-ScriptAnalyzer -Path:($OutputFilePath) -Recurse -ExcludeRule PSShouldProcess, PSAvoidTrailingWhitespace, PSAvoidUsingWMICmdlet, PSAvoidUsingPlainTextForPassword, PSAvoidUsingUsernameAndPasswordParams, PSAvoidUsingInvokeExpression, PSUseDeclaredVarsMoreThanAssignments, PSUseSingularNouns, PSAvoidGlobalVars, PSUseShouldProcessForStateChangingFunctions, PSAvoidUsingWriteHost, PSAvoidUsingPositionalParameters + If ($ScriptAnalyzerResult) + { + $ScriptAnalyzerResults += $ScriptAnalyzerResult + } + } + # Copy tests? + # Copy-Item -Path:($AutoRest_Tests) -Destination:($JCModule_Tests) -Force } - # Copy tests? - # Copy-Item -Path:($AutoRest_Tests) -Destination:($JCModule_Tests) -Force } +} +Else +{ + Write-Error ('No modules found!') } \ No newline at end of file From b0cf132b78c8c85b97e8a7f39ed6e3d8b0d8f92d Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Tue, 14 Jul 2020 11:10:34 -0600 Subject: [PATCH 12/29] refresh module list --- PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 index 1bea59cf3..4fdb3f7a1 100644 --- a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 +++ b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 @@ -21,6 +21,7 @@ $Divider = '|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|' $FunctionTemplate = "{0}`nFunction {1}`n{{`n$($IndentChar){2}`n$($IndentChar)Param(`n{3}`n$($IndentChar))`n$($IndentChar)Begin`n$($IndentChar){{`n{4}`n$($IndentChar)}}`n$($IndentChar)Process`n$($IndentChar){{`n{5}`n$($IndentChar)}}`n$($IndentChar)End`n$($IndentChar){{`n{6}`n$($IndentChar)}}`n}}" $ScriptAnalyzerResults = @() $JumpCloudModulePath = (Get-Item -Path:($PSScriptRoot)).Parent.Parent.FullName + '/JumpCloud Module' +Get-Module -Refresh -ListAvailable -All | Out-Null $Modules = Get-Module -Name:($Psd1.RequiredModules | Where-Object { $_ -in $ApprovedFunctions.Keys }) If (-not [System.String]::IsNullOrEmpty($Modules)) { From b7a1c34f33ee4bcf538b71bea89b71dfdaa80b19 Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Tue, 14 Jul 2020 11:18:04 -0600 Subject: [PATCH 13/29] import module --- PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 index 4fdb3f7a1..d6724a963 100644 --- a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 +++ b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 @@ -21,8 +21,9 @@ $Divider = '|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|' $FunctionTemplate = "{0}`nFunction {1}`n{{`n$($IndentChar){2}`n$($IndentChar)Param(`n{3}`n$($IndentChar))`n$($IndentChar)Begin`n$($IndentChar){{`n{4}`n$($IndentChar)}}`n$($IndentChar)Process`n$($IndentChar){{`n{5}`n$($IndentChar)}}`n$($IndentChar)End`n$($IndentChar){{`n{6}`n$($IndentChar)}}`n}}" $ScriptAnalyzerResults = @() $JumpCloudModulePath = (Get-Item -Path:($PSScriptRoot)).Parent.Parent.FullName + '/JumpCloud Module' +Import-Module -Name:($RequiredModules) Get-Module -Refresh -ListAvailable -All | Out-Null -$Modules = Get-Module -Name:($Psd1.RequiredModules | Where-Object { $_ -in $ApprovedFunctions.Keys }) +$Modules = Get-Module -Name:($RequiredModules | Where-Object { $_ -in $ApprovedFunctions.Keys }) If (-not [System.String]::IsNullOrEmpty($Modules)) { ForEach ($Module In $Modules) From f969e28d23f799d40d756a2458f6c4bdca5158dd Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Tue, 14 Jul 2020 11:29:10 -0600 Subject: [PATCH 14/29] debugging --- PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 index d6724a963..64581fa64 100644 --- a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 +++ b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 @@ -84,6 +84,7 @@ If (-not [System.String]::IsNullOrEmpty($Modules)) $NewScript = $NewScript.Replace("`r`n", "`n").Trim() # Export the function $OutputFilePath = "$OutputPath/$NewCommandName.ps1" + Write-Host ('Path is: ' + (Test-Path -Path:($OutputPath))) $NewScript | Out-File -FilePath:($OutputFilePath) -Force # Validate script syntax $ScriptAnalyzerResult = Invoke-ScriptAnalyzer -Path:($OutputFilePath) -Recurse -ExcludeRule PSShouldProcess, PSAvoidTrailingWhitespace, PSAvoidUsingWMICmdlet, PSAvoidUsingPlainTextForPassword, PSAvoidUsingUsernameAndPasswordParams, PSAvoidUsingInvokeExpression, PSUseDeclaredVarsMoreThanAssignments, PSUseSingularNouns, PSAvoidGlobalVars, PSUseShouldProcessForStateChangingFunctions, PSAvoidUsingWriteHost, PSAvoidUsingPositionalParameters From cfb2044a77060745e0e9d5aa281b6f267359063d Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Tue, 14 Jul 2020 11:33:38 -0600 Subject: [PATCH 15/29] create path --- PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 index 64581fa64..423d0f2fc 100644 --- a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 +++ b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 @@ -85,6 +85,7 @@ If (-not [System.String]::IsNullOrEmpty($Modules)) # Export the function $OutputFilePath = "$OutputPath/$NewCommandName.ps1" Write-Host ('Path is: ' + (Test-Path -Path:($OutputPath))) + New-FolderRecursive -Path:($OutputFilePath) -Force $NewScript | Out-File -FilePath:($OutputFilePath) -Force # Validate script syntax $ScriptAnalyzerResult = Invoke-ScriptAnalyzer -Path:($OutputFilePath) -Recurse -ExcludeRule PSShouldProcess, PSAvoidTrailingWhitespace, PSAvoidUsingWMICmdlet, PSAvoidUsingPlainTextForPassword, PSAvoidUsingUsernameAndPasswordParams, PSAvoidUsingInvokeExpression, PSUseDeclaredVarsMoreThanAssignments, PSUseSingularNouns, PSAvoidGlobalVars, PSUseShouldProcessForStateChangingFunctions, PSAvoidUsingWriteHost, PSAvoidUsingPositionalParameters From 603ca40c7a0c14b63b981afb90c9f41526aa5e43 Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Tue, 14 Jul 2020 12:30:33 -0600 Subject: [PATCH 16/29] update psd1 file --- PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 index 423d0f2fc..9f8802a07 100644 --- a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 +++ b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 @@ -96,6 +96,9 @@ If (-not [System.String]::IsNullOrEmpty($Modules)) } # Copy tests? # Copy-Item -Path:($AutoRest_Tests) -Destination:($JCModule_Tests) -Force + # Update .Psd1 file + $Psd1.FunctionsToExport += $FunctionName + Update-ModuleManifest -Path:($FilePath_psd1) -FunctionsToExport:($Psd1.FunctionsToExport) } } } From c2b6dbfc589b032e8947ca4a4e21e31323765477 Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Tue, 14 Jul 2020 12:43:26 -0600 Subject: [PATCH 17/29] fix var --- PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 index 9f8802a07..61264d876 100644 --- a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 +++ b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 @@ -97,7 +97,7 @@ If (-not [System.String]::IsNullOrEmpty($Modules)) # Copy tests? # Copy-Item -Path:($AutoRest_Tests) -Destination:($JCModule_Tests) -Force # Update .Psd1 file - $Psd1.FunctionsToExport += $FunctionName + $Psd1.FunctionsToExport += $NewCommandName Update-ModuleManifest -Path:($FilePath_psd1) -FunctionsToExport:($Psd1.FunctionsToExport) } } From 937043e9656bb81ea64e9ed901a2300d198f1186 Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Tue, 14 Jul 2020 12:46:04 -0600 Subject: [PATCH 18/29] remove debugging step --- PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 index 61264d876..897e700ac 100644 --- a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 +++ b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 @@ -84,7 +84,6 @@ If (-not [System.String]::IsNullOrEmpty($Modules)) $NewScript = $NewScript.Replace("`r`n", "`n").Trim() # Export the function $OutputFilePath = "$OutputPath/$NewCommandName.ps1" - Write-Host ('Path is: ' + (Test-Path -Path:($OutputPath))) New-FolderRecursive -Path:($OutputFilePath) -Force $NewScript | Out-File -FilePath:($OutputFilePath) -Force # Validate script syntax From 2ed764ef01ee5742d363e890d029b3537c2707b2 Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Tue, 14 Jul 2020 13:55:21 -0600 Subject: [PATCH 19/29] return warning to pipelines --- .../Tests/ModuleValidation/PesterFiles.Tests.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Tests/ModuleValidation/PesterFiles.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/ModuleValidation/PesterFiles.Tests.ps1 index d93efa0dd..ff8d79f4f 100755 --- a/PowerShell/JumpCloud Module/Tests/ModuleValidation/PesterFiles.Tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/ModuleValidation/PesterFiles.Tests.ps1 @@ -16,7 +16,13 @@ Describe -Tag:('ModuleValidation') 'Pester Files Tests' { Test-Path -Path:($FilePath) | Should -Be $true } It ('Validating Pester test file has been populated for ""') -TestCases:(Get-PesterFilesTestCases) { - $FilePath | Should -FileContentMatch '.*?' + # $FilePath | Should -FileContentMatch '.*?' + $FileContent = Get-Content -Path:($FilePath) -Raw + If ([System.String]::IsNullOrEmpty($FileContent)) + { + Write-Host("##vso[task.logissue type=warning;]" + 'The test file "' + $FilePath + '" has not been populated.') + Write-Warning ('The test file "' + $FilePath + '" has not been populated.') + } } } } From 33bb3fbc1171b5dc5ef978dd9c4503052ce6cfc0 Mon Sep 17 00:00:00 2001 From: AzurePipelines Date: Tue, 14 Jul 2020 20:07:19 +0000 Subject: [PATCH 20/29] Push to refs/heads/SA-1239-Intergrate-SDKs;[skip ci] --- .../JumpCloud Module/Docs/Get-JCEvent.md | 84 +-- .../JumpCloud Module/Docs/Get-JCEventCount.md | 267 +++++++++ PowerShell/JumpCloud Module/JumpCloud.psd1 | 7 +- .../Public/DirectoryInsights/Get-JCEvent.ps1 | 143 +++++ .../DirectoryInsights/Get-JCEventCount.ps1 | 127 ++++ .../Get-JCEventCount.Tests.ps1 | 0 .../JumpCloud Module/en-Us/JumpCloud-help.xml | 554 ++++++++++++++---- 7 files changed, 1006 insertions(+), 176 deletions(-) create mode 100644 PowerShell/JumpCloud Module/Docs/Get-JCEventCount.md create mode 100644 PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 create mode 100644 PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 create mode 100644 PowerShell/JumpCloud Module/Tests/Public/DirectoryInsights/Get-JCEventCount.Tests.ps1 diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCEvent.md b/PowerShell/JumpCloud Module/Docs/Get-JCEvent.md index 590d32fea..ada491582 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCEvent.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCEvent.md @@ -14,14 +14,14 @@ Query the API for Directory Insights events ### GetExpanded (Default) ``` -Get-JCEvent [-EndTime ] [-Fields ] [-Limit ] [-SearchAfter ] - [-SearchTermAnd ] [-SearchTermOr ] [-Service ] [-Sort ] - [-StartTime ] [-Paginate ] [-WhatIf] [-Confirm] [] +Get-JCEvent -Service -StartTime [-EndTime ] [-Fields ] + [-SearchAfter ] [-SearchTermAnd ] [-SearchTermOr ] [-Sort ] [-WhatIf] + [-Confirm] [] ``` ### Get ``` -Get-JCEvent -EventQueryBody [-Paginate ] [-WhatIf] [-Confirm] [] +Get-JCEvent -Body [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -87,42 +87,42 @@ Get all events filtered by organization_update term between a date range ## PARAMETERS -### -EventQueryBody -EventQuery is the users' command to search our auth logs -To construct, see NOTES section for EVENTQUERYBODY properties and create a hash table. +### -Service +service name to query. +Known services: systems,radius,sso,directory,ldap,all ```yaml -Type: JumpCloud.SDK.DirectoryInsights.Models.IEventQuery -Parameter Sets: Get +Type: System.String[] +Parameter Sets: GetExpanded Aliases: Required: True Position: Named Default value: None -Accept pipeline input: True (ByValue) +Accept pipeline input: False Accept wildcard characters: False ``` -### -EndTime -optional query end time, UTC in RFC3339 format +### -StartTime +query start time, UTC in RFC3339 format ```yaml Type: System.DateTime Parameter Sets: GetExpanded Aliases: -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -Fields -optional list of fields to return from query +### -EndTime +optional query end time, UTC in RFC3339 format ```yaml -Type: System.String[] +Type: System.DateTime Parameter Sets: GetExpanded Aliases: @@ -133,17 +133,17 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Limit -Max number of rows to return +### -Fields +optional list of fields to return from query ```yaml -Type: System.Int64 +Type: System.String[] Parameter Sets: GetExpanded Aliases: Required: False Position: Named -Default value: 0 +Default value: None Accept pipeline input: False Accept wildcard characters: False ``` @@ -195,22 +195,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Service -service name to query. -Known services: systems,radius,sso,directory,ldap,all - -```yaml -Type: System.String[] -Parameter Sets: GetExpanded -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -Sort ASC or DESC order for timestamp @@ -226,33 +210,19 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -StartTime -query start time, UTC in RFC3339 format +### -Body +EventQuery is the users' command to search our auth logs +To construct, see NOTES section for BODY properties and create a hash table. ```yaml -Type: System.DateTime -Parameter Sets: GetExpanded +Type: JumpCloud.SDK.DirectoryInsights.Models.IEventQuery +Parameter Sets: Get Aliases: -Required: False +Required: True Position: Named Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Paginate -Set to $true to return all results. - -```yaml -Type: System.Boolean -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: True -Accept pipeline input: False +Accept pipeline input: True (ByValue) Accept wildcard characters: False ``` diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCEventCount.md b/PowerShell/JumpCloud Module/Docs/Get-JCEventCount.md new file mode 100644 index 000000000..a292e916a --- /dev/null +++ b/PowerShell/JumpCloud Module/Docs/Get-JCEventCount.md @@ -0,0 +1,267 @@ +--- +external help file: JumpCloud-help.xml +Module Name: JumpCloud +online version: https://github.com/TheJumpCloud/support/wiki/Get-JCEventCount +schema: 2.0.0 +--- + +# Get-JCEventCount + +## SYNOPSIS +Query the API for a count of matching events + +## SYNTAX + +### GetExpanded (Default) +``` +Get-JCEventCount -Service -StartTime [-EndTime ] [-Fields ] + [-SearchAfter ] [-SearchTermAnd ] [-SearchTermOr ] [-Sort ] [-WhatIf] + [-Confirm] [] +``` + +### Get +``` +Get-JCEventCount -Body [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Query the API for a count of matching events + +## EXAMPLES + +### EXAMPLE 1 +``` +Get-JCEventCount -Service:('all') -StartTime:((Get-date).AddDays(-30)) +``` + +Pull all event records from a specified time and count the results + +### EXAMPLE 2 +``` +Get-JCEventCount -Service:('sso') -StartTime:('2020-04-14T00:00:00Z') +``` + +Pull all SSO event records from a specified time and count the results + +### EXAMPLE 3 +``` +Get-JCEventCount -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"event_type" = "admin_login_attempt"; "resource.email" = "admin.user@adminbizorg.com"} +``` + +Get all events counts between a date range and match event_type = admin_login_attempt and resource.email = admin.user@adminbizorg.com + +### EXAMPLE 4 +``` +Get-JCEventCount -Service:('directory') -StartTime:((Get-date).AddDays(-30)) -searchTermAnd:@{"event_type" = "group_create"} +``` + +Get only group_create event counts the last thirty days + +## PARAMETERS + +### -Service +service name to query. +Known services: systems,radius,sso,directory,ldap,all + +```yaml +Type: System.String[] +Parameter Sets: GetExpanded +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -StartTime +query start time, UTC in RFC3339 format + +```yaml +Type: System.DateTime +Parameter Sets: GetExpanded +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -EndTime +optional query end time, UTC in RFC3339 format + +```yaml +Type: System.DateTime +Parameter Sets: GetExpanded +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Fields +optional list of fields to return from query + +```yaml +Type: System.String[] +Parameter Sets: GetExpanded +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SearchAfter +Specific query to search after, see x-* response headers for next values + +```yaml +Type: System.String[] +Parameter Sets: GetExpanded +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SearchTermAnd +list of event terms. +If all terms match the event will be returned by the service. + +```yaml +Type: System.Collections.Hashtable +Parameter Sets: GetExpanded +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SearchTermOr +list of event terms. +If any term matches, the event will be returned by the service. + +```yaml +Type: System.Collections.Hashtable +Parameter Sets: GetExpanded +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Sort +ASC or DESC order for timestamp + +```yaml +Type: System.String +Parameter Sets: GetExpanded +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Body +EventQuery is the users' command to search our auth logs +To construct, see NOTES section for BODY properties and create a hash table. + +```yaml +Type: JumpCloud.SDK.DirectoryInsights.Models.IEventQuery +Parameter Sets: Get +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: cf + +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). + +## INPUTS + +### JumpCloud.SDK.DirectoryInsights.Models.IEventQuery +## OUTPUTS + +### System.Int64 +### System.String +## NOTES +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. +For information on hash tables, run Get-Help about_Hash_Tables. + +BODY \: EventQuery is the users' command to search our auth logs + Service \: service name to query. +Known services: systems,radius,sso,directory,ldap,all + StartTime \: query start time, UTC in RFC3339 format + \[EndTime \\]: optional query end time, UTC in RFC3339 format + \[Fields \\]: optional list of fields to return from query + \[Limit \\]: Max number of rows to return + \[SearchAfter \\]: Specific query to search after, see x-* response headers for next values + \[SearchTermAnd \\]: list of event terms. +If all terms match the event will be returned by the service. + \[(Any) \\]: This indicates any property can be added to this object. + \[SearchTermOr \\]: list of event terms. +If any term matches, the event will be returned by the service. + \[(Any) \\]: This indicates any property can be added to this object. + \[Sort \\]: ASC or DESC order for timestamp + +## RELATED LINKS + +[https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/jumpcloud.sdk.directoryinsights/get-jcsdkeventcount](https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/jumpcloud.sdk.directoryinsights/get-jcsdkeventcount) + diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 2353d9413..fc51f85a2 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -94,7 +94,8 @@ FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget', 'Send-JCPasswordReset', 'Set-JCCommand', 'Set-JCOrganization', 'Set-JCRadiusReplyAttribute', 'Set-JCRadiusServer', 'Set-JCSystem', 'Set-JCSystemUser', 'Set-JCUser', 'Set-JCUserGroupLDAP', - 'Update-JCModule', 'Update-JCUsersFromCSV' + 'Update-JCModule', 'Update-JCUsersFromCSV', 'Get-JCEvent', + 'Get-JCEventCount' # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. CmdletsToExport = @() @@ -120,7 +121,7 @@ PrivateData = @{ PSData = @{ # Tags applied to this module. These help with module discovery in online galleries. - Tags = 'JumpCloud', 'DaaS', 'Jump', 'Cloud', 'Directory' + Tags = 'JumpCloud','DaaS','Jump','Cloud','Directory' # A URL to the license for this module. LicenseUri = 'https://github.com/TheJumpCloud/support/blob/master/PowerShell/LICENSE' @@ -145,7 +146,7 @@ PrivateData = @{ } # End of PSData hashtable -} # End of PrivateData hashtable + } # End of PrivateData hashtable # HelpInfo URI of this module HelpInfoURI = 'https://github.com/TheJumpCloud/support/wiki' diff --git a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 new file mode 100644 index 000000000..51c47e8ea --- /dev/null +++ b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 @@ -0,0 +1,143 @@ +<# +.Synopsis +Query the API for Directory Insights events +.Description +Query the API for Directory Insights events +.Example +PS C:\> Get-JCEvent -Service:('all') -StartTime:((Get-date).AddDays(-30)) + +Pull all event records from the last thirty days +.Example +PS C:\> Get-JCEvent -Service:('directory') -StartTime:((Get-date).AddHours(-1)) -Limit:('10') + +Get directory results from the last hour limit to the last 10 results in the time range +.Example +PS C:\> Get-JCEvent -Service:('directory') -StartTime:((Get-date).AddDays(-30)) -Sort:("DESC") -EndTime:((Get-date).AddDays(-5)) + +Get directory results between 30 and 5 days ago, sort timestamp by descending value +.Example +PS C:\> Get-JCEvent -Service:('directory') -StartTime:((Get-date).AddDays(-30)) -Limit:('10') -searchTermAnd:@{"event_type" = "group_create"} + +Get only group_create from the last thirty days +.Example +PS C:\> Get-JCEvent -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermOr @{"initiated_by.username" = @("user.1", "user.2")} + +Get login events initiated by either "user.1" or "user.2" between a universal time zone range +.Example +PS C:\> Get-JCEvent -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"event_type" = "admin_login_attempt"; "resource.email" = "admin.user@adminbizorg.com"} + +Get all events between a date range and match event_type = admin_login_attempt and resource.email = admin.user@adminbizorg.com +.Example +PS C:\> Get-JCEvent -Service:('sso') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"initiated_by.username" = "user.1"} + +Get sso events with the search term initiated_by: username with value "user.1" +.Example +PS C:\> Get-JCEvent -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"event_type" = "organization_update"} + +Get all events filtered by organization_update term between a date range + +.Inputs +JumpCloud.SDK.DirectoryInsights.Models.IEventQuery +.Outputs +JumpCloud.SDK.DirectoryInsights.Models.IPost200ApplicationJsonItemsItem +.Outputs +System.String +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +BODY : EventQuery is the users' command to search our auth logs + Service : service name to query. Known services: systems,radius,sso,directory,ldap,all + StartTime : query start time, UTC in RFC3339 format + [EndTime ]: optional query end time, UTC in RFC3339 format + [Fields ]: optional list of fields to return from query + [Limit ]: Max number of rows to return + [SearchAfter ]: Specific query to search after, see x-* response headers for next values + [SearchTermAnd ]: list of event terms. If all terms match the event will be returned by the service. + [(Any) ]: This indicates any property can be added to this object. + [SearchTermOr ]: list of event terms. If any term matches, the event will be returned by the service. + [(Any) ]: This indicates any property can be added to this object. + [Sort ]: ASC or DESC order for timestamp +.Link +https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/jumpcloud.sdk.directoryinsights/get-jcsdkevent +#> +Function Get-JCEvent +{ + [OutputType([JumpCloud.SDK.DirectoryInsights.Models.IPost200ApplicationJsonItemsItem], [System.String])] + [CmdletBinding(DefaultParameterSetName='GetExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] + Param( + [Parameter(ParameterSetName='GetExpanded', Mandatory)] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.String[]] + # service name to query. + # Known services: systems,radius,sso,directory,ldap,all + ${Service}, + + [Parameter(ParameterSetName='GetExpanded', Mandatory)] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.DateTime] + # query start time, UTC in RFC3339 format + ${StartTime}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.DateTime] + # optional query end time, UTC in RFC3339 format + ${EndTime}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.String[]] + # optional list of fields to return from query + ${Fields}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.String[]] + # Specific query to search after, see x-* response headers for next values + ${SearchAfter}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [JumpCloud.SDK.DirectoryInsights.Runtime.Info(PossibleTypes=([JumpCloud.SDK.DirectoryInsights.Models.ISearchTermAnd]))] + [System.Collections.Hashtable] + # list of event terms. + # If all terms match the event will be returned by the service. + ${SearchTermAnd}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [JumpCloud.SDK.DirectoryInsights.Runtime.Info(PossibleTypes=([JumpCloud.SDK.DirectoryInsights.Models.ISearchTermOr]))] + [System.Collections.Hashtable] + # list of event terms. + # If any term matches, the event will be returned by the service. + ${SearchTermOr}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.String] + # ASC or DESC order for timestamp + ${Sort}, + + [Parameter(ParameterSetName='Get', Mandatory, ValueFromPipeline)] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [JumpCloud.SDK.DirectoryInsights.Models.IEventQuery] + # EventQuery is the users' command to search our auth logs + # To construct, see NOTES section for BODY properties and create a hash table. + ${Body} + ) + Begin + { + Connect-JCOnline -force | Out-Null + $Results = @() + } + Process + { + $Results = JumpCloud.SDK.DirectoryInsights\Get-JcSdkEvent @PSBoundParameters + } + End + { + Return $Results + } +} diff --git a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 new file mode 100644 index 000000000..52b4d6956 --- /dev/null +++ b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 @@ -0,0 +1,127 @@ +<# +.Synopsis +Query the API for a count of matching events +.Description +Query the API for a count of matching events +.Example +PS C:\> Get-JCEventCount -Service:('all') -StartTime:((Get-date).AddDays(-30)) + +Pull all event records from a specified time and count the results +.Example +PS C:\> Get-JCEventCount -Service:('sso') -StartTime:('2020-04-14T00:00:00Z') + +Pull all SSO event records from a specified time and count the results +.Example +PS C:\> Get-JCEventCount -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"event_type" = "admin_login_attempt"; "resource.email" = "admin.user@adminbizorg.com"} + +Get all events counts between a date range and match event_type = admin_login_attempt and resource.email = admin.user@adminbizorg.com +.Example +PS C:\> Get-JCEventCount -Service:('directory') -StartTime:((Get-date).AddDays(-30)) -searchTermAnd:@{"event_type" = "group_create"} + +Get only group_create event counts the last thirty days + +.Inputs +JumpCloud.SDK.DirectoryInsights.Models.IEventQuery +.Outputs +System.Int64 +.Outputs +System.String +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +BODY : EventQuery is the users' command to search our auth logs + Service : service name to query. Known services: systems,radius,sso,directory,ldap,all + StartTime : query start time, UTC in RFC3339 format + [EndTime ]: optional query end time, UTC in RFC3339 format + [Fields ]: optional list of fields to return from query + [Limit ]: Max number of rows to return + [SearchAfter ]: Specific query to search after, see x-* response headers for next values + [SearchTermAnd ]: list of event terms. If all terms match the event will be returned by the service. + [(Any) ]: This indicates any property can be added to this object. + [SearchTermOr ]: list of event terms. If any term matches, the event will be returned by the service. + [(Any) ]: This indicates any property can be added to this object. + [Sort ]: ASC or DESC order for timestamp +.Link +https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/jumpcloud.sdk.directoryinsights/get-jcsdkeventcount +#> +Function Get-JCEventCount +{ + [OutputType([System.Int64], [System.String])] + [CmdletBinding(DefaultParameterSetName='GetExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] + Param( + [Parameter(ParameterSetName='GetExpanded', Mandatory)] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.String[]] + # service name to query. + # Known services: systems,radius,sso,directory,ldap,all + ${Service}, + + [Parameter(ParameterSetName='GetExpanded', Mandatory)] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.DateTime] + # query start time, UTC in RFC3339 format + ${StartTime}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.DateTime] + # optional query end time, UTC in RFC3339 format + ${EndTime}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.String[]] + # optional list of fields to return from query + ${Fields}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.String[]] + # Specific query to search after, see x-* response headers for next values + ${SearchAfter}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [JumpCloud.SDK.DirectoryInsights.Runtime.Info(PossibleTypes=([JumpCloud.SDK.DirectoryInsights.Models.ISearchTermAnd]))] + [System.Collections.Hashtable] + # list of event terms. + # If all terms match the event will be returned by the service. + ${SearchTermAnd}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [JumpCloud.SDK.DirectoryInsights.Runtime.Info(PossibleTypes=([JumpCloud.SDK.DirectoryInsights.Models.ISearchTermOr]))] + [System.Collections.Hashtable] + # list of event terms. + # If any term matches, the event will be returned by the service. + ${SearchTermOr}, + + [Parameter(ParameterSetName='GetExpanded')] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [System.String] + # ASC or DESC order for timestamp + ${Sort}, + + [Parameter(ParameterSetName='Get', Mandatory, ValueFromPipeline)] + [JumpCloud.SDK.DirectoryInsights.Category('Body')] + [JumpCloud.SDK.DirectoryInsights.Models.IEventQuery] + # EventQuery is the users' command to search our auth logs + # To construct, see NOTES section for BODY properties and create a hash table. + ${Body} + ) + Begin + { + Connect-JCOnline -force | Out-Null + $Results = @() + } + Process + { + $Results = JumpCloud.SDK.DirectoryInsights\Get-JcSdkEventCount @PSBoundParameters + } + End + { + Return $Results + } +} diff --git a/PowerShell/JumpCloud Module/Tests/Public/DirectoryInsights/Get-JCEventCount.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/DirectoryInsights/Get-JCEventCount.Tests.ps1 new file mode 100644 index 000000000..e69de29bb diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index f452acd30..13e8a890e 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -3763,55 +3763,30 @@ Get-JCEvent - - EventQueryBody + + Service - EventQuery is the users' command to search our auth logs To construct, see NOTES section for EVENTQUERYBODY properties and create a hash table. + service name to query. Known services: systems,radius,sso,directory,ldap,all - JumpCloud.SDK.DirectoryInsights.Models.IEventQuery + System.String[] - JumpCloud.SDK.DirectoryInsights.Models.IEventQuery + System.String[] None - - Paginate - - Set to $true to return all results. - - System.Boolean - - System.Boolean - - - True - - - WhatIf - - Shows what would happen if the cmdlet runs. The cmdlet is not run. - - - System.Management.Automation.SwitchParameter - - - False - - - Confirm + + StartTime - Prompts you for confirmation before running the cmdlet. + query start time, UTC in RFC3339 format + System.DateTime - System.Management.Automation.SwitchParameter + System.DateTime - False + None - - - Get-JCEvent EndTime @@ -3836,18 +3811,6 @@ None - - Limit - - Max number of rows to return - - System.Int64 - - System.Int64 - - - 0 - SearchAfter @@ -3885,52 +3848,53 @@ None - Service + Sort - service name to query. Known services: systems,radius,sso,directory,ldap,all + ASC or DESC order for timestamp - System.String[] + System.String - System.String[] + System.String None - - Sort + + WhatIf - ASC or DESC order for timestamp + Shows what would happen if the cmdlet runs. The cmdlet is not run. - System.String - System.String + System.Management.Automation.SwitchParameter - None + False - - StartTime + + Confirm - query start time, UTC in RFC3339 format + Prompts you for confirmation before running the cmdlet. - System.DateTime - System.DateTime + System.Management.Automation.SwitchParameter - None + False - - Paginate + + + Get-JCEvent + + Body - Set to $true to return all results. + EventQuery is the users' command to search our auth logs To construct, see NOTES section for BODY properties and create a hash table. - System.Boolean + JumpCloud.SDK.DirectoryInsights.Models.IEventQuery - System.Boolean + JumpCloud.SDK.DirectoryInsights.Models.IEventQuery - True + None WhatIf @@ -3957,14 +3921,26 @@ - - EventQueryBody + + Service + + service name to query. Known services: systems,radius,sso,directory,ldap,all + + System.String[] + + System.String[] + + + None + + + StartTime - EventQuery is the users' command to search our auth logs To construct, see NOTES section for EVENTQUERYBODY properties and create a hash table. + query start time, UTC in RFC3339 format - JumpCloud.SDK.DirectoryInsights.Models.IEventQuery + System.DateTime - JumpCloud.SDK.DirectoryInsights.Models.IEventQuery + System.DateTime None @@ -3993,18 +3969,6 @@ None - - Limit - - Max number of rows to return - - System.Int64 - - System.Int64 - - - 0 - SearchAfter @@ -4041,18 +4005,6 @@ None - - Service - - service name to query. Known services: systems,radius,sso,directory,ldap,all - - System.String[] - - System.String[] - - - None - Sort @@ -4065,30 +4017,18 @@ None - - StartTime + + Body - query start time, UTC in RFC3339 format + EventQuery is the users' command to search our auth logs To construct, see NOTES section for BODY properties and create a hash table. - System.DateTime + JumpCloud.SDK.DirectoryInsights.Models.IEventQuery - System.DateTime + JumpCloud.SDK.DirectoryInsights.Models.IEventQuery None - - Paginate - - Set to $true to return all results. - - System.Boolean - - System.Boolean - - - True - WhatIf @@ -4213,6 +4153,388 @@ + + + Get-JCEventCount + Get + JCEventCount + + Query the API for a count of matching events + + + + Query the API for a count of matching events + + + + Get-JCEventCount + + Service + + service name to query. Known services: systems,radius,sso,directory,ldap,all + + System.String[] + + System.String[] + + + None + + + StartTime + + query start time, UTC in RFC3339 format + + System.DateTime + + System.DateTime + + + None + + + EndTime + + optional query end time, UTC in RFC3339 format + + System.DateTime + + System.DateTime + + + None + + + Fields + + optional list of fields to return from query + + System.String[] + + System.String[] + + + None + + + SearchAfter + + Specific query to search after, see x-* response headers for next values + + System.String[] + + System.String[] + + + None + + + SearchTermAnd + + list of event terms. If all terms match the event will be returned by the service. + + System.Collections.Hashtable + + System.Collections.Hashtable + + + None + + + SearchTermOr + + list of event terms. If any term matches, the event will be returned by the service. + + System.Collections.Hashtable + + System.Collections.Hashtable + + + None + + + Sort + + ASC or DESC order for timestamp + + System.String + + System.String + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + System.Management.Automation.SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + System.Management.Automation.SwitchParameter + + + False + + + + Get-JCEventCount + + Body + + EventQuery is the users' command to search our auth logs To construct, see NOTES section for BODY properties and create a hash table. + + JumpCloud.SDK.DirectoryInsights.Models.IEventQuery + + JumpCloud.SDK.DirectoryInsights.Models.IEventQuery + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + System.Management.Automation.SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + System.Management.Automation.SwitchParameter + + + False + + + + + + Service + + service name to query. Known services: systems,radius,sso,directory,ldap,all + + System.String[] + + System.String[] + + + None + + + StartTime + + query start time, UTC in RFC3339 format + + System.DateTime + + System.DateTime + + + None + + + EndTime + + optional query end time, UTC in RFC3339 format + + System.DateTime + + System.DateTime + + + None + + + Fields + + optional list of fields to return from query + + System.String[] + + System.String[] + + + None + + + SearchAfter + + Specific query to search after, see x-* response headers for next values + + System.String[] + + System.String[] + + + None + + + SearchTermAnd + + list of event terms. If all terms match the event will be returned by the service. + + System.Collections.Hashtable + + System.Collections.Hashtable + + + None + + + SearchTermOr + + list of event terms. If any term matches, the event will be returned by the service. + + System.Collections.Hashtable + + System.Collections.Hashtable + + + None + + + Sort + + ASC or DESC order for timestamp + + System.String + + System.String + + + None + + + Body + + EventQuery is the users' command to search our auth logs To construct, see NOTES section for BODY properties and create a hash table. + + JumpCloud.SDK.DirectoryInsights.Models.IEventQuery + + JumpCloud.SDK.DirectoryInsights.Models.IEventQuery + + + None + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + System.Management.Automation.SwitchParameter + + System.Management.Automation.SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + System.Management.Automation.SwitchParameter + + System.Management.Automation.SwitchParameter + + + False + + + + + + JumpCloud.SDK.DirectoryInsights.Models.IEventQuery + + + + + + + + + + System.Int64 + + + + + + + + System.String + + + + + + + + + COMPLEX PARAMETER PROPERTIES + To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + BODY <IEventQuery>: EventQuery is the users' command to search our auth logs Service <String[]>: service name to query. Known services: systems,radius,sso,directory,ldap,all StartTime <DateTime>: query start time, UTC in RFC3339 format [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 [SearchTermAnd <ISearchTermAnd>]: list of event terms. If all terms match the event will be returned by the service. [(Any) <Object>]: This indicates any property can be added to this object. [SearchTermOr <ISearchTermOr>]: list of event terms. If any term matches, the event will be returned by the service. [(Any) <Object>]: This indicates any property can be added to this object. [Sort <String>]: ASC or DESC order for timestamp + + + + + -------------------------- EXAMPLE 1 -------------------------- + Get-JCEventCount -Service:('all') -StartTime:((Get-date).AddDays(-30)) + + Pull all event records from a specified time and count the results + + + + -------------------------- EXAMPLE 2 -------------------------- + Get-JCEventCount -Service:('sso') -StartTime:('2020-04-14T00:00:00Z') + + Pull all SSO event records from a specified time and count the results + + + + -------------------------- EXAMPLE 3 -------------------------- + Get-JCEventCount -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"event_type" = "admin_login_attempt"; "resource.email" = "admin.user@adminbizorg.com"} + + Get all events counts between a date range and match event_type = admin_login_attempt and resource.email = admin.user@adminbizorg.com + + + + -------------------------- EXAMPLE 4 -------------------------- + Get-JCEventCount -Service:('directory') -StartTime:((Get-date).AddDays(-30)) -searchTermAnd:@{"event_type" = "group_create"} + + Get only group_create event counts the last thirty days + + + + + + Online Version: + https://github.com/TheJumpCloud/support/wiki/Get-JCEventCount + + + https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/jumpcloud.sdk.directoryinsights/get-jcsdkeventcount + https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/jumpcloud.sdk.directoryinsights/get-jcsdkeventcount + + + Get-JCGroup From b2dbd24b9056f1aa6722b819bc8403f55b532e28 Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Fri, 17 Jul 2020 09:18:01 -0600 Subject: [PATCH 21/29] update change log --- PowerShell/ModuleChangelog.md | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 90ad7d76c..ce769b991 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -8,29 +8,15 @@ Use Get-JCSystemInsight to query additional System Insights tables. #### FEATURES -#### IMPROVEMENTS - -#### BUG FIXES - -Fix for windows PowerShell Update-JCModule function - -## 1.17.4 - -Release Date: July 9, 2020 - -#### RELEASE NOTES - -Use Get-JCSystemInsight to query additional System Insights tables. - -#### FEATURES +Updated Get-JCEvent. +New function Get-JCEventCount. +Remove Depreciated SystemInsights Registry Table. #### IMPROVEMENTS #### BUG FIXES -Fix for Update-JCModule Pester tests - -Remove Depreciated SystemInsights Registry Table +Fix for windows PowerShell Update-JCModule function. ## 1.17.3 From dd669e64ba92cbd612c1ba00361135a855f43b57 Mon Sep 17 00:00:00 2001 From: AzurePipelines Date: Fri, 17 Jul 2020 15:33:35 +0000 Subject: [PATCH 22/29] Push to refs/heads/JumpCloudModule_1.17.5;[skip ci] --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 8 ++++---- PowerShell/ModuleBanner.md | 8 +++----- PowerShell/ModuleChangelog.md | 22 ++++++++++++++++++++++ 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 080da8b45..ca65125d8 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 7/14/2020 +# Generated on: 7/17/2020 # @{ @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '1.17.5' +ModuleVersion = '1.17.4' # Supported PSEditions # CompatiblePSEditions = @() @@ -76,8 +76,8 @@ FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget', 'Add-JCSystemUser', 'Add-JCUserGroupMember', 'Connect-JCOnline', 'Copy-JCAssociation', 'Get-JCAssociation', 'Get-JCBackup', 'Get-JCCommand', 'Get-JCCommandResult', 'Get-JCCommandTarget', - 'Get-JCGroup', 'Get-JCOrganization', 'Get-JCPolicy', - 'Get-JCPolicyResult', 'Get-JCPolicyTargetGroup', + 'Get-JCEvent', 'Get-JCEventCount', 'Get-JCGroup', 'Get-JCOrganization', + 'Get-JCPolicy', 'Get-JCPolicyResult', 'Get-JCPolicyTargetGroup', 'Get-JCPolicyTargetSystem', 'Get-JCRadiusReplyAttribute', 'Get-JCRadiusServer', 'Get-JCSystem', 'Get-JCSystemGroupMember', 'Get-JCSystemInsights', 'Get-JCSystemUser', 'Get-JCUser', diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index 9e8656789..c81681e79 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,19 +1,17 @@ #### Latest Version ``` -1.17.5 +1.17.4 ``` #### Banner Current ``` -Use Get-JCSystemInsight to query additional System Insights tables. -!!IF YOU RECEIVE AN ERROR WHILE UPDATING THE MODULE PLEASE RUN: Install-Module JumpCloud -force +{{Fill in the Banner Current}} ``` #### Banner Old ``` -Use Get-JCSystemInsight to query additional System Insights tables. -!!IF YOU RECEIVE AN ERROR WHILE UPDATING THE MODULE PLEASE RUN: Install-Module JumpCloud -force +{{Fill in the Banner Old}} ``` diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 90ad7d76c..c781e7a88 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,25 @@ +## 1.17.4 + +Release Date: July 17, 2020 + +#### RELEASE NOTES + +``` +{{Fill in the Release Notes}} +``` + +#### FEATURES: + +{{Fill in the Features}} + +#### IMPROVEMENTS: + +{{Fill in the Improvements}} + +#### BUG FIXES: + +{{Fill in the Bug Fixes}} + ## 1.17.5 Release Date: July 13, 2020 From cf5a5b16df4a8f4da4e292d8744895204cf3c892 Mon Sep 17 00:00:00 2001 From: epanipinto-jc <45767377+epanipinto-jc@users.noreply.github.com> Date: Fri, 17 Jul 2020 10:28:42 -0600 Subject: [PATCH 23/29] fix url --- PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 | 1 + .../JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 | 2 +- .../Public/DirectoryInsights/Get-JCEventCount.ps1 | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 index 897e700ac..62ef6e747 100644 --- a/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 +++ b/PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1 @@ -62,6 +62,7 @@ If (-not [System.String]::IsNullOrEmpty($Modules)) If (-not [System.String]::IsNullOrEmpty($PSScriptInfo)) { $PSScriptInfo = $PSScriptInfo.Replace($SdkPrefix, $JumpCloudModulePrefix) + $PSScriptInfo = $PSScriptInfo.Replace("$NewCommandName.md", "$FunctionName.md") } # Build CmdletBinding If (-not [System.String]::IsNullOrEmpty($OutputType)) { $CmdletBinding = "$($OutputType)`n$($IndentChar)$($CmdletBinding)" } diff --git a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 index 51c47e8ea..6b7a7b0ed 100644 --- a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 +++ b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 @@ -60,7 +60,7 @@ BODY : EventQuery is the users' command to search our auth logs [(Any) ]: This indicates any property can be added to this object. [Sort ]: ASC or DESC order for timestamp .Link -https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/jumpcloud.sdk.directoryinsights/get-jcsdkevent +https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/docs/exports/Get-JcSdkEvent.md #> Function Get-JCEvent { diff --git a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 index 52b4d6956..b67738c71 100644 --- a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 +++ b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 @@ -44,7 +44,7 @@ BODY : EventQuery is the users' command to search our auth logs [(Any) ]: This indicates any property can be added to this object. [Sort ]: ASC or DESC order for timestamp .Link -https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/jumpcloud.sdk.directoryinsights/get-jcsdkeventcount +https://github.com/TheJumpCloud/jcapi-powershell/tree/master/SDKs/PowerShell/JumpCloud.SDK.DirectoryInsights/docs/exports/Get-JcSdkEventCount.md #> Function Get-JCEventCount { From bc74d300d31d8a7eae8dff769ea8ac0cb6cdb2af Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Fri, 17 Jul 2020 10:55:35 -0600 Subject: [PATCH 24/29] Remove limit and specify four events to test --- .../DirectoryInsights/Get-JCEvent.Tests.ps1 | 51 +++++++------------ 1 file changed, 17 insertions(+), 34 deletions(-) diff --git a/PowerShell/JumpCloud Module/Tests/Public/DirectoryInsights/Get-JCEvent.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/DirectoryInsights/Get-JCEvent.Tests.ps1 index c42d13eca..fdb79fd36 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/DirectoryInsights/Get-JCEvent.Tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/DirectoryInsights/Get-JCEvent.Tests.ps1 @@ -6,26 +6,17 @@ Describe 'Get-JCEvent' -Tag:('JCEvent') { #> # Define parameters for functions $ParamHash = @{ - "StartTime" = (Get-Date).ToUniversalTime(); - "EndTime" = 'PlaceHolderDateTime'; + "StartTime" = (Get-Date).AddHours(-24).ToUniversalTime(); + "EndTime" = (Get-Date).ToUniversalTime(); "Service" = "all"; "Sort" = "DESC" - "Limit" = 2; "SearchTermAnd" = @{ "event_type" = "user_delete" } } - If ((Get-Command Get-JCEvent).Parameters.ContainsKey('Paginate')) - { - $ParamHash.Limit = ($ParamHash.Limit * 2) - } - Else - { - $ParamHash.Limit - } # Create event records for tests Connect-JCOnline -force | Out-Null - For ($i = 1; $i -le $ParamHash.Limit; $i++) + For ($i = 1; $i -le 4; $i++) { $UserName = 'JCSystemUserTest-{0}' -f $i Write-Host ("Creating add/delete records for: $UserName") @@ -45,47 +36,39 @@ Describe 'Get-JCEvent' -Tag:('JCEvent') { $EndTime = [DateTime]$ParamHash.EndTime } It 'GetExpanded' { - $eventTest = Get-JCEvent -Service:($ParamHash.Service) -StartTime:($ParamHash.StartTime) -EndTime:($ParamHash.EndTime) -Limit:($ParamHash.Limit) -Sort:($ParamHash.Sort) -SearchTermAnd:($ParamHash.SearchTermAnd) - If ([System.String]::IsNullOrEmpty($eventTest)) - { + $eventTest = Get-JCEvent -Service:($ParamHash.Service) -StartTime:($ParamHash.StartTime) -EndTime:($ParamHash.EndTime) -Sort:($ParamHash.Sort) -SearchTermAnd:($ParamHash.SearchTermAnd) + If ([System.String]::IsNullOrEmpty($eventTest)) { $eventTest | Should -Not -BeNullOrEmpty } - Else - { - $eventTest = ($eventTest) + Else { + # $eventTest = $eventTest $MostRecentRecord = ([System.DateTime]($eventTest | Select-Object -First 1).timestamp).ToUniversalTime() $OldestRecord = ([System.DateTime]($eventTest | Select-Object -Last 1).timestamp).ToUniversalTime() - # Limit - Test that results count matches parameter value - $eventTest.Count | Should -Be $ParamHash.Limit # Sort - Test that results come back in decending DateTime - $MostRecentRecord.Ticks | Should -BeGreaterThan $OldestRecord.Ticks + $MostRecentRecord | Should -BeGreaterThan $OldestRecord # EndTime - Test that results are not newer than EndTime parameter value - $MostRecentRecord.Ticks | Should -BeLessOrEqual $EndTime.Ticks + $MostRecentRecord | Should -BeLessOrEqual $ParamHash.EndTime # StartTime - Test that results are not older than StartTime parameter value - $OldestRecord.Ticks | Should -BeGreaterOrEqual $StartTime.Ticks + $OldestRecord | Should -BeGreaterOrEqual $ParamHash.StartTime # SearchTermAnd - Test that results matches parameter value ($eventTest.event_type | Select-Object -Unique) | Should -Be $ParamHash.SearchTermAnd.event_type } } It 'Get' { - $eventTest = Get-JCEvent -EventQueryBody:($ParamHash) - If ([System.String]::IsNullOrEmpty($eventTest)) - { + $eventTest = Get-JCEvent -Body:($ParamHash) + If ([System.String]::IsNullOrEmpty($eventTest)) { $eventTest | Should -Not -BeNullOrEmpty } - Else - { - $eventTest = ($eventTest) + Else { + # $eventTest = $eventTest $MostRecentRecord = ([System.DateTime]($eventTest | Select-Object -First 1).timestamp).ToUniversalTime() $OldestRecord = ([System.DateTime]($eventTest | Select-Object -Last 1).timestamp).ToUniversalTime() - # Limit - Test that results count matches parameter value - $eventTest.Count | Should -Be $ParamHash.Limit # Sort - Test that results come back in decending DateTime - $MostRecentRecord.Ticks | Should -BeGreaterThan $OldestRecord.Ticks + $MostRecentRecord | Should -BeGreaterThan $OldestRecord # EndTime - Test that results are not newer than EndTime parameter value - $MostRecentRecord.Ticks | Should -BeLessOrEqual $EndTime.Ticks + $MostRecentRecord | Should -BeLessOrEqual $ParamHash.EndTime # StartTime - Test that results are not older than StartTime parameter value - $OldestRecord.Ticks | Should -BeGreaterOrEqual $StartTime.Ticks + $OldestRecord | Should -BeGreaterOrEqual $ParamHash.StartTime # SearchTermAnd - Test that results matches parameter value ($eventTest.event_type | Select-Object -Unique) | Should -Be $ParamHash.SearchTermAnd.event_type } From da22dcec8be7c9550f7d1df3f9a19051fc5bacae Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Mon, 20 Jul 2020 08:10:20 -0600 Subject: [PATCH 25/29] 1.17.5 version and release date --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- PowerShell/ModuleBanner.md | 8 +++++--- PowerShell/ModuleChangelog.md | 24 +--------------------- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index ca65125d8..80ee16e29 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '1.17.4' +ModuleVersion = '1.17.5' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index c81681e79..9e8656789 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,17 +1,19 @@ #### Latest Version ``` -1.17.4 +1.17.5 ``` #### Banner Current ``` -{{Fill in the Banner Current}} +Use Get-JCSystemInsight to query additional System Insights tables. +!!IF YOU RECEIVE AN ERROR WHILE UPDATING THE MODULE PLEASE RUN: Install-Module JumpCloud -force ``` #### Banner Old ``` -{{Fill in the Banner Old}} +Use Get-JCSystemInsight to query additional System Insights tables. +!!IF YOU RECEIVE AN ERROR WHILE UPDATING THE MODULE PLEASE RUN: Install-Module JumpCloud -force ``` diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 0e8ceed9c..7ad3b06f8 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,28 +1,6 @@ -## 1.17.4 - -Release Date: July 17, 2020 - -#### RELEASE NOTES - -``` -{{Fill in the Release Notes}} -``` - -#### FEATURES: - -{{Fill in the Features}} - -#### IMPROVEMENTS: - -{{Fill in the Improvements}} - -#### BUG FIXES: - -{{Fill in the Bug Fixes}} - ## 1.17.5 -Release Date: July 13, 2020 +Release Date: July 20, 2020 #### RELEASE NOTES From 36eea47e9f089872021f4b05c386512a5e9a19cc Mon Sep 17 00:00:00 2001 From: AzurePipelines Date: Mon, 20 Jul 2020 14:14:24 +0000 Subject: [PATCH 26/29] Push to refs/heads/JumpCloudModule_1.17.5;[skip ci] --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 4 ++-- PowerShell/ModuleBanner.md | 8 +++----- PowerShell/ModuleChangelog.md | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 80ee16e29..d90bd9011 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 7/17/2020 +# Generated on: 7/20/2020 # @{ @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '1.17.5' +ModuleVersion = '1.17.4' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index 9e8656789..c81681e79 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,19 +1,17 @@ #### Latest Version ``` -1.17.5 +1.17.4 ``` #### Banner Current ``` -Use Get-JCSystemInsight to query additional System Insights tables. -!!IF YOU RECEIVE AN ERROR WHILE UPDATING THE MODULE PLEASE RUN: Install-Module JumpCloud -force +{{Fill in the Banner Current}} ``` #### Banner Old ``` -Use Get-JCSystemInsight to query additional System Insights tables. -!!IF YOU RECEIVE AN ERROR WHILE UPDATING THE MODULE PLEASE RUN: Install-Module JumpCloud -force +{{Fill in the Banner Old}} ``` diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 7ad3b06f8..7f587aba3 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,25 @@ +## 1.17.4 + +Release Date: July 20, 2020 + +#### RELEASE NOTES + +``` +{{Fill in the Release Notes}} +``` + +#### FEATURES: + +{{Fill in the Features}} + +#### IMPROVEMENTS: + +{{Fill in the Improvements}} + +#### BUG FIXES: + +{{Fill in the Bug Fixes}} + ## 1.17.5 Release Date: July 20, 2020 From 969bbd9fd011363322c14390696eb2516f4aba4e Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Mon, 20 Jul 2020 09:59:48 -0600 Subject: [PATCH 27/29] 1.17.5 version and release date [skip ci] --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- PowerShell/ModuleBanner.md | 8 +++++--- PowerShell/ModuleChangelog.md | 22 ---------------------- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index d90bd9011..c9c48c1c0 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '1.17.4' +ModuleVersion = '1.17.5' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index c81681e79..9e8656789 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,17 +1,19 @@ #### Latest Version ``` -1.17.4 +1.17.5 ``` #### Banner Current ``` -{{Fill in the Banner Current}} +Use Get-JCSystemInsight to query additional System Insights tables. +!!IF YOU RECEIVE AN ERROR WHILE UPDATING THE MODULE PLEASE RUN: Install-Module JumpCloud -force ``` #### Banner Old ``` -{{Fill in the Banner Old}} +Use Get-JCSystemInsight to query additional System Insights tables. +!!IF YOU RECEIVE AN ERROR WHILE UPDATING THE MODULE PLEASE RUN: Install-Module JumpCloud -force ``` diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 7f587aba3..7ad3b06f8 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,25 +1,3 @@ -## 1.17.4 - -Release Date: July 20, 2020 - -#### RELEASE NOTES - -``` -{{Fill in the Release Notes}} -``` - -#### FEATURES: - -{{Fill in the Features}} - -#### IMPROVEMENTS: - -{{Fill in the Improvements}} - -#### BUG FIXES: - -{{Fill in the Bug Fixes}} - ## 1.17.5 Release Date: July 20, 2020 From e195103fc95c15acc62ff64884569bad940ff0ed Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Mon, 20 Jul 2020 11:09:14 -0600 Subject: [PATCH 28/29] Manual versioning in pipelines --- .../Deploy/Functions/Get-PSGalleryModuleVersion.ps1 | 9 +++++++-- PowerShell/JumpCloud Module/JumpCloud.psd1 | 7 +++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/PowerShell/Deploy/Functions/Get-PSGalleryModuleVersion.ps1 b/PowerShell/Deploy/Functions/Get-PSGalleryModuleVersion.ps1 index 079ee10c8..5b4e302dc 100755 --- a/PowerShell/Deploy/Functions/Get-PSGalleryModuleVersion.ps1 +++ b/PowerShell/Deploy/Functions/Get-PSGalleryModuleVersion.ps1 @@ -2,7 +2,7 @@ Function Get-PSGalleryModuleVersion { Param ( [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)][ValidateNotNullOrEmpty()][string]$Name, - [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 1)][ValidateNotNullOrEmpty()][ValidateSet('Major', 'Minor', 'Patch')][string]$RELEASETYPE + [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 1)][ValidateNotNullOrEmpty()][ValidateSet('Major', 'Minor', 'Patch', 'Manual')][string]$RELEASETYPE ) # Check to see if module already exists to set version number $PowerShellGalleryModule = Find-Module -Name:($Name) -ErrorAction:('Ignore') @@ -48,7 +48,12 @@ Function Get-PSGalleryModuleVersion } } - $NextVersion = ($ModuleVersion.Major, $ModuleVersion.Minor, $ModuleVersion.Patch) -join '.' + if ($RELEASETYPE -eq 'Manual'){ + $NextVersion = ($Psd1).ModuleVersion + } + else { + $NextVersion = ($ModuleVersion.Major, $ModuleVersion.Minor, $ModuleVersion.Patch) -join '.' + } Add-Member -InputObject:($ModuleVersion) -MemberType:('NoteProperty') -Name:('NextVersion') -Value:($NextVersion) Return $ModuleVersion } \ No newline at end of file diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index c9c48c1c0..4ca2fac3a 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -94,8 +94,7 @@ FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget', 'Send-JCPasswordReset', 'Set-JCCommand', 'Set-JCOrganization', 'Set-JCRadiusReplyAttribute', 'Set-JCRadiusServer', 'Set-JCSystem', 'Set-JCSystemUser', 'Set-JCUser', 'Set-JCUserGroupLDAP', - 'Update-JCModule', 'Update-JCUsersFromCSV', 'Get-JCEvent', - 'Get-JCEventCount' + 'Update-JCModule', 'Update-JCUsersFromCSV' # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. CmdletsToExport = @() @@ -121,7 +120,7 @@ PrivateData = @{ PSData = @{ # Tags applied to this module. These help with module discovery in online galleries. - Tags = 'JumpCloud','DaaS','Jump','Cloud','Directory' + Tags = 'JumpCloud', 'DaaS', 'Jump', 'Cloud', 'Directory' # A URL to the license for this module. LicenseUri = 'https://github.com/TheJumpCloud/support/blob/master/PowerShell/LICENSE' @@ -146,7 +145,7 @@ PrivateData = @{ } # End of PSData hashtable - } # End of PrivateData hashtable +} # End of PrivateData hashtable # HelpInfo URI of this module HelpInfoURI = 'https://github.com/TheJumpCloud/support/wiki' From a06da22aed83ab1c229ca0d43f23fbed9b16a433 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Mon, 20 Jul 2020 12:25:37 -0600 Subject: [PATCH 29/29] updated bug fixes --- PowerShell/ModuleChangelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 7ad3b06f8..dc6973231 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -17,6 +17,7 @@ Remove Depreciated SystemInsights Registry Table. #### BUG FIXES Fix for windows PowerShell Update-JCModule function. +Fix for pipeline to specify manual version of module ## 1.17.3