From 9b48e5a02ce80375622fd855d02ed73036cb6ea1 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 12 Jan 2023 08:21:51 -0800 Subject: [PATCH 001/102] Init commit Get-JCSystemApp --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 210 +++++++++--------- .../Public/Systems/Get-JCSystemApp.ps1 | 133 +++++++++++ 2 files changed, 238 insertions(+), 105 deletions(-) create mode 100644 PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 862935eb5..1332ab534 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -8,151 +8,151 @@ @{ -# 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 = '2.1.3' + # Version number of this module. + ModuleVersion = '2.1.3' -# 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', 'Backup-JCOrganization', - 'Connect-JCOnline', 'Copy-JCAssociation', 'Get-JCAssociation', - 'Get-JCBackup', 'Get-JCCommand', 'Get-JCCommandResult', - 'Get-JCCommandTarget', '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', '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-JCSettingsFile', 'Set-JCSystem', 'Set-JCSystemUser', 'Set-JCUser', - 'Set-JCUserGroupLDAP', 'Update-JCModule', 'Update-JCUsersFromCSV', - 'Get-JCEvent', 'Get-JCEventCount' + # 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', 'Backup-JCOrganization', + 'Connect-JCOnline', 'Copy-JCAssociation', 'Get-JCAssociation', + 'Get-JCBackup', 'Get-JCCommand', 'Get-JCCommandResult', + 'Get-JCCommandTarget', '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', '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-JCSettingsFile', 'Set-JCSystem', 'Set-JCSystemUser', 'Set-JCUser', + 'Set-JCUserGroupLDAP', 'Update-JCModule', 'Update-JCUsersFromCSV', + 'Get-JCEvent', 'Get-JCEventCount', 'Get-JCSystemApp' -# 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 = '' } diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 new file mode 100644 index 000000000..924587a4a --- /dev/null +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -0,0 +1,133 @@ +function Get-JCSystemApp () { + [CmdletBinding()] + param ( + + [Parameter(Mandatory = $false, HelpMessage = 'The System Id of the system you want to search for applications')] + [string]$SystemID, + [Parameter( ValueFromPipelineByPropertyName, HelpMessage = 'The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, Mac, Linux))')] + [ValidateSet('Windows', 'MacOs', 'Linux')] + [string]$SystemOS, + [Parameter(Mandatory = $false, HelpMessage = 'The name of the application you want to search for ex. (JumpCloud-Agent, Slack)')] + [string]$SoftwareName, + [Parameter(Mandatory = $false, HelpMessage = 'The version of the application you want to search for ex. (1.1.2)')] + [string]$SoftwareVersion + ) + + begin { + Write-Verbose 'Verifying JCAPI Key' + if ($JCAPIKEY.length -ne 40) { + Connect-JCOnline + } + + $Parallel = $JCConfig.parallel.Calculated + + if ($Parallel) { + Write-Verbose 'Initilizing resultsArray' + $resultsArrayList = [System.Collections.Concurrent.ConcurrentBag[object]]::new() + } else { + Write-Verbose 'Initilizing resultsArray' + $resultsArrayList = New-Object -TypeName System.Collections.ArrayList + } + Write-Verbose "Parameter Set: $($PSCmdlet.ParameterSetName)" + } + + process { + [int]$limit = '1000' + Write-Verbose "Setting limit to $limit" + + [int]$skip = '0' + Write-Verbose "Setting skip to $skip" + # If Parameter is SystemID then return all apps for that system + if ($SystemId) { + $OSType = Get-JCSystem -ID $SystemID | Select-Object -ExpandProperty osFamily + $OSType + # Regex if $OSType contains Mac + + } elseif ($SystemOS) { + if ($OsType -eq 'MacOs') { + $Ostype = 'Darwin' + } + $OSType = $SystemOS + } else { + Write-Error 'No SystemID or SystemOS passed' + return + } + + #TODO: Loop through each endpoint if $SoftwareName is being search across all OS types + + + + + # Switch on OS type and return appropriate apps + switch ($OSType) { + 'Windows' { + # If Software title and system ID are passed then return specific app + if ($SoftwareVersion -and $SoftwareName ) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" + + } elseif ($SoftwareName -and $SystemID) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" + } elseif ($SoftwareName) { + # Add filter for system ID to $Search + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName" + } elseif ($SystemID) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID" + } + Write-Debug $URL + } + 'Darwin' { + # If Software title and system ID are passed then return specific app + if ($SoftwareVersion -and $SoftwareName) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName&filter=bundle_version:eq:$SoftwareVersion" + + } elseif ($SoftwareName -and $SystemID) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemID&filter=bundle_name:eq:$SoftwareName" + } elseif ($SoftwareName) { + # Add filter for system ID to $Search + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName" + } elseif ($SystemID) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemID" + } + Write-Debug $URL + } + 'Linux' { + # If Software title and system ID are passed then return specific app + if ($SoftwareVersion -and $SoftwareName) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" + + } elseif ($SoftwareName -and $SystemID) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" + } elseif ($SoftwareName) { + # Add filter for system ID to $Search + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName" + } elseif ($SystemID) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID" + } + Write-Debug $URL + } + } + + if ($Parallel) { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit + } + } + end { + return $resultsArray + } +} # End Function + From cfc6384a6f28b9bf708cc3c2ea0cf91d70db7ca1 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 12 Jan 2023 09:31:27 -0800 Subject: [PATCH 002/102] cleanup --- .../Public/Systems/Get-JCSystemApp.ps1 | 182 ++++++++++-------- 1 file changed, 101 insertions(+), 81 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 924587a4a..9e65d6d1a 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -28,7 +28,6 @@ function Get-JCSystemApp () { Write-Verbose 'Initilizing resultsArray' $resultsArrayList = New-Object -TypeName System.Collections.ArrayList } - Write-Verbose "Parameter Set: $($PSCmdlet.ParameterSetName)" } process { @@ -38,96 +37,117 @@ function Get-JCSystemApp () { [int]$skip = '0' Write-Verbose "Setting skip to $skip" # If Parameter is SystemID then return all apps for that system - if ($SystemId) { - $OSType = Get-JCSystem -ID $SystemID | Select-Object -ExpandProperty osFamily - $OSType - # Regex if $OSType contains Mac - - } elseif ($SystemOS) { - if ($OsType -eq 'MacOs') { - $Ostype = 'Darwin' + if ($SystemId -or $SystemOs) { + if ($SystemId) { + $OSType = Get-JCSystem -ID $SystemID | Select-Object -ExpandProperty osFamily + } elseif ($SystemOs) { + $OSType = $SystemOs } - $OSType = $SystemOS - } else { - Write-Error 'No SystemID or SystemOS passed' - return - } - - #TODO: Loop through each endpoint if $SoftwareName is being search across all OS types - - - - - # Switch on OS type and return appropriate apps - switch ($OSType) { - 'Windows' { - # If Software title and system ID are passed then return specific app - if ($SoftwareVersion -and $SoftwareName ) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" - - } elseif ($SoftwareName -and $SystemID) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" - } elseif ($SoftwareName) { - # Add filter for system ID to $Search - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName" - } elseif ($SystemID) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID" + if ($OsType -eq 'MacOs') { $Ostype = 'Darwin' } # OS Family for Mac is Darwin + + Write-Debug "OS: $OSType" + switch ($OSType) { + 'Windows' { + # If Software title and system ID are passed then return specific app + if ($SoftwareVersion -and $SoftwareName ) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" + + } elseif ($SoftwareName -and $SystemID) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" + } elseif ($SoftwareName) { + # Add filter for system ID to $Search + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName" + } elseif ($SystemID) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID" + } + Write-Debug $URL } - Write-Debug $URL - } - 'Darwin' { - # If Software title and system ID are passed then return specific app - if ($SoftwareVersion -and $SoftwareName) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName&filter=bundle_version:eq:$SoftwareVersion" - - } elseif ($SoftwareName -and $SystemID) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemID&filter=bundle_name:eq:$SoftwareName" - } elseif ($SoftwareName) { - # Add filter for system ID to $Search - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName" - } elseif ($SystemID) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemID" + 'Darwin' { + # If Software title and system ID are passed then return specific app + if ($SoftwareVersion -and $SoftwareName) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName&filter=bundle_version:eq:$SoftwareVersion" + + } elseif ($SoftwareName -and $SystemID) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemID&filter=bundle_name:eq:$SoftwareName" + } elseif ($SoftwareName) { + # Add filter for system ID to $Search + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName" + } elseif ($SystemID) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemID" + } + Write-Debug $URL + } + 'Linux' { + # If Software title and system ID are passed then return specific app + if ($SoftwareVersion -and $SoftwareName) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" + + } elseif ($SoftwareName -and $SystemID) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" + } elseif ($SoftwareName) { + # Add filter for system ID to $Search + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName" + } elseif ($SystemID) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID" + } + Write-Debug $URL } - Write-Debug $URL + + } + if ($Parallel) { + $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit } - 'Linux' { - # If Software title and system ID are passed then return specific app - if ($SoftwareVersion -and $SoftwareName) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" - } elseif ($SoftwareName -and $SystemID) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" - } elseif ($SoftwareName) { - # Add filter for system ID to $Search - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName" - } elseif ($SystemID) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID" + } elseif ($SoftwareName) { + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + # Foreach Mac, Windows, Linux + foreach ($os in @('MacOs', 'Windows', 'Linux')) { + if ($os -eq 'MacOs') { + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName" + if ($Parallel) { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit + } + $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + $resultsArrayList.Add($resultsArray) + } elseif ($os -eq 'Windows') { + if ($Parallel) { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit + } + $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + $resultsArrayList.Add($resultsArray) + } elseif ($os -eq 'Linux') { + if ($Parallel) { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit + } + $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + $resultsArrayList.Add($resultsArray) } - Write-Debug $URL } } - - if ($Parallel) { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit - } } end { - return $resultsArray + return $resultsArrayList } } # End Function From abb673928bf606bc28ea05eb3355d02599031196 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 12 Jan 2023 09:35:33 -0800 Subject: [PATCH 003/102] softwarename --- PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 9e65d6d1a..b1b8f171d 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -127,6 +127,7 @@ function Get-JCSystemApp () { $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os $resultsArrayList.Add($resultsArray) } elseif ($os -eq 'Windows') { + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName" if ($Parallel) { $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true } else { @@ -135,6 +136,7 @@ function Get-JCSystemApp () { $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os $resultsArrayList.Add($resultsArray) } elseif ($os -eq 'Linux') { + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName" if ($Parallel) { $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true } else { From 63e8258a2e2dc85176150b15d9d8b052c99b97c1 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Fri, 13 Jan 2023 11:15:28 -0700 Subject: [PATCH 004/102] first pass at Get-JCsystemApp tests --- .../Public/Systems/Get-JCSystemApp.tests.ps1 | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 new file mode 100644 index 000000000..8668c5281 --- /dev/null +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -0,0 +1,41 @@ +Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { + + BeforeAll { + $systems = Get-JCsystem + $mac = $systems | Where-Object { $_.osFamily -match "darwin" } | Select-Object -First 1 + $windows = $systems | Where-Object { $_.osFamily -match "windows" } | Select-Object -First 1 + $linux = $systems | Where-Object { $_.osFamily -match "linux" } | Select-Object -First 1 + } + + It "Tests that Get-JCSystemApp returns packages/apps/programs for all systems in the org" { + # Should return linuxPackages for all systems in the org + { Get-JCSystemApp -SystemOS linux } | Should -Not -Throw + # Should return mac apps for all systems in the org + { Get-JCSystemApp -SystemOS macOS } | Should -Not -Throw + # Should return windows programs for all systems in the org + { Get-JCSystemApp -SystemOS windows } | Should -Not -Throw + } + It "Tests that given a systemID, each type of app can be returned" { + { Get-JCSystemApp -SystemID $mac._id } | Should -Not -Throw + { Get-JCSystemApp -SystemID $windows._id } | Should -Not -Throw + { Get-JCSystemApp -SystemID $linux._id } | Should -Not -Throw + } + + It "Tests that given a systemID, SoftwareName, an app is returned" { + # Chess is always installed on MacOS and it CAN NOT be removed no matter what + Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" + # TODO: Windows/ Linux Examples + } + It "Tests that given a systemID, SoftwareName, SoftwareVersion, an app is returned" { + # Chess is always installed on MacOS and it CAN NOT be removed no matter what + $ChessApp = Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" + Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion $ChessApp.Bundle_short_version + # A null value version shouldn't be accepted + { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion "" } | Should -Throw + # A null value Name shouldn't be accepted + { Get-JCSystemApp -SystemID $mac._id -SoftwareName "" } | Should -Throw + # Using a version that doesn't exist should return nothing + Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion "48.49.50.51" | Should -Be $null + # TODO: Windows/ Linux Examples + } +} From a9047abb8401fac58345f8b00b5fbd4f18269650 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Fri, 13 Jan 2023 13:15:26 -0800 Subject: [PATCH 005/102] Added search by OS --- .../JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index b1b8f171d..d2290df93 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -64,6 +64,8 @@ function Get-JCSystemApp () { $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName" } elseif ($SystemID) { $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID" + } else { + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs" } Write-Debug $URL } @@ -83,6 +85,8 @@ function Get-JCSystemApp () { $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName" } elseif ($SystemID) { $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemID" + } else { + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps" } Write-Debug $URL } @@ -102,6 +106,8 @@ function Get-JCSystemApp () { $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName" } elseif ($SystemID) { $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID" + } else { + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages" } Write-Debug $URL } From 252a5f4177fdc3e9025dc8875438672bf361a2c8 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Tue, 17 Jan 2023 14:12:54 -0800 Subject: [PATCH 006/102] Added $search parameter --- .../Public/Systems/Get-JCSystemApp.ps1 | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index d2290df93..a1fd77a45 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -10,7 +10,9 @@ function Get-JCSystemApp () { [Parameter(Mandatory = $false, HelpMessage = 'The name of the application you want to search for ex. (JumpCloud-Agent, Slack)')] [string]$SoftwareName, [Parameter(Mandatory = $false, HelpMessage = 'The version of the application you want to search for ex. (1.1.2)')] - [string]$SoftwareVersion + [string]$SoftwareVersion, + [Parameter(Mandatory = $false, HelpMessage = 'Global search ex. (1.1.2)')] + [string]$Search ) begin { @@ -24,18 +26,36 @@ function Get-JCSystemApp () { if ($Parallel) { Write-Verbose 'Initilizing resultsArray' $resultsArrayList = [System.Collections.Concurrent.ConcurrentBag[object]]::new() + $searchAppResultsList = [System.Collections.Concurrent.ConcurrentBag[object]]::new() } else { Write-Verbose 'Initilizing resultsArray' $resultsArrayList = New-Object -TypeName System.Collections.ArrayList + $searchAppResultsList = New-Object -TypeName System.Collections.ArrayList } } - + #TODO: Create a PR to add docs process { [int]$limit = '1000' Write-Verbose "Setting limit to $limit" [int]$skip = '0' Write-Verbose "Setting skip to $skip" + # Create a global search for all endpoints(Windows, Mac, Linux) and regex software name + if ($Search) { + # Get all the results + foreach ($x in @('programs', 'apps', 'linux_packages')) { + Write-Debug $x + $URL = "$JCUrlBasePath/api/v2/systeminsights/$($x)" + $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit + $searchAppResultsList.Add($searchAppResults) + } + # Search for software name in the $searchAppResultsList + $searchAppResultsList | ForEach-Object { + $_ | Where-Object { $_.name -match $Search } | ForEach-Object { + $resultsArrayList.Add($_) + } + } + } # If Parameter is SystemID then return all apps for that system if ($SystemId -or $SystemOs) { if ($SystemId) { From 1a42c148fc4aabdcef1ee59ad06508af2442f874 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 18 Jan 2023 08:40:45 -0800 Subject: [PATCH 007/102] version --- .circleci/workflows.yml | 4 +++- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index c4aa026c1..c5b4430cc 100755 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -32,7 +32,7 @@ parameters: description: "Release Type. Accepted values [ Major, Minor, Patch ]" type: enum enum: ["Major", "Minor", "Patch"] - default: "Patch" + default: "Minor" RequiredModulesRepo: description: "PowerShell Repository for JumpCloud SDKs" type: enum @@ -607,3 +607,5 @@ commands: root: . paths: - . + +# VS Code Extension Version: 1.5.1 \ No newline at end of file diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 1332ab534..22e1bef71 100644 --- 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 = '2.1.3' + ModuleVersion = '2.2.0' # Supported PSEditions # CompatiblePSEditions = @() From fd87030c6a1372f3c3321564473d7299e8289782 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Wed, 18 Jan 2023 12:56:44 -0700 Subject: [PATCH 008/102] ssh key change r/w --- .circleci/workflows.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index c5b4430cc..8667be7d7 100755 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -310,7 +310,7 @@ commands: steps: - add_ssh_keys: fingerprints: - - "89:e7:20:1b:b1:a2:c2:2e:b8:d6:34:2f:73:80:a6:70" + - "47:a7:42:75:1a:a5:0b:d5:5a:79:68:c4:99:8d:81:70" - checkout - run: name: Set URLs @@ -413,7 +413,7 @@ commands: - checkout - add_ssh_keys: fingerprints: - - "89:e7:20:1b:b1:a2:c2:2e:b8:d6:34:2f:73:80:a6:70" + - "47:a7:42:75:1a:a5:0b:d5:5a:79:68:c4:99:8d:81:70" - attach_workspace: at: . - run: @@ -427,7 +427,7 @@ commands: - checkout - add_ssh_keys: fingerprints: - - "89:e7:20:1b:b1:a2:c2:2e:b8:d6:34:2f:73:80:a6:70" + - "47:a7:42:75:1a:a5:0b:d5:5a:79:68:c4:99:8d:81:70" - attach_workspace: at: . - run: @@ -607,5 +607,4 @@ commands: root: . paths: - . - -# VS Code Extension Version: 1.5.1 \ No newline at end of file +# VS Code Extension Version: 1.5.1 From 2a7d3e900ebd71ac150b06f6f74b4f3772c1332a Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Wed, 18 Jan 2023 13:03:48 -0700 Subject: [PATCH 009/102] support ssh key --- .circleci/workflows.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 8667be7d7..1121c3a4b 100755 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -310,7 +310,7 @@ commands: steps: - add_ssh_keys: fingerprints: - - "47:a7:42:75:1a:a5:0b:d5:5a:79:68:c4:99:8d:81:70" + - "48:4f:95:b2:cb:77:d1:d2:d4:e5:2d:32:3a:91:17:5a" - checkout - run: name: Set URLs @@ -413,7 +413,7 @@ commands: - checkout - add_ssh_keys: fingerprints: - - "47:a7:42:75:1a:a5:0b:d5:5a:79:68:c4:99:8d:81:70" + - "48:4f:95:b2:cb:77:d1:d2:d4:e5:2d:32:3a:91:17:5a" - attach_workspace: at: . - run: @@ -427,7 +427,7 @@ commands: - checkout - add_ssh_keys: fingerprints: - - "47:a7:42:75:1a:a5:0b:d5:5a:79:68:c4:99:8d:81:70" + - "48:4f:95:b2:cb:77:d1:d2:d4:e5:2d:32:3a:91:17:5a" - attach_workspace: at: . - run: From 7f3cf2e0baa565ddd82be52af24eab9a32a012a5 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Wed, 18 Jan 2023 13:30:54 -0700 Subject: [PATCH 010/102] ssh key --- .circleci/workflows.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 1121c3a4b..509e63d3e 100755 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -310,7 +310,7 @@ commands: steps: - add_ssh_keys: fingerprints: - - "48:4f:95:b2:cb:77:d1:d2:d4:e5:2d:32:3a:91:17:5a" + - "89:e7:20:1b:b1:a2:c2:2e:b8:d6:34:2f:73:80:a6:70" - checkout - run: name: Set URLs @@ -413,7 +413,7 @@ commands: - checkout - add_ssh_keys: fingerprints: - - "48:4f:95:b2:cb:77:d1:d2:d4:e5:2d:32:3a:91:17:5a" + - "89:e7:20:1b:b1:a2:c2:2e:b8:d6:34:2f:73:80:a6:70" - attach_workspace: at: . - run: @@ -427,7 +427,7 @@ commands: - checkout - add_ssh_keys: fingerprints: - - "48:4f:95:b2:cb:77:d1:d2:d4:e5:2d:32:3a:91:17:5a" + - "89:e7:20:1b:b1:a2:c2:2e:b8:d6:34:2f:73:80:a6:70" - attach_workspace: at: . - run: From 0893c80167c4bda82855bd4ce11f7fb24bf623e9 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Wed, 18 Jan 2023 13:52:43 -0700 Subject: [PATCH 011/102] ssh key --- .circleci/workflows.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 509e63d3e..7127e5bd3 100755 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -310,7 +310,7 @@ commands: steps: - add_ssh_keys: fingerprints: - - "89:e7:20:1b:b1:a2:c2:2e:b8:d6:34:2f:73:80:a6:70" + - "d0:d7:40:1c:62:64:d4:68:e2:12:c5:b9:78:40:66:6b" - checkout - run: name: Set URLs @@ -413,7 +413,7 @@ commands: - checkout - add_ssh_keys: fingerprints: - - "89:e7:20:1b:b1:a2:c2:2e:b8:d6:34:2f:73:80:a6:70" + - "d0:d7:40:1c:62:64:d4:68:e2:12:c5:b9:78:40:66:6b" - attach_workspace: at: . - run: @@ -427,7 +427,7 @@ commands: - checkout - add_ssh_keys: fingerprints: - - "89:e7:20:1b:b1:a2:c2:2e:b8:d6:34:2f:73:80:a6:70" + - "d0:d7:40:1c:62:64:d4:68:e2:12:c5:b9:78:40:66:6b" - attach_workspace: at: . - run: From 6cbbb2e6922bf16dae437d7ee36ccf9bc5aa8ef5 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Wed, 18 Jan 2023 15:40:58 -0700 Subject: [PATCH 012/102] ssh key --- .circleci/workflows.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 7127e5bd3..95c90779d 100755 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -310,7 +310,7 @@ commands: steps: - add_ssh_keys: fingerprints: - - "d0:d7:40:1c:62:64:d4:68:e2:12:c5:b9:78:40:66:6b" + - "c9:0f:56:c9:00:42:98:3c:03:59:24:1e:a7:e7:08:7f" - checkout - run: name: Set URLs @@ -413,7 +413,7 @@ commands: - checkout - add_ssh_keys: fingerprints: - - "d0:d7:40:1c:62:64:d4:68:e2:12:c5:b9:78:40:66:6b" + - "c9:0f:56:c9:00:42:98:3c:03:59:24:1e:a7:e7:08:7f" - attach_workspace: at: . - run: @@ -427,7 +427,7 @@ commands: - checkout - add_ssh_keys: fingerprints: - - "d0:d7:40:1c:62:64:d4:68:e2:12:c5:b9:78:40:66:6b" + - "c9:0f:56:c9:00:42:98:3c:03:59:24:1e:a7:e7:08:7f" - attach_workspace: at: . - run: From 5c61716e87ec62e15d3db118509b3721dd6c9090 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Wed, 18 Jan 2023 22:49:44 +0000 Subject: [PATCH 013/102] Updating PowerShell Module;[skip ci] --- .../JumpCloud Module/Docs/Get-JCSystemApp.md | 126 +++++++++++ PowerShell/JumpCloud Module/Docs/JumpCloud.md | 5 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 212 +++++++++--------- .../JumpCloud Module/en-Us/JumpCloud-help.xml | 185 +++++++++++++++ PowerShell/ModuleChangelog.md | 22 ++ 5 files changed, 443 insertions(+), 107 deletions(-) create mode 100644 PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md new file mode 100644 index 000000000..49457c786 --- /dev/null +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -0,0 +1,126 @@ +--- +external help file: JumpCloud-help.xml +Module Name: JumpCloud +online version: https://github.com/TheJumpCloud/support/wiki/ +schema: 2.0.0 +--- + +# Get-JCSystemApp + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Get-JCSystemApp [[-SystemID] ] [[-SystemOS] ] [[-SoftwareName] ] + [[-SoftwareVersion] ] [[-Search] ] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Search +Global search ex. +(1.1.2) + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 4 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SoftwareName +The name of the application you want to search for ex. +(JumpCloud-Agent, Slack) + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SoftwareVersion +The version of the application you want to search for ex. +(1.1.2) + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 3 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SystemID +The System Id of the system you want to search for applications + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 0 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SystemOS +The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. +(Windows, Mac, Linux)) + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: +Accepted values: Windows, MacOs, Linux + +Required: False +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +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 + +### System.String + +## OUTPUTS + +### System.Object +## NOTES + +## RELATED LINKS diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md index f0c80c1e5..bf2d2b4a4 100644 --- a/PowerShell/JumpCloud Module/Docs/JumpCloud.md +++ b/PowerShell/JumpCloud Module/Docs/JumpCloud.md @@ -2,7 +2,7 @@ Module Name: JumpCloud Module Guid: 31c023d1-a901-48c4-90a3-082f91b31646 Download Help Link: https://github.com/TheJumpCloud/support/wiki -Help Version: 2.1.3 +Help Version: 2.2.0 Locale: en-US --- @@ -86,6 +86,9 @@ Return JumpCloud radius server information. ### [Get-JCSystem](Get-JCSystem.md) Returns all JumpCloud Systems within a JumpCloud tenant or a single JumpCloud System using the -ByID Parameter. +### [Get-JCSystemApp](Get-JCSystemApp.md) +{{ Fill in the Synopsis }} + ### [Get-JCSystemGroupMember](Get-JCSystemGroupMember.md) Returns the System Group members of a JumpCloud System Group. diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 22e1bef71..f4c7b31ab 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,156 +3,156 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 1/6/2023 +# Generated on: 1/18/2023 # @{ - # 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 = '2.2.0' +# Version number of this module. +ModuleVersion = '2.2.0' - # 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', 'Backup-JCOrganization', - 'Connect-JCOnline', 'Copy-JCAssociation', 'Get-JCAssociation', - 'Get-JCBackup', 'Get-JCCommand', 'Get-JCCommandResult', - 'Get-JCCommandTarget', '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', '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-JCSettingsFile', 'Set-JCSystem', 'Set-JCSystemUser', 'Set-JCUser', - 'Set-JCUserGroupLDAP', 'Update-JCModule', 'Update-JCUsersFromCSV', - 'Get-JCEvent', 'Get-JCEventCount', 'Get-JCSystemApp' +# 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', 'Backup-JCOrganization', + 'Connect-JCOnline', 'Copy-JCAssociation', 'Get-JCAssociation', + 'Get-JCBackup', 'Get-JCCommand', 'Get-JCCommandResult', + 'Get-JCCommandTarget', 'Get-JCEvent', 'Get-JCEventCount', 'Get-JCGroup', + 'Get-JCOrganization', 'Get-JCPolicy', 'Get-JCPolicyResult', + 'Get-JCPolicyTargetGroup', 'Get-JCPolicyTargetSystem', + 'Get-JCRadiusReplyAttribute', 'Get-JCRadiusServer', 'Get-JCSystem', + 'Get-JCSystemApp', '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-JCSettingsFile', 'Set-JCSystem', 'Set-JCSystemUser', 'Set-JCUser', + 'Set-JCUserGroupLDAP', '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 = @() +# 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 = '' } diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index 697fbd989..d64041f2a 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -7048,6 +7048,191 @@ PS C:\> $BackupJcOrganizationResults.User + + + Get-JCSystemApp + Get + JCSystemApp + + {{ Fill in the Synopsis }} + + + + {{ Fill in the Description }} + + + + Get-JCSystemApp + + SystemID + + The System Id of the system you want to search for applications + + System.String + + System.String + + + None + + + SystemOS + + The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, Mac, Linux)) + + + Windows + MacOs + Linux + + System.String + + System.String + + + None + + + SoftwareName + + The name of the application you want to search for ex. (JumpCloud-Agent, Slack) + + System.String + + System.String + + + None + + + SoftwareVersion + + The version of the application you want to search for ex. (1.1.2) + + System.String + + System.String + + + None + + + Search + + Global search ex. (1.1.2) + + System.String + + System.String + + + None + + + + + + Search + + Global search ex. (1.1.2) + + System.String + + System.String + + + None + + + SoftwareName + + The name of the application you want to search for ex. (JumpCloud-Agent, Slack) + + System.String + + System.String + + + None + + + SoftwareVersion + + The version of the application you want to search for ex. (1.1.2) + + System.String + + System.String + + + None + + + SystemID + + The System Id of the system you want to search for applications + + System.String + + System.String + + + None + + + SystemOS + + The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, Mac, Linux)) + + System.String + + System.String + + + None + + + + + + System.String + + + + + + + + + + System.Object + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> {{ Add example code here }} + + {{ Add example description here }} + + + + + + Online Version: + https://github.com/TheJumpCloud/support/wiki/ + + + Get-JCSystemGroupMember diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 10894ef9b..1f02a89e8 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,25 @@ +## 2.2.0 + +Release Date: January 18, 2023 + +#### RELEASE NOTES + +``` +{{Fill in the Release Notes}} +``` + +#### FEATURES: + +{{Fill in the Features}} + +#### IMPROVEMENTS: + +{{Fill in the Improvements}} + +#### BUG FIXES: + +{{Fill in the Bug Fixes}} + ## 2.1.3 Release Date: January 5, 2023 From 80b000a013336ae34de6ecc28939079248e2320c Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 19 Jan 2023 12:16:30 -0800 Subject: [PATCH 014/102] ModuleChangelog and docs --- .../JumpCloud Module/Docs/Get-JCSystemApp.md | 26 ++++++++++++++++--- .../Public/Systems/Get-JCSystemApp.ps1 | 4 +-- PowerShell/ModuleChangelog.md | 12 ++++++--- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index 49457c786..9969ee066 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -8,7 +8,7 @@ schema: 2.0.0 # Get-JCSystemApp ## SYNOPSIS -{{ Fill in the Synopsis }} +Returns the System Apps installed to a JumpCloud System(s) ## SYNTAX @@ -24,10 +24,28 @@ Get-JCSystemApp [[-SystemID] ] [[-SystemOS] ] [[-SoftwareName] < ### Example 1 ```powershell -PS C:\> {{ Add example code here }} +PS C:\> Get-JCSystemApp -SystemId 'SystemId' ``` -{{ Add example description here }} +Returns the applications installed in the system with the given -SystemId + +### Example 2 +```powershell +PS C:\> Get-JCSystemApp -SystemOs 'MacOs' +``` + +Returns the 'MacOs' systems and all the applications installed for each system + +### Example 3 +```powershell +PS C:\> Get-JCSystemApp -SystemOs 'MacOs' -SoftwareName 'JumpCloud-Agent' +``` +### Example 4 +```powershell +PS C:\> Get-JCSystemApp -SystemOs 'MacOs' -SoftwareName 'JumpCloud-Agent' -SoftwareVersion '1.12.5' +``` + +Returns the 'MacOs' systems that have a 'JumpCloud Agent' application with the version '1.12.5' ## PARAMETERS @@ -80,7 +98,7 @@ Accept wildcard characters: False ``` ### -SystemID -The System Id of the system you want to search for applications +The System Id of the JumpCloud system you want to search for applications ```yaml Type: System.String diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index a1fd77a45..db0d64595 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -4,14 +4,14 @@ function Get-JCSystemApp () { [Parameter(Mandatory = $false, HelpMessage = 'The System Id of the system you want to search for applications')] [string]$SystemID, - [Parameter( ValueFromPipelineByPropertyName, HelpMessage = 'The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, Mac, Linux))')] + [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName, HelpMessage = 'The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, Mac, Linux))')] [ValidateSet('Windows', 'MacOs', 'Linux')] [string]$SystemOS, [Parameter(Mandatory = $false, HelpMessage = 'The name of the application you want to search for ex. (JumpCloud-Agent, Slack)')] [string]$SoftwareName, [Parameter(Mandatory = $false, HelpMessage = 'The version of the application you want to search for ex. (1.1.2)')] [string]$SoftwareVersion, - [Parameter(Mandatory = $false, HelpMessage = 'Global search ex. (1.1.2)')] + [Parameter(Mandatory = $false, HelpMessage = 'Search for a specific application by name to all systems in the org')] [string]$Search ) diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 1f02a89e8..be4c527f0 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -5,20 +5,24 @@ Release Date: January 18, 2023 #### RELEASE NOTES ``` -{{Fill in the Release Notes}} +This release adds new function Get-JCSystemApp ``` #### FEATURES: -{{Fill in the Features}} +* Get-JCSystemApp command enables search by: + - applications installed in a system + - applications installed from all the systems in a specifc OS + - SoftwareName + - SoftwareName and SoftwareVersion #### IMPROVEMENTS: -{{Fill in the Improvements}} +N/A #### BUG FIXES: -{{Fill in the Bug Fixes}} +N/A ## 2.1.3 From 04e66dd27125299f9801169e3945c336fc6836c7 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Thu, 19 Jan 2023 20:25:25 +0000 Subject: [PATCH 015/102] Updating PowerShell Module;[skip ci] --- .../JumpCloud Module/Docs/Get-JCSystemApp.md | 1 + PowerShell/JumpCloud Module/Docs/JumpCloud.md | 2 +- .../Docs/Set-JCSettingsFile.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- .../JumpCloud Module/en-Us/JumpCloud-help.xml | 31 ++++++++++++++++--- 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index 9969ee066..86e62f9b7 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -40,6 +40,7 @@ Returns the 'MacOs' systems and all the applications installed for each system ```powershell PS C:\> Get-JCSystemApp -SystemOs 'MacOs' -SoftwareName 'JumpCloud-Agent' ``` + ### Example 4 ```powershell PS C:\> Get-JCSystemApp -SystemOs 'MacOs' -SoftwareName 'JumpCloud-Agent' -SoftwareVersion '1.12.5' diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md index bf2d2b4a4..985234f75 100644 --- a/PowerShell/JumpCloud Module/Docs/JumpCloud.md +++ b/PowerShell/JumpCloud Module/Docs/JumpCloud.md @@ -87,7 +87,7 @@ Return JumpCloud radius server information. Returns all JumpCloud Systems within a JumpCloud tenant or a single JumpCloud System using the -ByID Parameter. ### [Get-JCSystemApp](Get-JCSystemApp.md) -{{ Fill in the Synopsis }} +Returns the System Apps installed to a JumpCloud System(s) ### [Get-JCSystemGroupMember](Get-JCSystemGroupMember.md) Returns the System Group members of a JumpCloud System Group. diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index ba6b37a0c..f8bf10130 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] +Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index 372616672..f5f43cb35 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.1.3 + 2.2.0.7403-202301192023 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index f4c7b31ab..93f0383d6 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 1/18/2023 +# Generated on: 1/19/2023 # @{ diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index d64041f2a..1e391d738 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -7054,7 +7054,7 @@ PS C:\> $BackupJcOrganizationResults.User Get JCSystemApp - {{ Fill in the Synopsis }} + Returns the System Apps installed to a JumpCloud System(s) @@ -7066,7 +7066,7 @@ PS C:\> $BackupJcOrganizationResults.User SystemID - The System Id of the system you want to search for applications + The System Id of the JumpCloud system you want to search for applications System.String @@ -7170,7 +7170,7 @@ PS C:\> $BackupJcOrganizationResults.User SystemID - The System Id of the system you want to search for applications + The System Id of the JumpCloud system you want to search for applications System.String @@ -7220,9 +7220,30 @@ PS C:\> $BackupJcOrganizationResults.User -------------------------- Example 1 -------------------------- - PS C:\> {{ Add example code here }} + PS C:\> Get-JCSystemApp -SystemId 'SystemId' - {{ Add example description here }} + Returns the applications installed in the system with the given -SystemId + + + + -------------------------- Example 2 -------------------------- + PS C:\> Get-JCSystemApp -SystemOs 'MacOs' + + Returns the 'MacOs' systems and all the applications installed for each system + + + + -------------------------- Example 3 -------------------------- + PS C:\> Get-JCSystemApp -SystemOs 'MacOs' -SoftwareName 'JumpCloud-Agent' + + + + + + -------------------------- Example 4 -------------------------- + PS C:\> Get-JCSystemApp -SystemOs 'MacOs' -SoftwareName 'JumpCloud-Agent' -SoftwareVersion '1.12.5' + + Returns the 'MacOs' systems that have a 'JumpCloud Agent' application with the version '1.12.5' From 6aaf43c8c505d87cc64e9b8f2f35628708e9aa19 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Thu, 19 Jan 2023 20:33:35 +0000 Subject: [PATCH 016/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index f8bf10130..ba6b37a0c 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] +Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] ``` ## DESCRIPTION From c3c01dae128953be20d92b9c55a3900b04643c75 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Mon, 23 Jan 2023 11:23:15 -0800 Subject: [PATCH 017/102] search --- .../Public/Systems/Get-JCSystemApp.ps1 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index db0d64595..8cfa2167b 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -11,10 +11,9 @@ function Get-JCSystemApp () { [string]$SoftwareName, [Parameter(Mandatory = $false, HelpMessage = 'The version of the application you want to search for ex. (1.1.2)')] [string]$SoftwareVersion, - [Parameter(Mandatory = $false, HelpMessage = 'Search for a specific application by name to all systems in the org')] - [string]$Search + [Parameter(Mandatory = $false, HelpMessage = 'Search for a specific application by name from all systems in the org')] + [switch]$Search ) - begin { Write-Verbose 'Verifying JCAPI Key' if ($JCAPIKEY.length -ne 40) { @@ -49,12 +48,14 @@ function Get-JCSystemApp () { $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit $searchAppResultsList.Add($searchAppResults) } - # Search for software name in the $searchAppResultsList - $searchAppResultsList | ForEach-Object { - $_ | Where-Object { $_.name -match $Search } | ForEach-Object { - $resultsArrayList.Add($_) + # Check for the parameter given + if ($SoftwareName) { + $searchAppResultsList | ForEach-Object { + $results = $_ | Where-Object { $_.name -match $SoftwareName } + $resultsArrayList.Add($results) } } + } # If Parameter is SystemID then return all apps for that system if ($SystemId -or $SystemOs) { From 948fab27a8ecb7df20271b338ca71f7e6a992cbd Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 23 Jan 2023 19:32:47 +0000 Subject: [PATCH 018/102] Updating PowerShell Module;[skip ci] --- .../JumpCloud Module/Docs/Get-JCSystemApp.md | 6 +++--- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- .../JumpCloud Module/en-Us/JumpCloud-help.xml | 15 +++++++-------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index 86e62f9b7..1abf60833 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -14,7 +14,7 @@ Returns the System Apps installed to a JumpCloud System(s) ``` Get-JCSystemApp [[-SystemID] ] [[-SystemOS] ] [[-SoftwareName] ] - [[-SoftwareVersion] ] [[-Search] ] [] + [[-SoftwareVersion] ] [-Search] [] ``` ## DESCRIPTION @@ -55,12 +55,12 @@ Global search ex. (1.1.2) ```yaml -Type: System.String +Type: System.Management.Automation.SwitchParameter Parameter Sets: (All) Aliases: Required: False -Position: 4 +Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 93f0383d6..9789ba99d 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 1/19/2023 +# Generated on: 1/23/2023 # @{ diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index 1e391d738..91914038c 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -7116,32 +7116,31 @@ PS C:\> $BackupJcOrganizationResults.User None - + Search Global search ex. (1.1.2) - System.String - System.String + System.Management.Automation.SwitchParameter - None + False - + Search Global search ex. (1.1.2) - System.String + System.Management.Automation.SwitchParameter - System.String + System.Management.Automation.SwitchParameter - None + False SoftwareName From ede019b8d2317891b69910d1fa3081ad10b1fe31 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Mon, 23 Jan 2023 14:32:46 -0800 Subject: [PATCH 019/102] fixed search --- .../Public/Systems/Get-JCSystemApp.ps1 | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 8cfa2167b..f74d48b26 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -19,36 +19,43 @@ function Get-JCSystemApp () { if ($JCAPIKEY.length -ne 40) { Connect-JCOnline } - $Parallel = $JCConfig.parallel.Calculated - + $searchAppResultsList = New-Object -TypeName System.Collections.ArrayList if ($Parallel) { Write-Verbose 'Initilizing resultsArray' $resultsArrayList = [System.Collections.Concurrent.ConcurrentBag[object]]::new() - $searchAppResultsList = [System.Collections.Concurrent.ConcurrentBag[object]]::new() } else { Write-Verbose 'Initilizing resultsArray' $resultsArrayList = New-Object -TypeName System.Collections.ArrayList - $searchAppResultsList = New-Object -TypeName System.Collections.ArrayList } } - #TODO: Create a PR to add docs process { [int]$limit = '1000' Write-Verbose "Setting limit to $limit" [int]$skip = '0' Write-Verbose "Setting skip to $skip" - # Create a global search for all endpoints(Windows, Mac, Linux) and regex software name + $applicationArray = @('programs', 'apps', 'linux_packages') + # Search if ($Search) { # Get all the results - foreach ($x in @('programs', 'apps', 'linux_packages')) { - Write-Debug $x - $URL = "$JCUrlBasePath/api/v2/systeminsights/$($x)" - $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit - $searchAppResultsList.Add($searchAppResults) + $applicationArray | ForEach-Object { + $URL = "$JCUrlBasePath/api/v2/systeminsights/$($_)" + Write-Verbose "Searching for $SoftwareName in $_" + if ($Parallel) { + $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit + } + # Add OS Family to results + if ($_ -eq 'programs') { $os = 'Windows' } + elseif ($_ -eq 'apps') { $os = 'MacOs' } + elseif ($_ -eq 'linux_packages') { $os = 'Linux' } + $searchAppResults | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + [void]$searchAppResultsList.Add($searchAppResults) } - # Check for the parameter given + + # softwarename search if ($SoftwareName) { $searchAppResultsList | ForEach-Object { $results = $_ | Where-Object { $_.name -match $SoftwareName } @@ -56,9 +63,7 @@ function Get-JCSystemApp () { } } - } - # If Parameter is SystemID then return all apps for that system - if ($SystemId -or $SystemOs) { + } elseif ($SystemId -or $SystemOs) { if ($SystemId) { $OSType = Get-JCSystem -ID $SystemID | Select-Object -ExpandProperty osFamily } elseif ($SystemOs) { From 354309abe08069ae3253fd64a06e9bc184669b88 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 23 Jan 2023 22:41:15 +0000 Subject: [PATCH 020/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index ba6b37a0c..f8bf10130 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] +Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] ``` ## DESCRIPTION From 962821b2b04e38ef333dee261898ac99036f9288 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Mon, 23 Jan 2023 14:55:00 -0800 Subject: [PATCH 021/102] fix object error --- .../JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index f74d48b26..a6a623647 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -59,8 +59,11 @@ function Get-JCSystemApp () { if ($SoftwareName) { $searchAppResultsList | ForEach-Object { $results = $_ | Where-Object { $_.name -match $SoftwareName } - $resultsArrayList.Add($results) + $results | ForEach-Object { + $resultsArrayList.Add($_) + } } + } } elseif ($SystemId -or $SystemOs) { From 85056b2a1ebde8ca47f97b2f6d0f4b286e36785e Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 23 Jan 2023 23:01:56 +0000 Subject: [PATCH 022/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index f8bf10130..ba6b37a0c 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] +Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] ``` ## DESCRIPTION From 33c6671adde8a512a4485a7de5818e079b142cd5 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 23 Jan 2023 23:09:37 +0000 Subject: [PATCH 023/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index ba6b37a0c..f8bf10130 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] +Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index f5f43cb35..45ae97a33 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.2.0.7403-202301192023 + 2.2.0.7454-202301232306 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud From 0d666505c845aef6f41fec99c1a99d13b9b02105 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Tue, 24 Jan 2023 15:51:54 -0700 Subject: [PATCH 024/102] additional search + compatibility tests --- .../Public/Systems/Get-JCSystemApp.tests.ps1 | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index 8668c5281..6d63e79c6 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -38,4 +38,48 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion "48.49.50.51" | Should -Be $null # TODO: Windows/ Linux Examples } + + It "Tests the search functionatily of a software app" { + # results with no data should be null or empty + Get-JCSystemApp -SoftwareName "chess" | Should -BeNullOrEmpty + # when search is used to find an app the results should not be null or empty + Get-JCSystemApp -SoftwareName "chess" -Search | Should -Not -BeNullOrEmpty + } + + It "Tests the search param with systemID" { + + $apps = Get-JCSystemApp -Systemid $mac._id -SoftwareName "a" -search + $foundSystems = $apps.system_id | Select-Object -Unique + # if you specify a systemID and Search, results should not contain multiple systems + $foundSystems.count | should -Be 1 + } + It "Tests the search param with SystemOS" { + $apps = Get-JCSystemApp -SystemOS "macos" -SoftwareName "a" -search + $foundSystems = $apps.system_id | Select-Object -Unique + # if you specify a systemOS and Search, results should not contain multiple systems + foreach ($system in $foundSystems) { + $foundSystem = Get-JCSystem -SystemID $system + $foundSystem.osfamily | Should -be 'darwin' + } + } + + It "Tests compatability with the SDKs" { + $sdkChess = Get-JcSdkSystemInsightApp -filter @("system_id:eq:$($mac._id)", "bundle_name:eq:Chess") + $moduleChess = Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" + $moduleChessSearch = Get-JCSystemApp -SystemID $mac._id -SoftwareName "chess" -Search + # SDK Results should look exactly like module results when exact name is specified + $sdkChess | Should -Be $moduleChess + # SDK Results should look exactly like module results when search is provided + $sdkChess | Should -Be $moduleChessSearch + } + + It "Tests that incompatible parameters should not be used together" { + # -SoftwareVersion should not be specified with -Search + { Get-JCSystemApp -SoftwareName "chess" -Search -SoftwareVersion "3.1.2" } | Should -Throw + # -SystemOS should not be specified with -SystemID + { Get-JCsystemApp -SystemID $mac._id -SystemOS "windows" } | Should -Throw + { Get-JCsystemApp -SystemID $mac._id -SystemOS "windows" } | Should -Throw + { Get-JCsystemApp -SystemID $mac._id -SystemOS "windows" -SoftwareName "Chess" } | Should -Throw + { Get-JCsystemApp -SystemID $mac._id -SystemOS "windows" -SoftwareName "Chess" -SoftwareVersion "1.2.3" } | Should -Throw + } } From 0b2937a09313dc94ff01b9ec8b22e514d86c62e6 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Tue, 24 Jan 2023 15:54:50 -0700 Subject: [PATCH 025/102] export to csv tests --- .../Tests/Public/Systems/Get-JCSystemApp.tests.ps1 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index 6d63e79c6..b4d9abff4 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -82,4 +82,15 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { { Get-JCsystemApp -SystemID $mac._id -SystemOS "windows" -SoftwareName "Chess" } | Should -Throw { Get-JCsystemApp -SystemID $mac._id -SystemOS "windows" -SoftwareName "Chess" -SoftwareVersion "1.2.3" } | Should -Throw } + + It "Tests the exporability of a list of software apps" { + { Get-JCSystemApp -SystemOS linux | ConvertTo-Csv } | Should -Not -Throw + # Should return mac apps for all systems in the org + { Get-JCSystemApp -SystemOS macOS | ConvertTo-Csv } | Should -Not -Throw + # Should return windows programs for all systems in the org + { Get-JCSystemApp -SystemOS windows | ConvertTo-Csv } | Should -Not -Throw + { Get-JCSystemApp -SystemID $mac._id | ConvertTo-Csv } | Should -Not -Throw + { Get-JCSystemApp -SystemID $windows._id | ConvertTo-Csv } | Should -Not -Throw + { Get-JCSystemApp -SystemID $linux._id | ConvertTo-Csv } | Should -Not -Throw + } } From 2229128242d5719b631d606fb2a0a30770b278be Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 26 Jan 2023 08:57:52 -0800 Subject: [PATCH 026/102] added tests, cleanup --- PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index 1abf60833..8fbddf56e 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -18,7 +18,7 @@ Get-JCSystemApp [[-SystemID] ] [[-SystemOS] ] [[-SoftwareName] < ``` ## DESCRIPTION -{{ Fill in the Description }} +Get-JCSystem app function enables admins to search what software is on their systems ## EXAMPLES @@ -48,6 +48,13 @@ PS C:\> Get-JCSystemApp -SystemOs 'MacOs' -SoftwareName 'JumpCloud-Agent' -Softw Returns the 'MacOs' systems that have a 'JumpCloud Agent' application with the version '1.12.5' +### Example 5 +```powershell +PS C:\> Get-JCSystemApp -SoftwareName 'jumpcloud-agent' -Search +``` + +Returns any 'jumpcloud-agent' software installed in all the os systems + ## PARAMETERS ### -Search From b5c504b7dde4a933427a1996c5a4dbc61cbb55b1 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 26 Jan 2023 08:58:14 -0800 Subject: [PATCH 027/102] cleanup, added tests --- .../Public/Systems/Get-JCSystemApp.ps1 | 425 ++++++++++++------ .../Public/Systems/Get-JCSystemApp.tests.ps1 | 16 + 2 files changed, 302 insertions(+), 139 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index a6a623647..1d1a5e00e 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -1,18 +1,21 @@ function Get-JCSystemApp () { - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = 'All')] param ( - [Parameter(Mandatory = $false, HelpMessage = 'The System Id of the system you want to search for applications')] + [Parameter(Mandatory = $false, HelpMessage = 'The System Id of the system you want to search for applications')][ValidateNotNullorEmpty()] [string]$SystemID, - [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName, HelpMessage = 'The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, Mac, Linux))')] - [ValidateSet('Windows', 'MacOs', 'Linux')] + [Parameter(Mandatory = $false , ValueFromPipelineByPropertyName, HelpMessage = 'The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, Mac, Linux))')] + [ValidateSet('Windows', 'MacOs', 'Linux')][ValidateNotNullorEmpty()] [string]$SystemOS, - [Parameter(Mandatory = $false, HelpMessage = 'The name of the application you want to search for ex. (JumpCloud-Agent, Slack)')] + [Parameter(Mandatory = $false, HelpMessage = 'The name of the application you want to search for ex. (JumpCloud-Agent, Slack)')][ValidateNotNullorEmpty()] [string]$SoftwareName, - [Parameter(Mandatory = $false, HelpMessage = 'The version of the application you want to search for ex. (1.1.2)')] + [Parameter(Mandatory = $false, HelpMessage = 'The version of the application you want to search for ex. (1.1.2)')][ValidateNotNullorEmpty()] [string]$SoftwareVersion, - [Parameter(Mandatory = $false, HelpMessage = 'Search for a specific application by name from all systems in the org')] - [switch]$Search + [Parameter(Mandatory = $false, ParameterSetName = "Search", HelpMessage = 'Search for a specific application by name from all systems in the org')] + [switch]$Search, + [Parameter(DontShow, Mandatory = $false, ParameterSetName = "All", HelpMessage = 'Search for a specific application by name from all systems in the org')] + [switch]$Software + ) begin { Write-Verbose 'Verifying JCAPI Key' @@ -28,6 +31,7 @@ function Get-JCSystemApp () { Write-Verbose 'Initilizing resultsArray' $resultsArrayList = New-Object -TypeName System.Collections.ArrayList } + Write-Verbose "Parameter Set: $($PSCmdlet.ParameterSetName)" } process { [int]$limit = '1000' @@ -36,155 +40,298 @@ function Get-JCSystemApp () { [int]$skip = '0' Write-Verbose "Setting skip to $skip" $applicationArray = @('programs', 'apps', 'linux_packages') - # Search - if ($Search) { - # Get all the results - $applicationArray | ForEach-Object { - $URL = "$JCUrlBasePath/api/v2/systeminsights/$($_)" - Write-Verbose "Searching for $SoftwareName in $_" - if ($Parallel) { - $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit - } - # Add OS Family to results - if ($_ -eq 'programs') { $os = 'Windows' } - elseif ($_ -eq 'apps') { $os = 'MacOs' } - elseif ($_ -eq 'linux_packages') { $os = 'Linux' } - $searchAppResults | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - [void]$searchAppResultsList.Add($searchAppResults) - } - # softwarename search - if ($SoftwareName) { - $searchAppResultsList | ForEach-Object { - $results = $_ | Where-Object { $_.name -match $SoftwareName } - $results | ForEach-Object { - $resultsArrayList.Add($_) - } - } + switch ($PSCmdlet.ParameterSetName) { + All { + if ($SystemId) { + Write-Debug "SystemId" + $OSType = Get-JCSystem -ID $SystemID | Select-Object -ExpandProperty osFamily + if ($OsType -eq 'MacOs') { $Ostype = 'Darwin' } + switch ($OSType) { + 'Windows' { + # If Software title, version, and system ID are passed then return specific app + if ($SoftwareVersion -and $SoftwareName -and $SystemID) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemId&filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" - } + } elseif ($SoftwareName -and $SystemID) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" + } elseif ($SystemID) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID" + } + Write-Debug $URL + } + 'Darwin' { + # If Software title, version, and system ID are passed then return specific app + if ($SoftwareVersion -and $SoftwareName -and $SystemID) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemId&filter=bundle_name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion" + + } elseif ($SoftwareName -and $SystemID) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemID&filter=bundle_name:eq:$SoftwareName" + } elseif ($SystemID) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemID" + } + Write-Debug $URL + } + 'Linux' { + # If Software title, version and system ID are passed then return specific app + if ($SoftwareVersion -and $SoftwareName -and $SystemID) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemId&filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion&filter=system_id:eq:$SystemID" + + } elseif ($SoftwareName -and $SystemID) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" + } elseif ($SystemID) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID" + } + Write-Debug $URL + } - } elseif ($SystemId -or $SystemOs) { - if ($SystemId) { - $OSType = Get-JCSystem -ID $SystemID | Select-Object -ExpandProperty osFamily - } elseif ($SystemOs) { - $OSType = $SystemOs - } - if ($OsType -eq 'MacOs') { $Ostype = 'Darwin' } # OS Family for Mac is Darwin - - Write-Debug "OS: $OSType" - switch ($OSType) { - 'Windows' { - # If Software title and system ID are passed then return specific app - if ($SoftwareVersion -and $SoftwareName ) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" - - } elseif ($SoftwareName -and $SystemID) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" - } elseif ($SoftwareName) { - # Add filter for system ID to $Search - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName" - } elseif ($SystemID) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID" - } else { - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs" - } - Write-Debug $URL - } - 'Darwin' { - # If Software title and system ID are passed then return specific app - if ($SoftwareVersion -and $SoftwareName) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName&filter=bundle_version:eq:$SoftwareVersion" - - } elseif ($SoftwareName -and $SystemID) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemID&filter=bundle_name:eq:$SoftwareName" - } elseif ($SoftwareName) { - # Add filter for system ID to $Search - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName" - } elseif ($SystemID) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemID" - } else { - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps" } - Write-Debug $URL - } - 'Linux' { - # If Software title and system ID are passed then return specific app - if ($SoftwareVersion -and $SoftwareName) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" - - } elseif ($SoftwareName -and $SystemID) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" - } elseif ($SoftwareName) { - # Add filter for system ID to $Search - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName" - } elseif ($SystemID) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID" + if ($Parallel) { + $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true } else { - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages" + $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit } - Write-Debug $URL - } - } - if ($Parallel) { - $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit - } + } elseif ($SystemOS) { + $OSType = $SystemOS + if ($OSType -eq 'MacOs') { $OSType = 'Darwin' } # OS Family for Mac is Darwin + + Write-Debug "OS: $SystemOs" + switch ($OSType) { + 'Windows' { + # If Software title, version, and system ID are passed then return specific app + if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" + + } elseif ($SoftwareName -and $SystemOS) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName" + } elseif ($SystemOs) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs" + } + Write-Debug $URL + } + 'Darwin' { + # If Software title, version, and system ID are passed then return specific app + if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion" + + } elseif ($SoftwareName -and $SystemOS) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?&filter=bundle_name:eq:$SoftwareName" + } elseif ($SystemOs) { + # Add filter for system ID to $Search + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps" + } + Write-Debug $URL + } + 'Linux' { + # If Software title, version, and system ID are passed then return specific app + if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" + + } elseif ($SoftwareName -and $SystemOS) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName" + } elseif ($SystemOs) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages" + } + Write-Debug $URL + } - } elseif ($SoftwareName) { - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - # Foreach Mac, Windows, Linux - foreach ($os in @('MacOs', 'Windows', 'Linux')) { - if ($os -eq 'MacOs') { - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName" - if ($Parallel) { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit } - $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - $resultsArrayList.Add($resultsArray) - } elseif ($os -eq 'Windows') { - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName" if ($Parallel) { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true } else { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit + $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit } - $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - $resultsArrayList.Add($resultsArray) - } elseif ($os -eq 'Linux') { - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName" - if ($Parallel) { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } elseif ($SoftwareName ) { + Write-Debug "SoftwareName: $SoftwareName" + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + # Foreach Mac, Windows, Linux + foreach ($os in @('MacOs', 'Windows', 'Linux')) { + if ($os -eq 'MacOs') { + if ($SoftwareVersion -and $SoftwareName) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName&filter=bundle_short_version:eq:$softwareVersion" + } else { + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName" + } + + if ($Parallel) { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit + } + # If no results, skip to next OS + if ($resultsArray.count -eq 0) { + continue + } + $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + $resultsArrayList.Add($resultsArray) + } elseif ($os -eq 'Windows') { + if ($SoftwareVersion -and $SoftwareName) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName&filter=version:eq:$softwareVersion" + } else { + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName" + } + if ($Parallel) { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit + } + if ($resultsArray.count -eq 0) { continue } + $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + $resultsArrayList.Add($resultsArray) + } elseif ($os -eq 'Linux') { + if ($SoftwareVersion -and $SoftwareName) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName&filter=version:eq:$softwareVersion" + } else { + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName" + } + if ($Parallel) { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit + } + if ($resultsArray.count -eq 0) { continue } + $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + $resultsArrayList.Add($resultsArray) + } + } + } else { + # Print all software + foreach ($os in @('programs', 'apps', 'linux_packages')) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/$os" + if ($Parallel) { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit + } + if ($resultsArray.count -eq 0) { continue } + # Add OS Family to results + if ($os -eq 'programs') { $os = 'Windows' } + elseif ($os -eq 'apps') { $os = 'MacOs' } + elseif ($os -eq 'linux_packages') { $os = 'Linux' } + $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + $resultsArrayList.Add($resultsArray) + + } + } + + } Search { + # IF only software name and no system ID or OS or version + if ($SoftwareName -and $Search) { + # Check if other parameters are set + if ($SoftwareVersion) { + Write-Error 'You cannot specify a system ID or version when using -search for a software name' + } elseif ($SystemId) { + $applicationArray | ForEach-Object { + $URL = "$JCUrlBasePath/api/v2/systeminsights/$_" + Write-Verbose "Searching for $SoftwareName and $SystemId in $_ " + if ($Parallel) { + $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit + } + # Add OS Family to results + if ($_ -eq 'programs') { $os = 'Windows' } + elseif ($_ -eq 'apps') { $os = 'MacOs' } + elseif ($_ -eq 'linux_packages') { $os = 'Linux' } + $searchAppResults | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + [void]$searchAppResultsList.Add($searchAppResults) + } + $searchAppResultsList | ForEach-Object { + $results = $_ | Where-Object { ($_.name -match $SoftwareName) -and ($_.System_id -match $SystemId) } + $results | ForEach-Object { + $resultsArrayList.Add($_) + } + } + } elseif ($SystemOS) { + # Get all the results if softwarename elseif softwarename and version + + $applicationArray | ForEach-Object { + $URL = "$JCUrlBasePath/api/v2/systeminsights/$_" + Write-Verbose "Searching for $SoftwareName and $SystemOs in $_ " + if ($Parallel) { + $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit + } + # Add OS Family to results + if ($_ -eq 'programs') { $os = 'Windows' } + elseif ($_ -eq 'apps') { $os = 'MacOs' } + elseif ($_ -eq 'linux_packages') { $os = 'Linux' } + $searchAppResults | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + [void]$searchAppResultsList.Add($searchAppResults) + } + $searchAppResultsList | ForEach-Object { + $results = $_ | Where-Object { ($_.name -match $SoftwareName) -and ($_.osFamily -match $SystemOs) } + $results | ForEach-Object { + $resultsArrayList.Add($_) + } + } } else { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit + # Get all the results with only softwarename + $applicationArray | ForEach-Object { + $URL = "$JCUrlBasePath/api/v2/systeminsights/$_" + Write-Verbose "Searching for $SoftwareName in $_ " + if ($Parallel) { + $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit + } + # Add OS Family to results + if ($_ -eq 'programs') { $os = 'Windows' } + elseif ($_ -eq 'apps') { $os = 'MacOs' } + elseif ($_ -eq 'linux_packages') { $os = 'Linux' } + $searchAppResults | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + [void]$searchAppResultsList.Add($searchAppResults) + + } + $searchAppResultsList | ForEach-Object { + $results = $_ | Where-Object { ($_.name -match $SoftwareName) -and ($_.osFamily -match $SystemOs) } + $results | ForEach-Object { + $resultsArrayList.Add($_) + } + } } - $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - $resultsArrayList.Add($resultsArray) + } } + } + } end { - return $resultsArrayList + switch ($PSCmdlet.ParameterSetName) { + Search { + return $resultsArrayList + } + All { + return $resultsArrayList + } + } } -} # End Function +} diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index 8668c5281..788e22b8f 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -6,6 +6,10 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { $windows = $systems | Where-Object { $_.osFamily -match "windows" } | Select-Object -First 1 $linux = $systems | Where-Object { $_.osFamily -match "linux" } | Select-Object -First 1 } + IT "Returns all the software" { + $AllApps = Get-JCSystemApp + $AllApps | Should -Not -BeNullOrEmpty + } It "Tests that Get-JCSystemApp returns packages/apps/programs for all systems in the org" { # Should return linuxPackages for all systems in the org @@ -38,4 +42,16 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion "48.49.50.51" | Should -Be $null # TODO: Windows/ Linux Examples } + # Create tests for Search + It "Tests for search given SystemOs and SoftwareName" { + # Chess is always installed on MacOS and it CAN NOT be removed no matter wha + { Get-JCSystemApp -Search -SoftwareName "Chess" | Should -Not -Throw } + { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemOs "MacOs" | Should -Not -Throw } + # A null value version shouldn't be accepted + { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemOs "" | Should -Throw } + # A null value version shouldn't be accepted + { Get-JCSystemApp -Search -SoftwareName "" -SystemOs "MacOs" | Should -Throw } + # Searching chess on MacOs should return a result + { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemOs "MacOs" | Should -Not -Throw } + } } From efc864b50f6888d3d70ef68146f4d334747edf2c Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Thu, 26 Jan 2023 17:12:25 +0000 Subject: [PATCH 028/102] Updating PowerShell Module;[skip ci] --- .../JumpCloud Module/Docs/Get-JCSystemApp.md | 21 ++++-- .../Docs/Set-JCSettingsFile.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- .../JumpCloud Module/en-Us/JumpCloud-help.xml | 67 ++++++++++--------- 4 files changed, 53 insertions(+), 39 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index 8fbddf56e..55b298631 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -12,9 +12,16 @@ Returns the System Apps installed to a JumpCloud System(s) ## SYNTAX +### All (Default) ``` -Get-JCSystemApp [[-SystemID] ] [[-SystemOS] ] [[-SoftwareName] ] - [[-SoftwareVersion] ] [-Search] [] +Get-JCSystemApp [-SystemID ] [-SystemOS ] [-SoftwareName ] [-SoftwareVersion ] + [] +``` + +### Search +``` +Get-JCSystemApp [-SystemID ] [-SystemOS ] [-SoftwareName ] [-SoftwareVersion ] + [-Search] [] ``` ## DESCRIPTION @@ -63,7 +70,7 @@ Global search ex. ```yaml Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) +Parameter Sets: Search Aliases: Required: False @@ -83,7 +90,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 2 +Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -99,7 +106,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 3 +Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -114,7 +121,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 0 +Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -131,7 +138,7 @@ Aliases: Accepted values: Windows, MacOs, Linux Required: False -Position: 1 +Position: Named Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index f8bf10130..ba6b37a0c 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] +Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 9789ba99d..917b446e9 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 1/23/2023 +# Generated on: 1/26/2023 # @{ diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index 91914038c..ff23e06c7 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -7058,33 +7058,27 @@ PS C:\> $BackupJcOrganizationResults.User - {{ Fill in the Description }} + Get-JCSystem app function enables admins to search what software is on their systems Get-JCSystemApp - - SystemID + + Search - The System Id of the JumpCloud system you want to search for applications + Global search ex. (1.1.2) - System.String - System.String + System.Management.Automation.SwitchParameter - None + False - - SystemOS + + SoftwareName - The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, Mac, Linux)) + The name of the application you want to search for ex. (JumpCloud-Agent, Slack) - - Windows - MacOs - Linux - System.String System.String @@ -7092,10 +7086,10 @@ PS C:\> $BackupJcOrganizationResults.User None - - SoftwareName + + SoftwareVersion - The name of the application you want to search for ex. (JumpCloud-Agent, Slack) + The version of the application you want to search for ex. (1.1.2) System.String @@ -7104,10 +7098,10 @@ PS C:\> $BackupJcOrganizationResults.User None - - SoftwareVersion + + SystemID - The version of the application you want to search for ex. (1.1.2) + The System Id of the JumpCloud system you want to search for applications System.String @@ -7116,16 +7110,22 @@ PS C:\> $BackupJcOrganizationResults.User None - - Search + + SystemOS - Global search ex. (1.1.2) + The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, Mac, Linux)) + + Windows + MacOs + Linux + + System.String - System.Management.Automation.SwitchParameter + System.String - False + None @@ -7142,7 +7142,7 @@ PS C:\> $BackupJcOrganizationResults.User False - + SoftwareName The name of the application you want to search for ex. (JumpCloud-Agent, Slack) @@ -7154,7 +7154,7 @@ PS C:\> $BackupJcOrganizationResults.User None - + SoftwareVersion The version of the application you want to search for ex. (1.1.2) @@ -7166,7 +7166,7 @@ PS C:\> $BackupJcOrganizationResults.User None - + SystemID The System Id of the JumpCloud system you want to search for applications @@ -7178,7 +7178,7 @@ PS C:\> $BackupJcOrganizationResults.User None - + SystemOS The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, Mac, Linux)) @@ -7245,6 +7245,13 @@ PS C:\> $BackupJcOrganizationResults.User Returns the 'MacOs' systems that have a 'JumpCloud Agent' application with the version '1.12.5' + + -------------------------- Example 5 -------------------------- + PS C:\> Get-JCSystemApp -SoftwareName 'jumpcloud-agent' -Search + + Returns any 'jumpcloud-agent' software installed in all the os systems + + From 2e17cb41bee53f0198db3272a7f4f7612b21252a Mon Sep 17 00:00:00 2001 From: Ken Maranion <97972790+kmaranionjc@users.noreply.github.com> Date: Thu, 26 Jan 2023 13:50:44 -0800 Subject: [PATCH 029/102] Update PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md Co-authored-by: Joe Workman <54448601+jworkmanjc@users.noreply.github.com> --- PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index 55b298631..9df55cf16 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -8,7 +8,7 @@ schema: 2.0.0 # Get-JCSystemApp ## SYNOPSIS -Returns the System Apps installed to a JumpCloud System(s) +Returns the applications/programs/linux packages installed on JumpCloud managed system(s). This function queries separate system insights tables to get data for macOS/windows/linux devices. ## SYNTAX From 90af6002c1ebd86fa979cb6a58f606839c93b2b0 Mon Sep 17 00:00:00 2001 From: Ken Maranion <97972790+kmaranionjc@users.noreply.github.com> Date: Thu, 26 Jan 2023 13:50:53 -0800 Subject: [PATCH 030/102] Update PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md Co-authored-by: Joe Workman <54448601+jworkmanjc@users.noreply.github.com> --- PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index 9df55cf16..5e8a310ab 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -25,7 +25,7 @@ Get-JCSystemApp [-SystemID ] [-SystemOS ] [-SoftwareName Date: Thu, 26 Jan 2023 13:51:04 -0800 Subject: [PATCH 031/102] Update PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md Co-authored-by: Joe Workman <54448601+jworkmanjc@users.noreply.github.com> --- PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index 5e8a310ab..32e12000d 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -31,7 +31,7 @@ Get-JCSystem app function helps admins identify what applications/programs or li ### Example 1 ```powershell -PS C:\> Get-JCSystemApp -SystemId 'SystemId' +PS C:\> Get-JCSystemApp -SystemId '6363237ec991136ae59892e4' ``` Returns the applications installed in the system with the given -SystemId From 03a939583148917141535d1f6cd6138c2c8f3d2a Mon Sep 17 00:00:00 2001 From: Ken Maranion <97972790+kmaranionjc@users.noreply.github.com> Date: Thu, 26 Jan 2023 13:51:12 -0800 Subject: [PATCH 032/102] Update PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 Co-authored-by: Joe Workman <54448601+jworkmanjc@users.noreply.github.com> --- PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 1d1a5e00e..73509d1d1 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -5,7 +5,7 @@ function Get-JCSystemApp () { [Parameter(Mandatory = $false, HelpMessage = 'The System Id of the system you want to search for applications')][ValidateNotNullorEmpty()] [string]$SystemID, [Parameter(Mandatory = $false , ValueFromPipelineByPropertyName, HelpMessage = 'The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, Mac, Linux))')] - [ValidateSet('Windows', 'MacOs', 'Linux')][ValidateNotNullorEmpty()] + [ValidateSet('Windows', 'macOS', 'Linux')][ValidateNotNullorEmpty()] [string]$SystemOS, [Parameter(Mandatory = $false, HelpMessage = 'The name of the application you want to search for ex. (JumpCloud-Agent, Slack)')][ValidateNotNullorEmpty()] [string]$SoftwareName, From 10595aa8d66de8467a6658fb682da1e7fd970911 Mon Sep 17 00:00:00 2001 From: Ken Maranion <97972790+kmaranionjc@users.noreply.github.com> Date: Thu, 26 Jan 2023 13:51:45 -0800 Subject: [PATCH 033/102] Update PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md Co-authored-by: Joe Workman <54448601+jworkmanjc@users.noreply.github.com> --- PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index 32e12000d..cf0bb4b39 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -38,7 +38,7 @@ Returns the applications installed in the system with the given -SystemId ### Example 2 ```powershell -PS C:\> Get-JCSystemApp -SystemOs 'MacOs' +PS C:\> Get-JCSystemApp -SystemOs 'macOS' ``` Returns the 'MacOs' systems and all the applications installed for each system From f09d2c0989a3433ae952bd0195717c290c5035c4 Mon Sep 17 00:00:00 2001 From: Ken Maranion <97972790+kmaranionjc@users.noreply.github.com> Date: Thu, 26 Jan 2023 13:51:57 -0800 Subject: [PATCH 034/102] Update PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md Co-authored-by: Joe Workman <54448601+jworkmanjc@users.noreply.github.com> --- PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index cf0bb4b39..238312c81 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -45,7 +45,7 @@ Returns the 'MacOs' systems and all the applications installed for each system ### Example 3 ```powershell -PS C:\> Get-JCSystemApp -SystemOs 'MacOs' -SoftwareName 'JumpCloud-Agent' +PS C:\> Get-JCSystemApp -SystemOs 'macOS' -SoftwareName 'JumpCloud-Agent' ``` ### Example 4 From f0e5cb0c421992a6967b94cc9c7eaab081ae8eee Mon Sep 17 00:00:00 2001 From: Ken Maranion <97972790+kmaranionjc@users.noreply.github.com> Date: Thu, 26 Jan 2023 13:52:09 -0800 Subject: [PATCH 035/102] Update PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md Co-authored-by: Joe Workman <54448601+jworkmanjc@users.noreply.github.com> --- PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index 238312c81..36a0e63ff 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -50,7 +50,7 @@ PS C:\> Get-JCSystemApp -SystemOs 'macOS' -SoftwareName 'JumpCloud-Agent' ### Example 4 ```powershell -PS C:\> Get-JCSystemApp -SystemOs 'MacOs' -SoftwareName 'JumpCloud-Agent' -SoftwareVersion '1.12.5' +PS C:\> Get-JCSystemApp -SystemOs 'macOS' -SoftwareName 'JumpCloud-Agent' -SoftwareVersion '1.12.5' ``` Returns the 'MacOs' systems that have a 'JumpCloud Agent' application with the version '1.12.5' From a085d06b165711276ee8484ac8070076562c4448 Mon Sep 17 00:00:00 2001 From: Ken Maranion <97972790+kmaranionjc@users.noreply.github.com> Date: Thu, 26 Jan 2023 13:52:21 -0800 Subject: [PATCH 036/102] Update PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md Co-authored-by: Joe Workman <54448601+jworkmanjc@users.noreply.github.com> --- PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index 36a0e63ff..8b3ad6188 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -41,7 +41,7 @@ Returns the applications installed in the system with the given -SystemId PS C:\> Get-JCSystemApp -SystemOs 'macOS' ``` -Returns the 'MacOs' systems and all the applications installed for each system +Returns the 'macOS' systems and all the applications installed for each system ### Example 3 ```powershell From b0d83060b0f915c91e5c01ebf43f4ea8d4f002fd Mon Sep 17 00:00:00 2001 From: Ken Maranion <97972790+kmaranionjc@users.noreply.github.com> Date: Thu, 26 Jan 2023 13:53:26 -0800 Subject: [PATCH 037/102] Update PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md Co-authored-by: Joe Workman <54448601+jworkmanjc@users.noreply.github.com> --- PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index 8b3ad6188..ef905fe3f 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -53,7 +53,7 @@ PS C:\> Get-JCSystemApp -SystemOs 'macOS' -SoftwareName 'JumpCloud-Agent' PS C:\> Get-JCSystemApp -SystemOs 'macOS' -SoftwareName 'JumpCloud-Agent' -SoftwareVersion '1.12.5' ``` -Returns the 'MacOs' systems that have a 'JumpCloud Agent' application with the version '1.12.5' +Returns the 'macOS' systems that have a 'JumpCloud Agent' application with the version '1.12.5' ### Example 5 ```powershell From ce99735d5ee48d575967ac29fd8465757cb3fe7d Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Thu, 26 Jan 2023 22:01:05 +0000 Subject: [PATCH 038/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/JumpCloud.md | 2 +- .../JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- .../JumpCloud Module/en-Us/JumpCloud-help.xml | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md index 985234f75..3056fe7c7 100644 --- a/PowerShell/JumpCloud Module/Docs/JumpCloud.md +++ b/PowerShell/JumpCloud Module/Docs/JumpCloud.md @@ -87,7 +87,7 @@ Return JumpCloud radius server information. Returns all JumpCloud Systems within a JumpCloud tenant or a single JumpCloud System using the -ByID Parameter. ### [Get-JCSystemApp](Get-JCSystemApp.md) -Returns the System Apps installed to a JumpCloud System(s) +Returns the applications/programs/linux packages installed on JumpCloud managed system(s). This function queries separate system insights tables to get data for macOS/windows/linux devices. ### [Get-JCSystemGroupMember](Get-JCSystemGroupMember.md) Returns the System Group members of a JumpCloud System Group. diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index ba6b37a0c..f8bf10130 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] +Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index ff23e06c7..1aa8ce6c4 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -7054,11 +7054,11 @@ PS C:\> $BackupJcOrganizationResults.User Get JCSystemApp - Returns the System Apps installed to a JumpCloud System(s) + Returns the applications/programs/linux packages installed on JumpCloud managed system(s). This function queries separate system insights tables to get data for macOS/windows/linux devices. - Get-JCSystem app function enables admins to search what software is on their systems + Get-JCSystem app function helps admins identify what applications/programs or linux packages exist on their JumpCloud managed systems. @@ -7219,30 +7219,30 @@ PS C:\> $BackupJcOrganizationResults.User -------------------------- Example 1 -------------------------- - PS C:\> Get-JCSystemApp -SystemId 'SystemId' + PS C:\> Get-JCSystemApp -SystemId '6363237ec991136ae59892e4' Returns the applications installed in the system with the given -SystemId -------------------------- Example 2 -------------------------- - PS C:\> Get-JCSystemApp -SystemOs 'MacOs' + PS C:\> Get-JCSystemApp -SystemOs 'macOS' - Returns the 'MacOs' systems and all the applications installed for each system + Returns the 'macOS' systems and all the applications installed for each system -------------------------- Example 3 -------------------------- - PS C:\> Get-JCSystemApp -SystemOs 'MacOs' -SoftwareName 'JumpCloud-Agent' + PS C:\> Get-JCSystemApp -SystemOs 'macOS' -SoftwareName 'JumpCloud-Agent' -------------------------- Example 4 -------------------------- - PS C:\> Get-JCSystemApp -SystemOs 'MacOs' -SoftwareName 'JumpCloud-Agent' -SoftwareVersion '1.12.5' + PS C:\> Get-JCSystemApp -SystemOs 'macOS' -SoftwareName 'JumpCloud-Agent' -SoftwareVersion '1.12.5' - Returns the 'MacOs' systems that have a 'JumpCloud Agent' application with the version '1.12.5' + Returns the 'macOS' systems that have a 'JumpCloud Agent' application with the version '1.12.5' From c16686fb769ac66d4d657c28e3c8446540c16b0f Mon Sep 17 00:00:00 2001 From: Ken Maranion <97972790+kmaranionjc@users.noreply.github.com> Date: Thu, 26 Jan 2023 14:07:33 -0800 Subject: [PATCH 039/102] Update PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md Co-authored-by: Joe Workman <54448601+jworkmanjc@users.noreply.github.com> --- PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index ef905fe3f..b573b38fc 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -135,7 +135,7 @@ The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. Type: System.String Parameter Sets: (All) Aliases: -Accepted values: Windows, MacOs, Linux +Accepted values: Windows, macOS, Linux Required: False Position: Named From 84763e81f4ec374c636d41f26e1b9f03738bbbdd Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 26 Jan 2023 14:08:51 -0800 Subject: [PATCH 040/102] cleanup --- PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md | 4 ++-- .../JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 | 5 ++++- .../Tests/Public/Systems/Get-JCSystemApp.tests.ps1 | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index b573b38fc..b5fe530e7 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -65,8 +65,8 @@ Returns any 'jumpcloud-agent' software installed in all the os systems ## PARAMETERS ### -Search -Global search ex. -(1.1.2) +Search for a specific application by from all systems in the org ex. +(Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") ```yaml Type: System.Management.Automation.SwitchParameter diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 73509d1d1..b8b7e43cb 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -11,7 +11,7 @@ function Get-JCSystemApp () { [string]$SoftwareName, [Parameter(Mandatory = $false, HelpMessage = 'The version of the application you want to search for ex. (1.1.2)')][ValidateNotNullorEmpty()] [string]$SoftwareVersion, - [Parameter(Mandatory = $false, ParameterSetName = "Search", HelpMessage = 'Search for a specific application by name from all systems in the org')] + [Parameter(Mandatory = $false, ParameterSetName = "Search", HelpMessage = 'Search for a specific application by from all systems in the org ex (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent")')] [switch]$Search, [Parameter(DontShow, Mandatory = $false, ParameterSetName = "All", HelpMessage = 'Search for a specific application by name from all systems in the org')] [switch]$Software @@ -46,6 +46,7 @@ function Get-JCSystemApp () { if ($SystemId) { Write-Debug "SystemId" $OSType = Get-JCSystem -ID $SystemID | Select-Object -ExpandProperty osFamily + # Handle error for if Get-JCSystem returns nothing if ($OsType -eq 'MacOs') { $Ostype = 'Darwin' } switch ($OSType) { 'Windows' { @@ -317,6 +318,8 @@ function Get-JCSystemApp () { } } + } else { + Write-Error "You must specify a software name and/or systemId when using -search" } } diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index 0e2f58b37..cc7d01378 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -43,7 +43,9 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { } # Create tests for Search It "Tests for search given SystemOs and SoftwareName" { - # Chess is always installed on MacOS and it CAN NOT be removed no matter wha + # Chess is always installed on MacOS and it CAN NOT be removed no matter what + { Get-JCSystemApp -Search | Should -Throw } + { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemID $mac.Id | Should -Not -Throw } { Get-JCSystemApp -Search -SoftwareName "Chess" | Should -Not -Throw } { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemOs "MacOs" | Should -Not -Throw } # A null value version shouldn't be accepted From 580af048b8d5965e515403097b308ce8639621f5 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Thu, 26 Jan 2023 22:16:24 +0000 Subject: [PATCH 041/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index f8bf10130..ba6b37a0c 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] +Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index 45ae97a33..0f6ad0948 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.2.0.7454-202301232306 + 2.2.0.7522-202301262214 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index 1aa8ce6c4..df6d8aa47 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -7066,7 +7066,7 @@ PS C:\> $BackupJcOrganizationResults.User Search - Global search ex. (1.1.2) + Search for a specific application by from all systems in the org ex. (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") System.Management.Automation.SwitchParameter @@ -7117,7 +7117,7 @@ PS C:\> $BackupJcOrganizationResults.User Windows - MacOs + macOS Linux System.String @@ -7133,7 +7133,7 @@ PS C:\> $BackupJcOrganizationResults.User Search - Global search ex. (1.1.2) + Search for a specific application by from all systems in the org ex. (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") System.Management.Automation.SwitchParameter From 9ab53e07a50967aac67af6a12d175461f4c7f429 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 26 Jan 2023 14:22:42 -0800 Subject: [PATCH 042/102] MacOs bundle_name replace with name filter --- .../JumpCloud Module/Docs/Get-JCSystemApp.md | 2 +- .../Public/Systems/Get-JCSystemApp.ps1 | 29 ++++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index b5fe530e7..c42d1b1cd 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -129,7 +129,7 @@ Accept wildcard characters: False ### -SystemOS The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. -(Windows, Mac, Linux)) +(Windows, macOs, Linux)) ```yaml Type: System.String diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index b8b7e43cb..5303e6797 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -67,15 +67,21 @@ function Get-JCSystemApp () { } 'Darwin' { # If Software title, version, and system ID are passed then return specific app + # If $softwareName does not have .app at the end then add it + if (-not $SoftwareName.EndsWith('.app')) { + $SoftwareName = $SoftwareName + '.app' + } else { + Write-Debug "$($SoftwareName) already ends with .app" + } if ($SoftwareVersion -and $SoftwareName -and $SystemID) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemId&filter=bundle_name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion" + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemId&filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion" } elseif ($SoftwareName -and $SystemID) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemID&filter=bundle_name:eq:$SoftwareName" + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" } elseif ($SystemID) { $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemID" } @@ -129,15 +135,20 @@ function Get-JCSystemApp () { } 'Darwin' { # If Software title, version, and system ID are passed then return specific app + if (-not $SoftwareName.EndsWith('.app')) { + $SoftwareName = $SoftwareName + '.app' + } else { + Write-Debug "$($SoftwareName) already ends with .app" + } if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion" + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion" } elseif ($SoftwareName -and $SystemOS) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?&filter=bundle_name:eq:$SoftwareName" + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?&filter=name:eq:$SoftwareName" } elseif ($SystemOs) { # Add filter for system ID to $Search $URL = "$JCUrlBasePath/api/v2/systeminsights/apps" @@ -168,15 +179,19 @@ function Get-JCSystemApp () { $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit } } elseif ($SoftwareName ) { - Write-Debug "SoftwareName: $SoftwareName" $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) # Foreach Mac, Windows, Linux foreach ($os in @('MacOs', 'Windows', 'Linux')) { if ($os -eq 'MacOs') { + if (-not $SoftwareName.EndsWith('.app')) { + $SoftwareName = $SoftwareName + '.app' + } else { + Write-Debug "$($SoftwareName) already ends with .app" + } if ($SoftwareVersion -and $SoftwareName) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName&filter=bundle_short_version:eq:$softwareVersion" + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$softwareVersion" } else { - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=bundle_name:eq:$SoftwareName" + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName" } if ($Parallel) { From cf5c02112b19c3de01ecec46c86f3e8a1425dd36 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 26 Jan 2023 14:25:39 -0800 Subject: [PATCH 043/102] docs --- PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md | 1 + PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index c42d1b1cd..e075d4bc2 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -83,6 +83,7 @@ Accept wildcard characters: False ### -SoftwareName The name of the application you want to search for ex. (JumpCloud-Agent, Slack) +SoftwareName will always query the 'name' property from system insights. Note, for macOS systems, '.app' will be applied ```yaml Type: System.String diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 5303e6797..e36479709 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -7,7 +7,7 @@ function Get-JCSystemApp () { [Parameter(Mandatory = $false , ValueFromPipelineByPropertyName, HelpMessage = 'The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, Mac, Linux))')] [ValidateSet('Windows', 'macOS', 'Linux')][ValidateNotNullorEmpty()] [string]$SystemOS, - [Parameter(Mandatory = $false, HelpMessage = 'The name of the application you want to search for ex. (JumpCloud-Agent, Slack)')][ValidateNotNullorEmpty()] + [Parameter(Mandatory = $false, HelpMessage = 'The name of the application you want to search for ex. (JumpCloud-Agent, Slack). SoftwareName will always query the "name" property from system insights. Note, for macOS systems, ".app" will be applied' )][ValidateNotNullorEmpty()] [string]$SoftwareName, [Parameter(Mandatory = $false, HelpMessage = 'The version of the application you want to search for ex. (1.1.2)')][ValidateNotNullorEmpty()] [string]$SoftwareVersion, From 6b7eb1e9f775e6c9ccbc917552918d11e19dc7df Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Thu, 26 Jan 2023 22:34:46 +0000 Subject: [PATCH 044/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index ba6b37a0c..f8bf10130 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] +Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index df6d8aa47..45deb2b1f 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -7077,7 +7077,7 @@ PS C:\> $BackupJcOrganizationResults.User SoftwareName - The name of the application you want to search for ex. (JumpCloud-Agent, Slack) + The name of the application you want to search for ex. (JumpCloud-Agent, Slack) SoftwareName will always query the 'name' property from system insights. Note, for macOS systems, '.app' will be applied System.String @@ -7113,7 +7113,7 @@ PS C:\> $BackupJcOrganizationResults.User SystemOS - The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, Mac, Linux)) + The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, macOs, Linux)) Windows @@ -7145,7 +7145,7 @@ PS C:\> $BackupJcOrganizationResults.User SoftwareName - The name of the application you want to search for ex. (JumpCloud-Agent, Slack) + The name of the application you want to search for ex. (JumpCloud-Agent, Slack) SoftwareName will always query the 'name' property from system insights. Note, for macOS systems, '.app' will be applied System.String @@ -7181,7 +7181,7 @@ PS C:\> $BackupJcOrganizationResults.User SystemOS - The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, Mac, Linux)) + The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, macOs, Linux)) System.String From e6fce4b17219490afa11cad4b1a85d32729fafee Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Thu, 26 Jan 2023 15:36:04 -0700 Subject: [PATCH 045/102] tests .app/.App [skip ci] --- .../Tests/Public/Systems/Get-JCSystemApp.tests.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index cc7d01378..03efcbcbf 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -110,7 +110,11 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { { Get-JCSystemApp -SystemID $windows._id | ConvertTo-Csv } | Should -Not -Throw { Get-JCSystemApp -SystemID $linux._id | ConvertTo-Csv } | Should -Not -Throw } - + It "Tests macos functionatily to append .app to softwareTitles" { + Get-JCSystemApp -SystemID $mac._id -SoftwareTitle "chess.app" | Should -Not -BeNullOrEmpty + Get-JCSystemApp -SystemID $mac._id -SoftwareTitle "chess.App" | Should -Not -BeNullOrEmpty + Get-JCSystemApp -SystemID $mac._id -SoftwareTitle "chess" | Should -Not -BeNullOrEmpty + } } From d17986d4cd0293690896213413784970dcee9c1a Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Thu, 26 Jan 2023 22:44:51 +0000 Subject: [PATCH 046/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index f8bf10130..ba6b37a0c 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] +Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index 0f6ad0948..b8b00d035 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.2.0.7522-202301262214 + 2.2.0.7549-202301262243 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud From 871973bcf7cda07f4e61925914db771229bf68a7 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 26 Jan 2023 15:20:10 -0800 Subject: [PATCH 047/102] macOs softwarename fix --- .../Public/Systems/Get-JCSystemApp.ps1 | 63 ++++++++----------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index e36479709..87a645dca 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -69,9 +69,11 @@ function Get-JCSystemApp () { # If Software title, version, and system ID are passed then return specific app # If $softwareName does not have .app at the end then add it if (-not $SoftwareName.EndsWith('.app')) { - $SoftwareName = $SoftwareName + '.app' - } else { - Write-Debug "$($SoftwareName) already ends with .app" + if ($SoftwareName.EndsWith('.App')) { + $SoftwareName = $SoftwareName.Replace('.App', '.app') + } else { + $SoftwareName = "$SoftwareName.app" + } } if ($SoftwareVersion -and $SoftwareName -and $SystemID) { # Handle Special Characters @@ -136,9 +138,11 @@ function Get-JCSystemApp () { 'Darwin' { # If Software title, version, and system ID are passed then return specific app if (-not $SoftwareName.EndsWith('.app')) { - $SoftwareName = $SoftwareName + '.app' - } else { - Write-Debug "$($SoftwareName) already ends with .app" + if ($SoftwareName.EndsWith('.App')) { + $SoftwareName = $SoftwareName.Replace('.App', '.app') + } else { + $SoftwareName = "$SoftwareName.app" + } } if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { # Handle Special Characters @@ -184,56 +188,41 @@ function Get-JCSystemApp () { foreach ($os in @('MacOs', 'Windows', 'Linux')) { if ($os -eq 'MacOs') { if (-not $SoftwareName.EndsWith('.app')) { - $SoftwareName = $SoftwareName + '.app' - } else { - Write-Debug "$($SoftwareName) already ends with .app" + if ($SoftwareName.EndsWith('.App')) { + $SoftwareName = $SoftwareName.Replace('.App', '.app') + } else { + $SoftwareName = "$SoftwareName.app" + } } if ($SoftwareVersion -and $SoftwareName) { $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$softwareVersion" } else { $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName" } - - if ($Parallel) { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit - } - # If no results, skip to next OS - if ($resultsArray.count -eq 0) { - continue - } - $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - $resultsArrayList.Add($resultsArray) } elseif ($os -eq 'Windows') { if ($SoftwareVersion -and $SoftwareName) { $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName&filter=version:eq:$softwareVersion" } else { $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName" } - if ($Parallel) { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit - } - if ($resultsArray.count -eq 0) { continue } - $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - $resultsArrayList.Add($resultsArray) } elseif ($os -eq 'Linux') { if ($SoftwareVersion -and $SoftwareName) { $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName&filter=version:eq:$softwareVersion" } else { $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName" } - if ($Parallel) { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit - } - if ($resultsArray.count -eq 0) { continue } - $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - $resultsArrayList.Add($resultsArray) } + if ($Parallel) { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit + } + # If no results, skip to next OS + if ($resultsArray.count -eq 0) { + continue + } + $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + $resultsArrayList.Add($resultsArray) } } else { # Print all software From d8ac8d810f8bba9668032506774302c03d235ce4 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Thu, 26 Jan 2023 23:28:18 +0000 Subject: [PATCH 048/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index b8b00d035..0b07577ca 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.2.0.7549-202301262243 + 2.2.0.7560-202301262325 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud From a27cf70581df69dca814f81d3069ea7cb3359f64 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Fri, 27 Jan 2023 09:17:33 -0800 Subject: [PATCH 049/102] comments --- .../Public/Systems/Get-JCSystemApp.ps1 | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 87a645dca..6a9acd4cb 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -46,7 +46,6 @@ function Get-JCSystemApp () { if ($SystemId) { Write-Debug "SystemId" $OSType = Get-JCSystem -ID $SystemID | Select-Object -ExpandProperty osFamily - # Handle error for if Get-JCSystem returns nothing if ($OsType -eq 'MacOs') { $Ostype = 'Darwin' } switch ($OSType) { 'Windows' { @@ -120,7 +119,7 @@ function Get-JCSystemApp () { Write-Debug "OS: $SystemOs" switch ($OSType) { 'Windows' { - # If Software title, version, and system ID are passed then return specific app + # If Software title, version, and system OS are passed then return specific app if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) @@ -136,7 +135,7 @@ function Get-JCSystemApp () { Write-Debug $URL } 'Darwin' { - # If Software title, version, and system ID are passed then return specific app + # If Software title, version, and system OS are passed then return specific app if (-not $SoftwareName.EndsWith('.app')) { if ($SoftwareName.EndsWith('.App')) { $SoftwareName = $SoftwareName.Replace('.App', '.app') @@ -160,7 +159,7 @@ function Get-JCSystemApp () { Write-Debug $URL } 'Linux' { - # If Software title, version, and system ID are passed then return specific app + # If Software title, version, and system OS are passed then return specific app if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) @@ -182,9 +181,9 @@ function Get-JCSystemApp () { } else { $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit } - } elseif ($SoftwareName ) { + } elseif ($SoftwareName) { $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - # Foreach Mac, Windows, Linux + # Search each apps endpoint for software name foreach ($os in @('MacOs', 'Windows', 'Linux')) { if ($os -eq 'MacOs') { if (-not $SoftwareName.EndsWith('.app')) { @@ -225,7 +224,7 @@ function Get-JCSystemApp () { $resultsArrayList.Add($resultsArray) } } else { - # Print all software + # Default/All foreach ($os in @('programs', 'apps', 'linux_packages')) { $URL = "$JCUrlBasePath/api/v2/systeminsights/$os" if ($Parallel) { @@ -245,9 +244,8 @@ function Get-JCSystemApp () { } } Search { - # IF only software name and no system ID or OS or version + # Search for softwareName if ($SoftwareName -and $Search) { - # Check if other parameters are set if ($SoftwareVersion) { Write-Error 'You cannot specify a system ID or version when using -search for a software name' } elseif ($SystemId) { @@ -273,8 +271,6 @@ function Get-JCSystemApp () { } } } elseif ($SystemOS) { - # Get all the results if softwarename elseif softwarename and version - $applicationArray | ForEach-Object { $URL = "$JCUrlBasePath/api/v2/systeminsights/$_" Write-Verbose "Searching for $SoftwareName and $SystemOs in $_ " From 6f2b843bbc329cc82de58b7bae154749cb2c3f62 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Fri, 27 Jan 2023 17:24:35 +0000 Subject: [PATCH 050/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 917b446e9..9209c2453 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 1/26/2023 +# Generated on: 1/27/2023 # @{ From e4e34f30e9884e936a54f33d93b4477f79d6cbe3 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Fri, 27 Jan 2023 12:55:51 -0800 Subject: [PATCH 051/102] docs --- PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md | 1 + .../Public/Systems/Get-JCSystemApp.ps1 | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index e075d4bc2..09c12b770 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -67,6 +67,7 @@ Returns any 'jumpcloud-agent' software installed in all the os systems ### -Search Search for a specific application by from all systems in the org ex. (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") +THIS PARAMETER DOES NOT TAKE INPUT ```yaml Type: System.Management.Automation.SwitchParameter diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 6a9acd4cb..a366d6995 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -11,7 +11,7 @@ function Get-JCSystemApp () { [string]$SoftwareName, [Parameter(Mandatory = $false, HelpMessage = 'The version of the application you want to search for ex. (1.1.2)')][ValidateNotNullorEmpty()] [string]$SoftwareVersion, - [Parameter(Mandatory = $false, ParameterSetName = "Search", HelpMessage = 'Search for a specific application by from all systems in the org ex (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent")')] + [Parameter(Mandatory = $false, ParameterSetName = "Search", HelpMessage = 'Search for a specific application by from all systems in the org ex (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent"). THIS PARAMETER DOES NOT TAKE INPUT')] [switch]$Search, [Parameter(DontShow, Mandatory = $false, ParameterSetName = "All", HelpMessage = 'Search for a specific application by name from all systems in the org')] [switch]$Software @@ -188,15 +188,16 @@ function Get-JCSystemApp () { if ($os -eq 'MacOs') { if (-not $SoftwareName.EndsWith('.app')) { if ($SoftwareName.EndsWith('.App')) { - $SoftwareName = $SoftwareName.Replace('.App', '.app') + $MacSoftwareName = $SoftwareName + $MacSoftwareName = $MacSoftwareName.Replace('.App', '.app') } else { - $SoftwareName = "$SoftwareName.app" + $MacSoftwareName = "$MacSoftwareName.app" } } if ($SoftwareVersion -and $SoftwareName) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$softwareVersion" + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$MacSoftwareName&filter=bundle_short_version:eq:$softwareVersion" } else { - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName" + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$MacSoftwareName" } } elseif ($os -eq 'Windows') { if ($SoftwareVersion -and $SoftwareName) { From 3c555a0b641d7a739391ee2259d512ad3149f34c Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Fri, 27 Jan 2023 21:04:57 +0000 Subject: [PATCH 052/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index ba6b37a0c..f8bf10130 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] +Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index 45deb2b1f..92492607a 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -7066,7 +7066,7 @@ PS C:\> $BackupJcOrganizationResults.User Search - Search for a specific application by from all systems in the org ex. (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") + Search for a specific application by from all systems in the org ex. (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") THIS PARAMETER DOES NOT TAKE INPUT System.Management.Automation.SwitchParameter @@ -7133,7 +7133,7 @@ PS C:\> $BackupJcOrganizationResults.User Search - Search for a specific application by from all systems in the org ex. (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") + Search for a specific application by from all systems in the org ex. (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") THIS PARAMETER DOES NOT TAKE INPUT System.Management.Automation.SwitchParameter From 13071430710bae9941737be75f943b6d1daad3bb Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Fri, 27 Jan 2023 14:17:50 -0800 Subject: [PATCH 053/102] fixed errors --- .../Public/Systems/Get-JCSystemApp.ps1 | 63 ++++++++++--------- .../Public/Systems/Get-JCSystemApp.tests.ps1 | 11 ++-- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index a366d6995..2e0e7d3eb 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -47,6 +47,7 @@ function Get-JCSystemApp () { Write-Debug "SystemId" $OSType = Get-JCSystem -ID $SystemID | Select-Object -ExpandProperty osFamily if ($OsType -eq 'MacOs') { $Ostype = 'Darwin' } + if ($SystemOS) { Throw "SystemID and SystemOS cannot be used together" } switch ($OSType) { 'Windows' { # If Software title, version, and system ID are passed then return specific app @@ -67,24 +68,26 @@ function Get-JCSystemApp () { 'Darwin' { # If Software title, version, and system ID are passed then return specific app # If $softwareName does not have .app at the end then add it - if (-not $SoftwareName.EndsWith('.app')) { + if ((!$SoftwareName) -and (!$SystemOs) -and (!$SoftwareVersion)) { + # Add filter for system ID to $Search + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps" + } elseif (-not $SoftwareName.EndsWith('.app')) { if ($SoftwareName.EndsWith('.App')) { $SoftwareName = $SoftwareName.Replace('.App', '.app') } else { $SoftwareName = "$SoftwareName.app" } - } - if ($SoftwareVersion -and $SoftwareName -and $SystemID) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemId&filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion" - } elseif ($SoftwareName -and $SystemID) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" - } elseif ($SystemID) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=system_id:eq:$SystemID" + if ($SoftwareVersion -and $SoftwareName -and $SystemId) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion" + + } elseif ($SoftwareName -and $SystemId) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?&filter=name:eq:$SoftwareName" + } } Write-Debug $URL } @@ -115,7 +118,7 @@ function Get-JCSystemApp () { } elseif ($SystemOS) { $OSType = $SystemOS if ($OSType -eq 'MacOs') { $OSType = 'Darwin' } # OS Family for Mac is Darwin - + if ($SystemID) { Throw "SystemID and SystemOS cannot be used together" } Write-Debug "OS: $SystemOs" switch ($OSType) { 'Windows' { @@ -135,26 +138,27 @@ function Get-JCSystemApp () { Write-Debug $URL } 'Darwin' { - # If Software title, version, and system OS are passed then return specific app - if (-not $SoftwareName.EndsWith('.app')) { + # If Software title, version, and system OS are passed then return specific app and not null + if ((!$SoftwareName) -and (!$SystemId) -and (!$SoftwareVersion)) { + # Add filter for system ID to $Search + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps" + } elseif (-not $SoftwareName.EndsWith('.app')) { if ($SoftwareName.EndsWith('.App')) { $SoftwareName = $SoftwareName.Replace('.App', '.app') } else { $SoftwareName = "$SoftwareName.app" } - } - if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion" - } elseif ($SoftwareName -and $SystemOS) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?&filter=name:eq:$SoftwareName" - } elseif ($SystemOs) { - # Add filter for system ID to $Search - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps" + if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion" + + } elseif ($SoftwareName -and $SystemOS) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?&filter=name:eq:$SoftwareName" + } } Write-Debug $URL } @@ -248,9 +252,10 @@ function Get-JCSystemApp () { # Search for softwareName if ($SoftwareName -and $Search) { if ($SoftwareVersion) { - Write-Error 'You cannot specify a system ID or version when using -search for a software name' + Throw 'You cannot specify software version when using -search for a software name' } elseif ($SystemId) { $applicationArray | ForEach-Object { + $URL = "$JCUrlBasePath/api/v2/systeminsights/$_" Write-Verbose "Searching for $SoftwareName and $SystemId in $_ " if ($Parallel) { @@ -320,7 +325,7 @@ function Get-JCSystemApp () { } } else { - Write-Error "You must specify a software name and/or systemId when using -search" + Throw "You must specify a software name and/or systemId when using -search" } } diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index 03efcbcbf..f541a558f 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -110,10 +110,13 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { { Get-JCSystemApp -SystemID $windows._id | ConvertTo-Csv } | Should -Not -Throw { Get-JCSystemApp -SystemID $linux._id | ConvertTo-Csv } | Should -Not -Throw } - It "Tests macos functionatily to append .app to softwareTitles" { - Get-JCSystemApp -SystemID $mac._id -SoftwareTitle "chess.app" | Should -Not -BeNullOrEmpty - Get-JCSystemApp -SystemID $mac._id -SoftwareTitle "chess.App" | Should -Not -BeNullOrEmpty - Get-JCSystemApp -SystemID $mac._id -SoftwareTitle "chess" | Should -Not -BeNullOrEmpty + It "Tests macos functionatily to append .app to softwareName" { + Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess.app" | Should -Not -BeNullOrEmpty + Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess.App" | Should -Not -BeNullOrEmpty + Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" | Should -Not -BeNullOrEmpty + Get-JCSystemApp -SystemID $mac._id -SoftwareName "chess.app" -search | Should -Not -BeNullOrEmpty + Get-JCSystemApp -SystemID $mac._id -SoftwareName "chess.App" -search | Should -Not -BeNullOrEmpty + Get-JCSystemApp -SystemID $mac._id -SoftwareName "chess" -search | Should -Not -BeNullOrEmpty } } From 5f467c205f42fadf8d760f690dd7de81d7fe904d Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Fri, 27 Jan 2023 22:25:20 +0000 Subject: [PATCH 054/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index f8bf10130..ba6b37a0c 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] +Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index 0b07577ca..8dfbdd893 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.2.0.7560-202301262325 + 2.2.0.7597-202301272222 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud From 2daa874d0d582ad641e9dbdb8a178c52680ed740 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Mon, 30 Jan 2023 09:04:24 -0800 Subject: [PATCH 055/102] test fix --- .../Tests/Public/Systems/Get-JCSystemApp.tests.ps1 | 3 --- 1 file changed, 3 deletions(-) diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index f541a558f..b5d67c988 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -114,9 +114,6 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess.app" | Should -Not -BeNullOrEmpty Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess.App" | Should -Not -BeNullOrEmpty Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" | Should -Not -BeNullOrEmpty - Get-JCSystemApp -SystemID $mac._id -SoftwareName "chess.app" -search | Should -Not -BeNullOrEmpty - Get-JCSystemApp -SystemID $mac._id -SoftwareName "chess.App" -search | Should -Not -BeNullOrEmpty - Get-JCSystemApp -SystemID $mac._id -SoftwareName "chess" -search | Should -Not -BeNullOrEmpty } } From c5d2bfd883d0ce0f61e30cb76651557908879984 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 30 Jan 2023 17:12:49 +0000 Subject: [PATCH 056/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index ba6b37a0c..f8bf10130 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] +Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index 8dfbdd893..3721ccd40 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.2.0.7597-202301272222 + 2.2.0.7609-202301301710 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 9209c2453..6d58a5a95 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 1/27/2023 +# Generated on: 1/30/2023 # @{ From 329fc5f212ae80d9085cbbc53c7c0eff4f277366 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Mon, 30 Jan 2023 09:35:32 -0800 Subject: [PATCH 057/102] fixed tests --- .../Public/Systems/Get-JCSystemApp.ps1 | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 2e0e7d3eb..74cc2b6f5 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -71,13 +71,20 @@ function Get-JCSystemApp () { if ((!$SoftwareName) -and (!$SystemOs) -and (!$SoftwareVersion)) { # Add filter for system ID to $Search $URL = "$JCUrlBasePath/api/v2/systeminsights/apps" - } elseif (-not $SoftwareName.EndsWith('.app')) { - if ($SoftwareName.EndsWith('.App')) { - $SoftwareName = $SoftwareName.Replace('.App', '.app') + } + if ($SoftwareName) { + # Check for .app at the end of the software name + if (-not $SoftwareName.EndsWith('.app')) { + Write-Debug "Adding .app to $SoftwareName" + if ($SoftwareName.EndsWith('.App')) { + Write-Debug "Replacing .App with .app" + $SoftwareName = $SoftwareName.Replace('.App', '.app') + } else { + $SoftwareName = "$SoftwareName.app" + } } else { - $SoftwareName = "$SoftwareName.app" + Write-Debug "$SoftwareName already ends with .app" } - if ($SoftwareVersion -and $SoftwareName -and $SystemId) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) @@ -139,14 +146,21 @@ function Get-JCSystemApp () { } 'Darwin' { # If Software title, version, and system OS are passed then return specific app and not null - if ((!$SoftwareName) -and (!$SystemId) -and (!$SoftwareVersion)) { + if ((!$SoftwareName) -and (!$SoftwareVersion)) { # Add filter for system ID to $Search $URL = "$JCUrlBasePath/api/v2/systeminsights/apps" - } elseif (-not $SoftwareName.EndsWith('.app')) { - if ($SoftwareName.EndsWith('.App')) { - $SoftwareName = $SoftwareName.Replace('.App', '.app') + } + if ($SoftwareName) { + if (-not $SoftwareName.EndsWith('.app')) { + Write-Debug "Adding .app to $SoftwareName" + if ($SoftwareName.EndsWith('.App')) { + Write-Debug "Replacing .App with .app" + $SoftwareName = $SoftwareName.Replace('.App', '.app') + } else { + $SoftwareName = "$SoftwareName.app" + } } else { - $SoftwareName = "$SoftwareName.app" + Write-Debug "$SoftwareName already ends with .app" } if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { From 12f34a9d27a315746461cfc185ed18cc318a7c4f Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 30 Jan 2023 17:43:34 +0000 Subject: [PATCH 058/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index f8bf10130..ba6b37a0c 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] +Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index 3721ccd40..76c187a91 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.2.0.7609-202301301710 + 2.2.0.7621-202301301741 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud From 49086107e52933a2a56fe7eaf2d4a5dff53c0eb0 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 30 Jan 2023 17:51:23 +0000 Subject: [PATCH 059/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index ba6b37a0c..f8bf10130 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] +Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] ``` ## DESCRIPTION From 98e6cad86b894564ccf3c106ee7f0e0c243d2e40 Mon Sep 17 00:00:00 2001 From: Ken Maranion <97972790+kmaranionjc@users.noreply.github.com> Date: Mon, 30 Jan 2023 10:50:53 -0800 Subject: [PATCH 060/102] Update PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md [skip ci] Co-authored-by: Joe Workman <54448601+jworkmanjc@users.noreply.github.com> --- PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index 09c12b770..afd1836e0 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -100,7 +100,7 @@ Accept wildcard characters: False ### -SoftwareVersion The version of the application you want to search for ex. -(1.1.2) +1.1.2 ```yaml Type: System.String From 3eca3db0f629498e2592357a3405ea1c55cd91d8 Mon Sep 17 00:00:00 2001 From: Ken Maranion <97972790+kmaranionjc@users.noreply.github.com> Date: Mon, 30 Jan 2023 11:03:11 -0800 Subject: [PATCH 061/102] Update PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 [skip ci] Co-authored-by: Joe Workman <54448601+jworkmanjc@users.noreply.github.com> --- PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 74cc2b6f5..ea6de4620 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -4,7 +4,7 @@ function Get-JCSystemApp () { [Parameter(Mandatory = $false, HelpMessage = 'The System Id of the system you want to search for applications')][ValidateNotNullorEmpty()] [string]$SystemID, - [Parameter(Mandatory = $false , ValueFromPipelineByPropertyName, HelpMessage = 'The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, Mac, Linux))')] + [Parameter(Mandatory = $false , ValueFromPipelineByPropertyName, HelpMessage = 'The type (windows, macOS, linux) of the JumpCloud system you wish to search. Ex. (Windows, macOS, Linux))')] [ValidateSet('Windows', 'macOS', 'Linux')][ValidateNotNullorEmpty()] [string]$SystemOS, [Parameter(Mandatory = $false, HelpMessage = 'The name of the application you want to search for ex. (JumpCloud-Agent, Slack). SoftwareName will always query the "name" property from system insights. Note, for macOS systems, ".app" will be applied' )][ValidateNotNullorEmpty()] From 22c7783df98102810a7b000e3a0b62172ca21e4b Mon Sep 17 00:00:00 2001 From: Ken Maranion <97972790+kmaranionjc@users.noreply.github.com> Date: Mon, 30 Jan 2023 11:03:33 -0800 Subject: [PATCH 062/102] Update PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 [skip ci] Co-authored-by: Joe Workman <54448601+jworkmanjc@users.noreply.github.com> --- PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index ea6de4620..840d1e2f6 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -9,7 +9,7 @@ function Get-JCSystemApp () { [string]$SystemOS, [Parameter(Mandatory = $false, HelpMessage = 'The name of the application you want to search for ex. (JumpCloud-Agent, Slack). SoftwareName will always query the "name" property from system insights. Note, for macOS systems, ".app" will be applied' )][ValidateNotNullorEmpty()] [string]$SoftwareName, - [Parameter(Mandatory = $false, HelpMessage = 'The version of the application you want to search for ex. (1.1.2)')][ValidateNotNullorEmpty()] + [Parameter(Mandatory = $false, HelpMessage = 'The version of the application you want to search for ex. 1.1.2')][ValidateNotNullorEmpty()] [string]$SoftwareVersion, [Parameter(Mandatory = $false, ParameterSetName = "Search", HelpMessage = 'Search for a specific application by from all systems in the org ex (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent"). THIS PARAMETER DOES NOT TAKE INPUT')] [switch]$Search, From 4c5e16cac2c706bdaeb66b7fef45dcfef6cd7f74 Mon Sep 17 00:00:00 2001 From: Ken Maranion <97972790+kmaranionjc@users.noreply.github.com> Date: Mon, 30 Jan 2023 11:03:53 -0800 Subject: [PATCH 063/102] Update PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 [skip ci] Co-authored-by: Joe Workman <54448601+jworkmanjc@users.noreply.github.com> --- PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 840d1e2f6..aba0c2a02 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -7,7 +7,7 @@ function Get-JCSystemApp () { [Parameter(Mandatory = $false , ValueFromPipelineByPropertyName, HelpMessage = 'The type (windows, macOS, linux) of the JumpCloud system you wish to search. Ex. (Windows, macOS, Linux))')] [ValidateSet('Windows', 'macOS', 'Linux')][ValidateNotNullorEmpty()] [string]$SystemOS, - [Parameter(Mandatory = $false, HelpMessage = 'The name of the application you want to search for ex. (JumpCloud-Agent, Slack). SoftwareName will always query the "name" property from system insights. Note, for macOS systems, ".app" will be applied' )][ValidateNotNullorEmpty()] + [Parameter(Mandatory = $false, HelpMessage = 'The name of the application you want to search for ex. (JumpCloud-Agent, Slack). SoftwareName will always query the "name" property from system insights. Note, for macOS systems, ".app" will be applied. This field is case sensitive.' )][ValidateNotNullorEmpty()] [string]$SoftwareName, [Parameter(Mandatory = $false, HelpMessage = 'The version of the application you want to search for ex. 1.1.2')][ValidateNotNullorEmpty()] [string]$SoftwareVersion, From 9c4e16db0c8158d619ec4a6009ad4c42b19dfe29 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Mon, 30 Jan 2023 11:08:19 -0800 Subject: [PATCH 064/102] pr changes --- .../Public/Systems/Get-JCSystemApp.ps1 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 74cc2b6f5..3ce3720f6 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -11,10 +11,10 @@ function Get-JCSystemApp () { [string]$SoftwareName, [Parameter(Mandatory = $false, HelpMessage = 'The version of the application you want to search for ex. (1.1.2)')][ValidateNotNullorEmpty()] [string]$SoftwareVersion, - [Parameter(Mandatory = $false, ParameterSetName = "Search", HelpMessage = 'Search for a specific application by from all systems in the org ex (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent"). THIS PARAMETER DOES NOT TAKE INPUT')] + [Parameter(Mandatory = $false, ParameterSetName = "Search", HelpMessage = "The Search parameter can be used in conjunction with the 'SoftwareName' parameter to perform a case-insensitive search for software. This is parameter switch is inherently slower than using just the 'softwareName' parameter but can be useful to identify the names of software titles on systems. If the exact name of a software title isn't known, the 'search' parameter can be used to find that name. Ex. Get-JCSoftwareApp -SystemID '63c9654cb357249876bfc05b' -SoftwareName 'chrome' -Search will attempt to perform a match for the term 'chrome' on all applications/ programs for the specified system. If a match, partial-match, case-insensitive match is found, it would be returned in the results. In this case, the 'name' of the software title is 'Google Chrome'. A subsequent search could be run to return all macOS systems which have 'Google Chrome' installed. Ex. Get-JCSystemApp -SystemOS macOS -softwareName 'Google Chrome', this would perform an exact match search for macOS systems that have google chrome which is substantially quicker than running: Get-JCSystemApp -SystemOS macOS -softwareName 'google chrome' -Search. The search parameter is a tool to help identify the 'name' attribute of software titles when searching bulk systems its recommended to not use the search parameter and instead specify the exact (case sensitive) name of the software title.")] [switch]$Search, [Parameter(DontShow, Mandatory = $false, ParameterSetName = "All", HelpMessage = 'Search for a specific application by name from all systems in the org')] - [switch]$Software + [switch]$SearchAllSystems ) begin { @@ -46,7 +46,6 @@ function Get-JCSystemApp () { if ($SystemId) { Write-Debug "SystemId" $OSType = Get-JCSystem -ID $SystemID | Select-Object -ExpandProperty osFamily - if ($OsType -eq 'MacOs') { $Ostype = 'Darwin' } if ($SystemOS) { Throw "SystemID and SystemOS cannot be used together" } switch ($OSType) { 'Windows' { @@ -88,12 +87,12 @@ function Get-JCSystemApp () { if ($SoftwareVersion -and $SoftwareName -and $SystemId) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion" + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion&filter=system_id:eq:$SystemID" } elseif ($SoftwareName -and $SystemId) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?&filter=name:eq:$SoftwareName" + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?&filter=name:eq:$SoftwareName&filter=system_id:eq:$SystemID" } } Write-Debug $URL @@ -264,7 +263,7 @@ function Get-JCSystemApp () { } Search { # Search for softwareName - if ($SoftwareName -and $Search) { + if ($SoftwareName) { if ($SoftwareVersion) { Throw 'You cannot specify software version when using -search for a software name' } elseif ($SystemId) { @@ -331,7 +330,7 @@ function Get-JCSystemApp () { } $searchAppResultsList | ForEach-Object { - $results = $_ | Where-Object { ($_.name -match $SoftwareName) -and ($_.osFamily -match $SystemOs) } + $results = $_ | Where-Object { ($_.name -match $SoftwareName) } $results | ForEach-Object { $resultsArrayList.Add($_) } From 37e657afd53879936608ad933ecacf927747fd88 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 30 Jan 2023 19:16:12 +0000 Subject: [PATCH 065/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index 92492607a..13fdc2ffa 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -7089,7 +7089,7 @@ PS C:\> $BackupJcOrganizationResults.User SoftwareVersion - The version of the application you want to search for ex. (1.1.2) + The version of the application you want to search for ex. 1.1.2 System.String @@ -7157,7 +7157,7 @@ PS C:\> $BackupJcOrganizationResults.User SoftwareVersion - The version of the application you want to search for ex. (1.1.2) + The version of the application you want to search for ex. 1.1.2 System.String From cbdcfa55639e69fe22a2a5c338190373619fc9fb Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Tue, 31 Jan 2023 14:13:20 -0800 Subject: [PATCH 066/102] Replaced IWR to SDK --- .../Public/Systems/Get-JCSystemApp.ps1 | 423 +++++++++--------- .../Public/Systems/Get-JCSystemApp.tests.ps1 | 6 +- 2 files changed, 215 insertions(+), 214 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 1fbd2398f..01b5f04dd 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -22,15 +22,11 @@ function Get-JCSystemApp () { if ($JCAPIKEY.length -ne 40) { Connect-JCOnline } - $Parallel = $JCConfig.parallel.Calculated $searchAppResultsList = New-Object -TypeName System.Collections.ArrayList - if ($Parallel) { - Write-Verbose 'Initilizing resultsArray' - $resultsArrayList = [System.Collections.Concurrent.ConcurrentBag[object]]::new() - } else { - Write-Verbose 'Initilizing resultsArray' - $resultsArrayList = New-Object -TypeName System.Collections.ArrayList - } + + Write-Verbose 'Initilizing resultsArray' + $resultsArrayList = New-Object -TypeName System.Collections.ArrayList + Write-Verbose "Parameter Set: $($PSCmdlet.ParameterSetName)" } process { @@ -43,34 +39,67 @@ function Get-JCSystemApp () { switch ($PSCmdlet.ParameterSetName) { All { - if ($SystemId) { - Write-Debug "SystemId" - $OSType = Get-JCSystem -ID $SystemID | Select-Object -ExpandProperty osFamily - if ($SystemOS) { Throw "SystemID and SystemOS cannot be used together" } + if ($SystemId -or $SystemOS) { + if ($SystemID -and $SystemOS) { + Throw "Cannot specify both SystemID and SystemOS" + } + + if ($SystemID) { + $OSType = Get-JcSdkSystem -ID $SystemID | Select-Object -ExpandProperty OSFamily + } else { + $OSType = $SystemOS + if ($OSType -eq 'macOS') { + $OSType = 'Darwin' + } + } + Write-Debug "OSType: $OSType" switch ($OSType) { 'Windows' { # If Software title, version, and system ID are passed then return specific app - if ($SoftwareVersion -and $SoftwareName -and $SystemID) { + if ($SoftwareVersion -and $SoftwareName) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemId&filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" - - } elseif ($SoftwareName -and $SystemID) { + if ($SystemID) { + Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($SystemOS) { + Get-JcSdkSystemInsightProgram -Filter @("name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } + } elseif ($SoftwareName) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" + if ($SystemID) { + Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($SystemOS) { + Get-JcSdkSystemInsightProgram -Filter @("name:eq:$SoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } } elseif ($SystemID) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID" + if ($SoftwareVersion) { + Write-Error "Cannot search for software version on Windows without software name." + } else { + Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } + } elseif ($SystemOS) { + if ($SoftwareVersion) { + Write-Error "Cannot search for software version on Windows without software name." + } else { + Get-JcSdkSystemInsightProgram | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } } - Write-Debug $URL } 'Darwin' { - # If Software title, version, and system ID are passed then return specific app - # If $softwareName does not have .app at the end then add it - if ((!$SoftwareName) -and (!$SystemOs) -and (!$SoftwareVersion)) { - # Add filter for system ID to $Search - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps" - } + if ($SoftwareName) { # Check for .app at the end of the software name if (-not $SoftwareName.EndsWith('.app')) { @@ -84,255 +113,229 @@ function Get-JCSystemApp () { } else { Write-Debug "$SoftwareName already ends with .app" } - if ($SoftwareVersion -and $SoftwareName -and $SystemId) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion&filter=system_id:eq:$SystemID" - - } elseif ($SoftwareName -and $SystemId) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?&filter=name:eq:$SoftwareName&filter=system_id:eq:$SystemID" - } } - Write-Debug $URL - } - 'Linux' { - # If Software title, version and system ID are passed then return specific app - if ($SoftwareVersion -and $SoftwareName -and $SystemID) { + + # If Software title, version, and system ID are passed then return specific app + if ($SoftwareVersion -and $SoftwareName) { # Handle Special Characters + Write-Debug "Trying to get app with name $SoftwareName and version $SoftwareVersion" $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemId&filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion&filter=system_id:eq:$SystemID" + if ($SystemID) { - } elseif ($SoftwareName -and $SystemID) { + Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName", "bundle_short_version:eq:$SoftwareVersion") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($SystemOS) { + Get-JcSdkSystemInsightApp -Filter @("name:eq:$SoftwareName", "bundle_short_version:eq:$SoftwareVersion") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } + } elseif ($SoftwareName) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" + if ($SystemID) { + Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($SystemOS) { + Get-JcSdkSystemInsightApp -Filter @("name:eq:$SoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } } elseif ($SystemID) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID" + if ($SoftwareVersion) { + Write-Error "Cannot search for software version on MacOs without software name." + } else { + Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } + } elseif ($SystemOS) { + if ($SoftwareVersion) { + Write-Error "Cannot search for software version on MacOs without software name." + } else { + Get-JcSdkSystemInsightApp | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } } - Write-Debug $URL - } - } - if ($Parallel) { - $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit - } + } + 'Linux' { - } elseif ($SystemOS) { - $OSType = $SystemOS - if ($OSType -eq 'MacOs') { $OSType = 'Darwin' } # OS Family for Mac is Darwin - if ($SystemID) { Throw "SystemID and SystemOS cannot be used together" } - Write-Debug "OS: $SystemOs" - switch ($OSType) { - 'Windows' { - # If Software title, version, and system OS are passed then return specific app - if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { + if ($SoftwareVersion -and $SoftwareName) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" - - } elseif ($SoftwareName -and $SystemOS) { + if ($SystemID) { + Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($SystemOS) { + Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } + } elseif ($SoftwareName) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName" - } elseif ($SystemOs) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs" - } - Write-Debug $URL - } - 'Darwin' { - # If Software title, version, and system OS are passed then return specific app and not null - if ((!$SoftwareName) -and (!$SoftwareVersion)) { - # Add filter for system ID to $Search - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps" - } - if ($SoftwareName) { - if (-not $SoftwareName.EndsWith('.app')) { - Write-Debug "Adding .app to $SoftwareName" - if ($SoftwareName.EndsWith('.App')) { - Write-Debug "Replacing .App with .app" - $SoftwareName = $SoftwareName.Replace('.App', '.app') - } else { - $SoftwareName = "$SoftwareName.app" + if ($SystemID) { + Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($SystemOS) { + Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$SoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) } + } + } elseif ($SystemID) { + if ($SoftwareVersion) { + Write-Error "Cannot search for software version on Linux without software name." } else { - Write-Debug "$SoftwareName already ends with .app" + Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } } - if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion" - - } elseif ($SoftwareName -and $SystemOS) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?&filter=name:eq:$SoftwareName" + } elseif ($SystemOS) { + if ($SoftwareVersion) { + Write-Error "Cannot search for software version on Linux without software name." + } else { + Get-JcSdkSystemInsightLinuxPackage | ForEach-Object { + [void]$resultsArrayList.Add($_) + } } } - Write-Debug $URL - } - 'Linux' { - # If Software title, version, and system OS are passed then return specific app - if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" - - } elseif ($SoftwareName -and $SystemOS) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName" - } elseif ($SystemOs) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages" - } - Write-Debug $URL } } - if ($Parallel) { - $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit - } } elseif ($SoftwareName) { - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - # Search each apps endpoint for software name - foreach ($os in @('MacOs', 'Windows', 'Linux')) { - if ($os -eq 'MacOs') { + # Loop through each OS and get the results + Write-Debug "SoftwareName" + foreach ($os in @('Windows', 'MacOs', 'Linux')) { + if ($os -eq 'Windows') { + Get-JcSdkSystemInsightProgram -Filter @("name:eq:$SoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($os -eq 'MacOs') { if (-not $SoftwareName.EndsWith('.app')) { + Write-Debug "Adding .app to $SoftwareName" if ($SoftwareName.EndsWith('.App')) { - $MacSoftwareName = $SoftwareName - $MacSoftwareName = $MacSoftwareName.Replace('.App', '.app') + Write-Debug "Replacing .App with .app" + $SoftwareName = $SoftwareName.Replace('.App', '.app') } else { - $MacSoftwareName = "$MacSoftwareName.app" + $SoftwareName = "$SoftwareName.app" } - } - if ($SoftwareVersion -and $SoftwareName) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$MacSoftwareName&filter=bundle_short_version:eq:$softwareVersion" } else { - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$MacSoftwareName" + Write-Debug "$SoftwareName already ends with .app" } - } elseif ($os -eq 'Windows') { - if ($SoftwareVersion -and $SoftwareName) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName&filter=version:eq:$softwareVersion" - } else { - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName" + Get-JcSdkSystemInsightApp -Filter @("name:eq:$SoftwareName") | ForEach-Object { + + [void]$resultsArrayList.Add($_) } } elseif ($os -eq 'Linux') { - if ($SoftwareVersion -and $SoftwareName) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName&filter=version:eq:$softwareVersion" - } else { - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName" + Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$SoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) } } - if ($Parallel) { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit - } - # If no results, skip to next OS - if ($resultsArray.count -eq 0) { - continue - } - $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - $resultsArrayList.Add($resultsArray) } - } else { + } + + else { # Default/All - foreach ($os in @('programs', 'apps', 'linux_packages')) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/$os" - if ($Parallel) { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit + Write-Debug "Test All" + #TODO: Parallelize this + foreach ($os in @('Windows', 'MacOs', 'Linux')) { + if ($os -eq 'Windows') { + Get-JcSdkSystemInsightProgram | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($os -eq 'MacOs') { + Get-JcSdkSystemInsightApp | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($os -eq 'Linux') { + Get-JcSdkSystemInsightLinuxPackage | ForEach-Object { + [void]$resultsArrayList.Add($_) + } } - if ($resultsArray.count -eq 0) { continue } - # Add OS Family to results - if ($os -eq 'programs') { $os = 'Windows' } - elseif ($os -eq 'apps') { $os = 'MacOs' } - elseif ($os -eq 'linux_packages') { $os = 'Linux' } - $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - $resultsArrayList.Add($resultsArray) } } - } Search { # Search for softwareName + Write-Debug "Search $SoftwareName" if ($SoftwareName) { if ($SoftwareVersion) { Throw 'You cannot specify software version when using -search for a software name' } elseif ($SystemId) { - $applicationArray | ForEach-Object { - - $URL = "$JCUrlBasePath/api/v2/systeminsights/$_" - Write-Verbose "Searching for $SoftwareName and $SystemId in $_ " - if ($Parallel) { - $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit + $OSType = Get-JcSdkSystem -ID $SystemID | Select-Object -ExpandProperty OSFamily + $OSType + if ($OSType -eq 'Windows') { + Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID") | ForEach-Object { + [void]$searchAppResultsList.Add($_) + } + } elseif ($OSType -eq 'Darwin') { + Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID") | ForEach-Object { + [void]$searchAppResultsList.Add($_) + } + } elseif ($OSType -eq 'Linux') { + Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID") | ForEach-Object { + [void]$searchAppResultsList.Add($_) } - # Add OS Family to results - if ($_ -eq 'programs') { $os = 'Windows' } - elseif ($_ -eq 'apps') { $os = 'MacOs' } - elseif ($_ -eq 'linux_packages') { $os = 'Linux' } - $searchAppResults | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - [void]$searchAppResultsList.Add($searchAppResults) } + $searchAppResultsList.Count + $searchAppResultsList | ForEach-Object { - $results = $_ | Where-Object { ($_.name -match $SoftwareName) -and ($_.System_id -match $SystemId) } + $results = $_ | Where-Object { ($_.name -match $SoftwareName) } $results | ForEach-Object { - $resultsArrayList.Add($_) + [void]$resultsArrayList.Add($_) } } } elseif ($SystemOS) { - $applicationArray | ForEach-Object { - $URL = "$JCUrlBasePath/api/v2/systeminsights/$_" - Write-Verbose "Searching for $SoftwareName and $SystemOs in $_ " - if ($Parallel) { - $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit + Write-Debug "SystemOS $SystemOS" + if ($SystemOS -eq 'Windows') { + Get-JcSdkSystemInsightProgram | ForEach-Object { + [void]$searchAppResultsList.Add($_) + } + } elseif ($SystemOS -eq 'MacOs') { + Get-JcSdkSystemInsightApp | ForEach-Object { + [void]$searchAppResultsList.Add($_) + } + } elseif ($SystemOS -eq 'Linux') { + Get-JcSdkSystemInsightLinuxPackage | ForEach-Object { + [void]$searchAppResultsList.Add($_) } - # Add OS Family to results - if ($_ -eq 'programs') { $os = 'Windows' } - elseif ($_ -eq 'apps') { $os = 'MacOs' } - elseif ($_ -eq 'linux_packages') { $os = 'Linux' } - $searchAppResults | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - [void]$searchAppResultsList.Add($searchAppResults) } $searchAppResultsList | ForEach-Object { - $results = $_ | Where-Object { ($_.name -match $SoftwareName) -and ($_.osFamily -match $SystemOs) } + $results = $_ | Where-Object { ($_.name -match $SoftwareName) } $results | ForEach-Object { - $resultsArrayList.Add($_) + [void]$resultsArrayList.Add($_) } } } else { + Write-Debug "Test All" # Get all the results with only softwarename - $applicationArray | ForEach-Object { - $URL = "$JCUrlBasePath/api/v2/systeminsights/$_" - Write-Verbose "Searching for $SoftwareName in $_ " - if ($Parallel) { - $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit + # Loop through each OS and get the results + foreach ($os in @('Windows', 'MacOs', 'Linux')) { + if ($os -eq 'Windows') { + Get-JcSdkSystemInsightProgram | ForEach-Object { + [void]$searchAppResultsList.Add($_) + } + } elseif ($os -eq 'MacOs') { + Get-JcSdkSystemInsightApp | ForEach-Object { + [void]$searchAppResultsList.Add($_) + } + } elseif ($os -eq 'Linux') { + Get-JcSdkSystemInsightLinuxPackage | ForEach-Object { + [void]$searchAppResultsList.Add($_) + } } - # Add OS Family to results - if ($_ -eq 'programs') { $os = 'Windows' } - elseif ($_ -eq 'apps') { $os = 'MacOs' } - elseif ($_ -eq 'linux_packages') { $os = 'Linux' } - $searchAppResults | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - [void]$searchAppResultsList.Add($searchAppResults) - } + $searchAppResultsList | ForEach-Object { $results = $_ | Where-Object { ($_.name -match $SoftwareName) } $results | ForEach-Object { - $resultsArrayList.Add($_) + [void]$resultsArrayList.Add($_) } } } @@ -343,7 +346,6 @@ function Get-JCSystemApp () { } } - } end { switch ($PSCmdlet.ParameterSetName) { @@ -355,5 +357,4 @@ function Get-JCSystemApp () { } } } -} - +} \ No newline at end of file diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index b5d67c988..f9600f803 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -32,7 +32,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests that given a systemID, SoftwareName, SoftwareVersion, an app is returned" { # Chess is always installed on MacOS and it CAN NOT be removed no matter what $ChessApp = Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" - Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion $ChessApp.Bundle_short_version + { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion $ChessApp.Bundle_short_version } | Should -Throw # A null value version shouldn't be accepted { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion "" } | Should -Throw # A null value Name shouldn't be accepted @@ -66,13 +66,13 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests the search param with systemID" { $apps = Get-JCSystemApp -Systemid $mac._id -SoftwareName "a" -search - $foundSystems = $apps.system_id | Select-Object -Unique + $foundSystems = $apps.systemid | Select-Object -Unique # if you specify a systemID and Search, results should not contain multiple systems $foundSystems.count | should -Be 1 } It "Tests the search param with SystemOS" { $apps = Get-JCSystemApp -SystemOS "macos" -SoftwareName "a" -search - $foundSystems = $apps.system_id | Select-Object -Unique + $foundSystems = $apps.systemid | Select-Object -Unique # if you specify a systemOS and Search, results should not contain multiple systems foreach ($system in $foundSystems) { $foundSystem = Get-JCSystem -SystemID $system From 42b23a50ef1c0797c0c2f761012496e5723bb468 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Tue, 31 Jan 2023 15:02:43 -0800 Subject: [PATCH 067/102] Replaced IWR to SDK --- .../Public/Systems/Get-JCSystemApp.ps1 | 423 +++++++++--------- .../Public/Systems/Get-JCSystemApp.tests.ps1 | 6 +- 2 files changed, 215 insertions(+), 214 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 1fbd2398f..01b5f04dd 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -22,15 +22,11 @@ function Get-JCSystemApp () { if ($JCAPIKEY.length -ne 40) { Connect-JCOnline } - $Parallel = $JCConfig.parallel.Calculated $searchAppResultsList = New-Object -TypeName System.Collections.ArrayList - if ($Parallel) { - Write-Verbose 'Initilizing resultsArray' - $resultsArrayList = [System.Collections.Concurrent.ConcurrentBag[object]]::new() - } else { - Write-Verbose 'Initilizing resultsArray' - $resultsArrayList = New-Object -TypeName System.Collections.ArrayList - } + + Write-Verbose 'Initilizing resultsArray' + $resultsArrayList = New-Object -TypeName System.Collections.ArrayList + Write-Verbose "Parameter Set: $($PSCmdlet.ParameterSetName)" } process { @@ -43,34 +39,67 @@ function Get-JCSystemApp () { switch ($PSCmdlet.ParameterSetName) { All { - if ($SystemId) { - Write-Debug "SystemId" - $OSType = Get-JCSystem -ID $SystemID | Select-Object -ExpandProperty osFamily - if ($SystemOS) { Throw "SystemID and SystemOS cannot be used together" } + if ($SystemId -or $SystemOS) { + if ($SystemID -and $SystemOS) { + Throw "Cannot specify both SystemID and SystemOS" + } + + if ($SystemID) { + $OSType = Get-JcSdkSystem -ID $SystemID | Select-Object -ExpandProperty OSFamily + } else { + $OSType = $SystemOS + if ($OSType -eq 'macOS') { + $OSType = 'Darwin' + } + } + Write-Debug "OSType: $OSType" switch ($OSType) { 'Windows' { # If Software title, version, and system ID are passed then return specific app - if ($SoftwareVersion -and $SoftwareName -and $SystemID) { + if ($SoftwareVersion -and $SoftwareName) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemId&filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" - - } elseif ($SoftwareName -and $SystemID) { + if ($SystemID) { + Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($SystemOS) { + Get-JcSdkSystemInsightProgram -Filter @("name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } + } elseif ($SoftwareName) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" + if ($SystemID) { + Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($SystemOS) { + Get-JcSdkSystemInsightProgram -Filter @("name:eq:$SoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } } elseif ($SystemID) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID" + if ($SoftwareVersion) { + Write-Error "Cannot search for software version on Windows without software name." + } else { + Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } + } elseif ($SystemOS) { + if ($SoftwareVersion) { + Write-Error "Cannot search for software version on Windows without software name." + } else { + Get-JcSdkSystemInsightProgram | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } } - Write-Debug $URL } 'Darwin' { - # If Software title, version, and system ID are passed then return specific app - # If $softwareName does not have .app at the end then add it - if ((!$SoftwareName) -and (!$SystemOs) -and (!$SoftwareVersion)) { - # Add filter for system ID to $Search - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps" - } + if ($SoftwareName) { # Check for .app at the end of the software name if (-not $SoftwareName.EndsWith('.app')) { @@ -84,255 +113,229 @@ function Get-JCSystemApp () { } else { Write-Debug "$SoftwareName already ends with .app" } - if ($SoftwareVersion -and $SoftwareName -and $SystemId) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion&filter=system_id:eq:$SystemID" - - } elseif ($SoftwareName -and $SystemId) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?&filter=name:eq:$SoftwareName&filter=system_id:eq:$SystemID" - } } - Write-Debug $URL - } - 'Linux' { - # If Software title, version and system ID are passed then return specific app - if ($SoftwareVersion -and $SoftwareName -and $SystemID) { + + # If Software title, version, and system ID are passed then return specific app + if ($SoftwareVersion -and $SoftwareName) { # Handle Special Characters + Write-Debug "Trying to get app with name $SoftwareName and version $SoftwareVersion" $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemId&filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion&filter=system_id:eq:$SystemID" + if ($SystemID) { - } elseif ($SoftwareName -and $SystemID) { + Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName", "bundle_short_version:eq:$SoftwareVersion") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($SystemOS) { + Get-JcSdkSystemInsightApp -Filter @("name:eq:$SoftwareName", "bundle_short_version:eq:$SoftwareVersion") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } + } elseif ($SoftwareName) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" + if ($SystemID) { + Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($SystemOS) { + Get-JcSdkSystemInsightApp -Filter @("name:eq:$SoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } } elseif ($SystemID) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID" + if ($SoftwareVersion) { + Write-Error "Cannot search for software version on MacOs without software name." + } else { + Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } + } elseif ($SystemOS) { + if ($SoftwareVersion) { + Write-Error "Cannot search for software version on MacOs without software name." + } else { + Get-JcSdkSystemInsightApp | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } } - Write-Debug $URL - } - } - if ($Parallel) { - $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit - } + } + 'Linux' { - } elseif ($SystemOS) { - $OSType = $SystemOS - if ($OSType -eq 'MacOs') { $OSType = 'Darwin' } # OS Family for Mac is Darwin - if ($SystemID) { Throw "SystemID and SystemOS cannot be used together" } - Write-Debug "OS: $SystemOs" - switch ($OSType) { - 'Windows' { - # If Software title, version, and system OS are passed then return specific app - if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { + if ($SoftwareVersion -and $SoftwareName) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" - - } elseif ($SoftwareName -and $SystemOS) { + if ($SystemID) { + Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($SystemOS) { + Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } + } elseif ($SoftwareName) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName" - } elseif ($SystemOs) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs" - } - Write-Debug $URL - } - 'Darwin' { - # If Software title, version, and system OS are passed then return specific app and not null - if ((!$SoftwareName) -and (!$SoftwareVersion)) { - # Add filter for system ID to $Search - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps" - } - if ($SoftwareName) { - if (-not $SoftwareName.EndsWith('.app')) { - Write-Debug "Adding .app to $SoftwareName" - if ($SoftwareName.EndsWith('.App')) { - Write-Debug "Replacing .App with .app" - $SoftwareName = $SoftwareName.Replace('.App', '.app') - } else { - $SoftwareName = "$SoftwareName.app" + if ($SystemID) { + Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($SystemOS) { + Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$SoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) } + } + } elseif ($SystemID) { + if ($SoftwareVersion) { + Write-Error "Cannot search for software version on Linux without software name." } else { - Write-Debug "$SoftwareName already ends with .app" + Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } } - if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion" - - } elseif ($SoftwareName -and $SystemOS) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?&filter=name:eq:$SoftwareName" + } elseif ($SystemOS) { + if ($SoftwareVersion) { + Write-Error "Cannot search for software version on Linux without software name." + } else { + Get-JcSdkSystemInsightLinuxPackage | ForEach-Object { + [void]$resultsArrayList.Add($_) + } } } - Write-Debug $URL - } - 'Linux' { - # If Software title, version, and system OS are passed then return specific app - if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" - - } elseif ($SoftwareName -and $SystemOS) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName" - } elseif ($SystemOs) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages" - } - Write-Debug $URL } } - if ($Parallel) { - $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit - } } elseif ($SoftwareName) { - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - # Search each apps endpoint for software name - foreach ($os in @('MacOs', 'Windows', 'Linux')) { - if ($os -eq 'MacOs') { + # Loop through each OS and get the results + Write-Debug "SoftwareName" + foreach ($os in @('Windows', 'MacOs', 'Linux')) { + if ($os -eq 'Windows') { + Get-JcSdkSystemInsightProgram -Filter @("name:eq:$SoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($os -eq 'MacOs') { if (-not $SoftwareName.EndsWith('.app')) { + Write-Debug "Adding .app to $SoftwareName" if ($SoftwareName.EndsWith('.App')) { - $MacSoftwareName = $SoftwareName - $MacSoftwareName = $MacSoftwareName.Replace('.App', '.app') + Write-Debug "Replacing .App with .app" + $SoftwareName = $SoftwareName.Replace('.App', '.app') } else { - $MacSoftwareName = "$MacSoftwareName.app" + $SoftwareName = "$SoftwareName.app" } - } - if ($SoftwareVersion -and $SoftwareName) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$MacSoftwareName&filter=bundle_short_version:eq:$softwareVersion" } else { - $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$MacSoftwareName" + Write-Debug "$SoftwareName already ends with .app" } - } elseif ($os -eq 'Windows') { - if ($SoftwareVersion -and $SoftwareName) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName&filter=version:eq:$softwareVersion" - } else { - $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName" + Get-JcSdkSystemInsightApp -Filter @("name:eq:$SoftwareName") | ForEach-Object { + + [void]$resultsArrayList.Add($_) } } elseif ($os -eq 'Linux') { - if ($SoftwareVersion -and $SoftwareName) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName&filter=version:eq:$softwareVersion" - } else { - $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName" + Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$SoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) } } - if ($Parallel) { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit - } - # If no results, skip to next OS - if ($resultsArray.count -eq 0) { - continue - } - $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - $resultsArrayList.Add($resultsArray) } - } else { + } + + else { # Default/All - foreach ($os in @('programs', 'apps', 'linux_packages')) { - $URL = "$JCUrlBasePath/api/v2/systeminsights/$os" - if ($Parallel) { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit + Write-Debug "Test All" + #TODO: Parallelize this + foreach ($os in @('Windows', 'MacOs', 'Linux')) { + if ($os -eq 'Windows') { + Get-JcSdkSystemInsightProgram | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($os -eq 'MacOs') { + Get-JcSdkSystemInsightApp | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } elseif ($os -eq 'Linux') { + Get-JcSdkSystemInsightLinuxPackage | ForEach-Object { + [void]$resultsArrayList.Add($_) + } } - if ($resultsArray.count -eq 0) { continue } - # Add OS Family to results - if ($os -eq 'programs') { $os = 'Windows' } - elseif ($os -eq 'apps') { $os = 'MacOs' } - elseif ($os -eq 'linux_packages') { $os = 'Linux' } - $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - $resultsArrayList.Add($resultsArray) } } - } Search { # Search for softwareName + Write-Debug "Search $SoftwareName" if ($SoftwareName) { if ($SoftwareVersion) { Throw 'You cannot specify software version when using -search for a software name' } elseif ($SystemId) { - $applicationArray | ForEach-Object { - - $URL = "$JCUrlBasePath/api/v2/systeminsights/$_" - Write-Verbose "Searching for $SoftwareName and $SystemId in $_ " - if ($Parallel) { - $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit + $OSType = Get-JcSdkSystem -ID $SystemID | Select-Object -ExpandProperty OSFamily + $OSType + if ($OSType -eq 'Windows') { + Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID") | ForEach-Object { + [void]$searchAppResultsList.Add($_) + } + } elseif ($OSType -eq 'Darwin') { + Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID") | ForEach-Object { + [void]$searchAppResultsList.Add($_) + } + } elseif ($OSType -eq 'Linux') { + Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID") | ForEach-Object { + [void]$searchAppResultsList.Add($_) } - # Add OS Family to results - if ($_ -eq 'programs') { $os = 'Windows' } - elseif ($_ -eq 'apps') { $os = 'MacOs' } - elseif ($_ -eq 'linux_packages') { $os = 'Linux' } - $searchAppResults | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - [void]$searchAppResultsList.Add($searchAppResults) } + $searchAppResultsList.Count + $searchAppResultsList | ForEach-Object { - $results = $_ | Where-Object { ($_.name -match $SoftwareName) -and ($_.System_id -match $SystemId) } + $results = $_ | Where-Object { ($_.name -match $SoftwareName) } $results | ForEach-Object { - $resultsArrayList.Add($_) + [void]$resultsArrayList.Add($_) } } } elseif ($SystemOS) { - $applicationArray | ForEach-Object { - $URL = "$JCUrlBasePath/api/v2/systeminsights/$_" - Write-Verbose "Searching for $SoftwareName and $SystemOs in $_ " - if ($Parallel) { - $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit + Write-Debug "SystemOS $SystemOS" + if ($SystemOS -eq 'Windows') { + Get-JcSdkSystemInsightProgram | ForEach-Object { + [void]$searchAppResultsList.Add($_) + } + } elseif ($SystemOS -eq 'MacOs') { + Get-JcSdkSystemInsightApp | ForEach-Object { + [void]$searchAppResultsList.Add($_) + } + } elseif ($SystemOS -eq 'Linux') { + Get-JcSdkSystemInsightLinuxPackage | ForEach-Object { + [void]$searchAppResultsList.Add($_) } - # Add OS Family to results - if ($_ -eq 'programs') { $os = 'Windows' } - elseif ($_ -eq 'apps') { $os = 'MacOs' } - elseif ($_ -eq 'linux_packages') { $os = 'Linux' } - $searchAppResults | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - [void]$searchAppResultsList.Add($searchAppResults) } $searchAppResultsList | ForEach-Object { - $results = $_ | Where-Object { ($_.name -match $SoftwareName) -and ($_.osFamily -match $SystemOs) } + $results = $_ | Where-Object { ($_.name -match $SoftwareName) } $results | ForEach-Object { - $resultsArrayList.Add($_) + [void]$resultsArrayList.Add($_) } } } else { + Write-Debug "Test All" # Get all the results with only softwarename - $applicationArray | ForEach-Object { - $URL = "$JCUrlBasePath/api/v2/systeminsights/$_" - Write-Verbose "Searching for $SoftwareName in $_ " - if ($Parallel) { - $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true - } else { - $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit + # Loop through each OS and get the results + foreach ($os in @('Windows', 'MacOs', 'Linux')) { + if ($os -eq 'Windows') { + Get-JcSdkSystemInsightProgram | ForEach-Object { + [void]$searchAppResultsList.Add($_) + } + } elseif ($os -eq 'MacOs') { + Get-JcSdkSystemInsightApp | ForEach-Object { + [void]$searchAppResultsList.Add($_) + } + } elseif ($os -eq 'Linux') { + Get-JcSdkSystemInsightLinuxPackage | ForEach-Object { + [void]$searchAppResultsList.Add($_) + } } - # Add OS Family to results - if ($_ -eq 'programs') { $os = 'Windows' } - elseif ($_ -eq 'apps') { $os = 'MacOs' } - elseif ($_ -eq 'linux_packages') { $os = 'Linux' } - $searchAppResults | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os - [void]$searchAppResultsList.Add($searchAppResults) - } + $searchAppResultsList | ForEach-Object { $results = $_ | Where-Object { ($_.name -match $SoftwareName) } $results | ForEach-Object { - $resultsArrayList.Add($_) + [void]$resultsArrayList.Add($_) } } } @@ -343,7 +346,6 @@ function Get-JCSystemApp () { } } - } end { switch ($PSCmdlet.ParameterSetName) { @@ -355,5 +357,4 @@ function Get-JCSystemApp () { } } } -} - +} \ No newline at end of file diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index b5d67c988..f9600f803 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -32,7 +32,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests that given a systemID, SoftwareName, SoftwareVersion, an app is returned" { # Chess is always installed on MacOS and it CAN NOT be removed no matter what $ChessApp = Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" - Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion $ChessApp.Bundle_short_version + { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion $ChessApp.Bundle_short_version } | Should -Throw # A null value version shouldn't be accepted { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion "" } | Should -Throw # A null value Name shouldn't be accepted @@ -66,13 +66,13 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests the search param with systemID" { $apps = Get-JCSystemApp -Systemid $mac._id -SoftwareName "a" -search - $foundSystems = $apps.system_id | Select-Object -Unique + $foundSystems = $apps.systemid | Select-Object -Unique # if you specify a systemID and Search, results should not contain multiple systems $foundSystems.count | should -Be 1 } It "Tests the search param with SystemOS" { $apps = Get-JCSystemApp -SystemOS "macos" -SoftwareName "a" -search - $foundSystems = $apps.system_id | Select-Object -Unique + $foundSystems = $apps.systemid | Select-Object -Unique # if you specify a systemOS and Search, results should not contain multiple systems foreach ($system in $foundSystems) { $foundSystem = Get-JCSystem -SystemID $system From 61a6846c64732e8e2be0a1ec94f17c3bb352e441 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Tue, 31 Jan 2023 15:05:40 -0800 Subject: [PATCH 068/102] Revert "Replaced IWR to SDK" This reverts commit cbdcfa55639e69fe22a2a5c338190373619fc9fb. --- .../Public/Systems/Get-JCSystemApp.ps1 | 423 +++++++++--------- .../Public/Systems/Get-JCSystemApp.tests.ps1 | 6 +- 2 files changed, 214 insertions(+), 215 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 01b5f04dd..1fbd2398f 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -22,11 +22,15 @@ function Get-JCSystemApp () { if ($JCAPIKEY.length -ne 40) { Connect-JCOnline } + $Parallel = $JCConfig.parallel.Calculated $searchAppResultsList = New-Object -TypeName System.Collections.ArrayList - - Write-Verbose 'Initilizing resultsArray' - $resultsArrayList = New-Object -TypeName System.Collections.ArrayList - + if ($Parallel) { + Write-Verbose 'Initilizing resultsArray' + $resultsArrayList = [System.Collections.Concurrent.ConcurrentBag[object]]::new() + } else { + Write-Verbose 'Initilizing resultsArray' + $resultsArrayList = New-Object -TypeName System.Collections.ArrayList + } Write-Verbose "Parameter Set: $($PSCmdlet.ParameterSetName)" } process { @@ -39,67 +43,34 @@ function Get-JCSystemApp () { switch ($PSCmdlet.ParameterSetName) { All { - if ($SystemId -or $SystemOS) { - if ($SystemID -and $SystemOS) { - Throw "Cannot specify both SystemID and SystemOS" - } - - if ($SystemID) { - $OSType = Get-JcSdkSystem -ID $SystemID | Select-Object -ExpandProperty OSFamily - } else { - $OSType = $SystemOS - if ($OSType -eq 'macOS') { - $OSType = 'Darwin' - } - } - Write-Debug "OSType: $OSType" + if ($SystemId) { + Write-Debug "SystemId" + $OSType = Get-JCSystem -ID $SystemID | Select-Object -ExpandProperty osFamily + if ($SystemOS) { Throw "SystemID and SystemOS cannot be used together" } switch ($OSType) { 'Windows' { # If Software title, version, and system ID are passed then return specific app - if ($SoftwareVersion -and $SoftwareName) { + if ($SoftwareVersion -and $SoftwareName -and $SystemID) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - if ($SystemID) { - Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } elseif ($SystemOS) { - Get-JcSdkSystemInsightProgram -Filter @("name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } - } elseif ($SoftwareName) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemId&filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" + + } elseif ($SoftwareName -and $SystemID) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - if ($SystemID) { - Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName") | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } elseif ($SystemOS) { - Get-JcSdkSystemInsightProgram -Filter @("name:eq:$SoftwareName") | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" } elseif ($SystemID) { - if ($SoftwareVersion) { - Write-Error "Cannot search for software version on Windows without software name." - } else { - Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID") | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } - } elseif ($SystemOS) { - if ($SoftwareVersion) { - Write-Error "Cannot search for software version on Windows without software name." - } else { - Get-JcSdkSystemInsightProgram | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=system_id:eq:$SystemID" } + Write-Debug $URL } 'Darwin' { - + # If Software title, version, and system ID are passed then return specific app + # If $softwareName does not have .app at the end then add it + if ((!$SoftwareName) -and (!$SystemOs) -and (!$SoftwareVersion)) { + # Add filter for system ID to $Search + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps" + } if ($SoftwareName) { # Check for .app at the end of the software name if (-not $SoftwareName.EndsWith('.app')) { @@ -113,229 +84,255 @@ function Get-JCSystemApp () { } else { Write-Debug "$SoftwareName already ends with .app" } - } + if ($SoftwareVersion -and $SoftwareName -and $SystemId) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion&filter=system_id:eq:$SystemID" - # If Software title, version, and system ID are passed then return specific app - if ($SoftwareVersion -and $SoftwareName) { + } elseif ($SoftwareName -and $SystemId) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?&filter=name:eq:$SoftwareName&filter=system_id:eq:$SystemID" + } + } + Write-Debug $URL + } + 'Linux' { + # If Software title, version and system ID are passed then return specific app + if ($SoftwareVersion -and $SoftwareName -and $SystemID) { # Handle Special Characters - Write-Debug "Trying to get app with name $SoftwareName and version $SoftwareVersion" $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - if ($SystemID) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemId&filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion&filter=system_id:eq:$SystemID" - Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName", "bundle_short_version:eq:$SoftwareVersion") | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } elseif ($SystemOS) { - Get-JcSdkSystemInsightApp -Filter @("name:eq:$SoftwareName", "bundle_short_version:eq:$SoftwareVersion") | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } - } elseif ($SoftwareName) { + } elseif ($SoftwareName -and $SystemID) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - if ($SystemID) { - Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName") | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } elseif ($SystemOS) { - Get-JcSdkSystemInsightApp -Filter @("name:eq:$SoftwareName") | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID&filter=name:eq:$SoftwareName" } elseif ($SystemID) { - if ($SoftwareVersion) { - Write-Error "Cannot search for software version on MacOs without software name." - } else { - Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID") | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } - } elseif ($SystemOS) { - if ($SoftwareVersion) { - Write-Error "Cannot search for software version on MacOs without software name." - } else { - Get-JcSdkSystemInsightApp | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=system_id:eq:$SystemID" } - + Write-Debug $URL } - 'Linux' { - if ($SoftwareVersion -and $SoftwareName) { + } + if ($Parallel) { + $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit + } + + } elseif ($SystemOS) { + $OSType = $SystemOS + if ($OSType -eq 'MacOs') { $OSType = 'Darwin' } # OS Family for Mac is Darwin + if ($SystemID) { Throw "SystemID and SystemOS cannot be used together" } + Write-Debug "OS: $SystemOs" + switch ($OSType) { + 'Windows' { + # If Software title, version, and system OS are passed then return specific app + if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - if ($SystemID) { - Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } elseif ($SystemOS) { - Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } - } elseif ($SoftwareName) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" + + } elseif ($SoftwareName -and $SystemOS) { # Handle Special Characters $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) - if ($SystemID) { - Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName") | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } elseif ($SystemOS) { - Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$SoftwareName") | ForEach-Object { - [void]$resultsArrayList.Add($_) + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName" + } elseif ($SystemOs) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs" + } + Write-Debug $URL + } + 'Darwin' { + # If Software title, version, and system OS are passed then return specific app and not null + if ((!$SoftwareName) -and (!$SoftwareVersion)) { + # Add filter for system ID to $Search + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps" + } + if ($SoftwareName) { + if (-not $SoftwareName.EndsWith('.app')) { + Write-Debug "Adding .app to $SoftwareName" + if ($SoftwareName.EndsWith('.App')) { + Write-Debug "Replacing .App with .app" + $SoftwareName = $SoftwareName.Replace('.App', '.app') + } else { + $SoftwareName = "$SoftwareName.app" } - } - } elseif ($SystemID) { - if ($SoftwareVersion) { - Write-Error "Cannot search for software version on Linux without software name." } else { - Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID") | ForEach-Object { - [void]$resultsArrayList.Add($_) - } + Write-Debug "$SoftwareName already ends with .app" } - } elseif ($SystemOS) { - if ($SoftwareVersion) { - Write-Error "Cannot search for software version on Linux without software name." - } else { - Get-JcSdkSystemInsightLinuxPackage | ForEach-Object { - [void]$resultsArrayList.Add($_) - } + if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$SoftwareName&filter=bundle_short_version:eq:$SoftwareVersion" + + } elseif ($SoftwareName -and $SystemOS) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?&filter=name:eq:$SoftwareName" } } + Write-Debug $URL + } + 'Linux' { + # If Software title, version, and system OS are passed then return specific app + if ($SoftwareVersion -and $SoftwareName -and $SystemOS) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName&filter=version:eq:$SoftwareVersion" + + } elseif ($SoftwareName -and $SystemOS) { + # Handle Special Characters + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName" + } elseif ($SystemOs) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages" + } + Write-Debug $URL } } + if ($Parallel) { + $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $resultsArrayList = Get-JCResults -URL $URL -Method "GET" -limit $limit + } } elseif ($SoftwareName) { - # Loop through each OS and get the results - Write-Debug "SoftwareName" - foreach ($os in @('Windows', 'MacOs', 'Linux')) { - if ($os -eq 'Windows') { - Get-JcSdkSystemInsightProgram -Filter @("name:eq:$SoftwareName") | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } elseif ($os -eq 'MacOs') { + $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + # Search each apps endpoint for software name + foreach ($os in @('MacOs', 'Windows', 'Linux')) { + if ($os -eq 'MacOs') { if (-not $SoftwareName.EndsWith('.app')) { - Write-Debug "Adding .app to $SoftwareName" if ($SoftwareName.EndsWith('.App')) { - Write-Debug "Replacing .App with .app" - $SoftwareName = $SoftwareName.Replace('.App', '.app') + $MacSoftwareName = $SoftwareName + $MacSoftwareName = $MacSoftwareName.Replace('.App', '.app') } else { - $SoftwareName = "$SoftwareName.app" + $MacSoftwareName = "$MacSoftwareName.app" } + } + if ($SoftwareVersion -and $SoftwareName) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$MacSoftwareName&filter=bundle_short_version:eq:$softwareVersion" } else { - Write-Debug "$SoftwareName already ends with .app" + $URL = "$JCUrlBasePath/api/v2/systeminsights/apps?filter=name:eq:$MacSoftwareName" } - Get-JcSdkSystemInsightApp -Filter @("name:eq:$SoftwareName") | ForEach-Object { - - [void]$resultsArrayList.Add($_) + } elseif ($os -eq 'Windows') { + if ($SoftwareVersion -and $SoftwareName) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName&filter=version:eq:$softwareVersion" + } else { + $URL = "$JCUrlBasePath/api/v2/systeminsights/programs?filter=name:eq:$SoftwareName" } } elseif ($os -eq 'Linux') { - Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$SoftwareName") | ForEach-Object { - [void]$resultsArrayList.Add($_) + if ($SoftwareVersion -and $SoftwareName) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName&filter=version:eq:$softwareVersion" + } else { + $URL = "$JCUrlBasePath/api/v2/systeminsights/linux_packages?filter=name:eq:$SoftwareName" } } + if ($Parallel) { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit + } + # If no results, skip to next OS + if ($resultsArray.count -eq 0) { + continue + } + $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + $resultsArrayList.Add($resultsArray) } - } - - else { + } else { # Default/All - Write-Debug "Test All" - #TODO: Parallelize this - foreach ($os in @('Windows', 'MacOs', 'Linux')) { - if ($os -eq 'Windows') { - Get-JcSdkSystemInsightProgram | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } elseif ($os -eq 'MacOs') { - Get-JcSdkSystemInsightApp | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } elseif ($os -eq 'Linux') { - Get-JcSdkSystemInsightLinuxPackage | ForEach-Object { - [void]$resultsArrayList.Add($_) - } + foreach ($os in @('programs', 'apps', 'linux_packages')) { + $URL = "$JCUrlBasePath/api/v2/systeminsights/$os" + if ($Parallel) { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $resultsArray = Get-JCResults -URL $URL -Method "GET" -limit $limit } + if ($resultsArray.count -eq 0) { continue } + # Add OS Family to results + if ($os -eq 'programs') { $os = 'Windows' } + elseif ($os -eq 'apps') { $os = 'MacOs' } + elseif ($os -eq 'linux_packages') { $os = 'Linux' } + $resultsArray | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + $resultsArrayList.Add($resultsArray) } } + } Search { # Search for softwareName - Write-Debug "Search $SoftwareName" if ($SoftwareName) { if ($SoftwareVersion) { Throw 'You cannot specify software version when using -search for a software name' } elseif ($SystemId) { - $OSType = Get-JcSdkSystem -ID $SystemID | Select-Object -ExpandProperty OSFamily - $OSType - if ($OSType -eq 'Windows') { - Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID") | ForEach-Object { - [void]$searchAppResultsList.Add($_) - } - } elseif ($OSType -eq 'Darwin') { - Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID") | ForEach-Object { - [void]$searchAppResultsList.Add($_) - } - } elseif ($OSType -eq 'Linux') { - Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID") | ForEach-Object { - [void]$searchAppResultsList.Add($_) + $applicationArray | ForEach-Object { + + $URL = "$JCUrlBasePath/api/v2/systeminsights/$_" + Write-Verbose "Searching for $SoftwareName and $SystemId in $_ " + if ($Parallel) { + $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit } + # Add OS Family to results + if ($_ -eq 'programs') { $os = 'Windows' } + elseif ($_ -eq 'apps') { $os = 'MacOs' } + elseif ($_ -eq 'linux_packages') { $os = 'Linux' } + $searchAppResults | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + [void]$searchAppResultsList.Add($searchAppResults) } - $searchAppResultsList.Count - $searchAppResultsList | ForEach-Object { - $results = $_ | Where-Object { ($_.name -match $SoftwareName) } + $results = $_ | Where-Object { ($_.name -match $SoftwareName) -and ($_.System_id -match $SystemId) } $results | ForEach-Object { - [void]$resultsArrayList.Add($_) + $resultsArrayList.Add($_) } } } elseif ($SystemOS) { - Write-Debug "SystemOS $SystemOS" - if ($SystemOS -eq 'Windows') { - Get-JcSdkSystemInsightProgram | ForEach-Object { - [void]$searchAppResultsList.Add($_) - } - } elseif ($SystemOS -eq 'MacOs') { - Get-JcSdkSystemInsightApp | ForEach-Object { - [void]$searchAppResultsList.Add($_) - } - } elseif ($SystemOS -eq 'Linux') { - Get-JcSdkSystemInsightLinuxPackage | ForEach-Object { - [void]$searchAppResultsList.Add($_) + $applicationArray | ForEach-Object { + $URL = "$JCUrlBasePath/api/v2/systeminsights/$_" + Write-Verbose "Searching for $SoftwareName and $SystemOs in $_ " + if ($Parallel) { + $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit } + # Add OS Family to results + if ($_ -eq 'programs') { $os = 'Windows' } + elseif ($_ -eq 'apps') { $os = 'MacOs' } + elseif ($_ -eq 'linux_packages') { $os = 'Linux' } + $searchAppResults | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + [void]$searchAppResultsList.Add($searchAppResults) } $searchAppResultsList | ForEach-Object { - $results = $_ | Where-Object { ($_.name -match $SoftwareName) } + $results = $_ | Where-Object { ($_.name -match $SoftwareName) -and ($_.osFamily -match $SystemOs) } $results | ForEach-Object { - [void]$resultsArrayList.Add($_) + $resultsArrayList.Add($_) } } } else { - Write-Debug "Test All" # Get all the results with only softwarename - # Loop through each OS and get the results - foreach ($os in @('Windows', 'MacOs', 'Linux')) { - if ($os -eq 'Windows') { - Get-JcSdkSystemInsightProgram | ForEach-Object { - [void]$searchAppResultsList.Add($_) - } - } elseif ($os -eq 'MacOs') { - Get-JcSdkSystemInsightApp | ForEach-Object { - [void]$searchAppResultsList.Add($_) - } - } elseif ($os -eq 'Linux') { - Get-JcSdkSystemInsightLinuxPackage | ForEach-Object { - [void]$searchAppResultsList.Add($_) - } + $applicationArray | ForEach-Object { + $URL = "$JCUrlBasePath/api/v2/systeminsights/$_" + Write-Verbose "Searching for $SoftwareName in $_ " + if ($Parallel) { + $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit -parallel $true + } else { + $searchAppResults = Get-JCResults -URL $URL -Method "GET" -limit $limit } - } + # Add OS Family to results + if ($_ -eq 'programs') { $os = 'Windows' } + elseif ($_ -eq 'apps') { $os = 'MacOs' } + elseif ($_ -eq 'linux_packages') { $os = 'Linux' } + $searchAppResults | Add-Member -MemberType NoteProperty -Name 'osFamily' -Value $os + [void]$searchAppResultsList.Add($searchAppResults) + } $searchAppResultsList | ForEach-Object { $results = $_ | Where-Object { ($_.name -match $SoftwareName) } $results | ForEach-Object { - [void]$resultsArrayList.Add($_) + $resultsArrayList.Add($_) } } } @@ -346,6 +343,7 @@ function Get-JCSystemApp () { } } + } end { switch ($PSCmdlet.ParameterSetName) { @@ -357,4 +355,5 @@ function Get-JCSystemApp () { } } } -} \ No newline at end of file +} + diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index f9600f803..b5d67c988 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -32,7 +32,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests that given a systemID, SoftwareName, SoftwareVersion, an app is returned" { # Chess is always installed on MacOS and it CAN NOT be removed no matter what $ChessApp = Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" - { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion $ChessApp.Bundle_short_version } | Should -Throw + Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion $ChessApp.Bundle_short_version # A null value version shouldn't be accepted { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion "" } | Should -Throw # A null value Name shouldn't be accepted @@ -66,13 +66,13 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests the search param with systemID" { $apps = Get-JCSystemApp -Systemid $mac._id -SoftwareName "a" -search - $foundSystems = $apps.systemid | Select-Object -Unique + $foundSystems = $apps.system_id | Select-Object -Unique # if you specify a systemID and Search, results should not contain multiple systems $foundSystems.count | should -Be 1 } It "Tests the search param with SystemOS" { $apps = Get-JCSystemApp -SystemOS "macos" -SoftwareName "a" -search - $foundSystems = $apps.systemid | Select-Object -Unique + $foundSystems = $apps.system_id | Select-Object -Unique # if you specify a systemOS and Search, results should not contain multiple systems foreach ($system in $foundSystems) { $foundSystem = Get-JCSystem -SystemID $system From 27b29d5652634ef08126ff8bfd8cfd011136ee1a Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 1 Feb 2023 12:56:07 -0800 Subject: [PATCH 069/102] added some parallel or efficiency improvements --- .../Public/Systems/Get-JCSystemApp.ps1 | 68 +++++++------------ 1 file changed, 26 insertions(+), 42 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 01b5f04dd..1dc70651b 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -210,7 +210,7 @@ function Get-JCSystemApp () { } } elseif ($SoftwareName) { # Loop through each OS and get the results - Write-Debug "SoftwareName" + Write-Debug "SoftwareName only passed. Getting all software with name $SoftwareName" foreach ($os in @('Windows', 'MacOs', 'Linux')) { if ($os -eq 'Windows') { Get-JcSdkSystemInsightProgram -Filter @("name:eq:$SoftwareName") | ForEach-Object { @@ -242,24 +242,11 @@ function Get-JCSystemApp () { else { # Default/All - Write-Debug "Test All" - #TODO: Parallelize this - foreach ($os in @('Windows', 'MacOs', 'Linux')) { - if ($os -eq 'Windows') { - Get-JcSdkSystemInsightProgram | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } elseif ($os -eq 'MacOs') { - Get-JcSdkSystemInsightApp | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } elseif ($os -eq 'Linux') { - Get-JcSdkSystemInsightLinuxPackage | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } + Write-Debug "Get All" + $commands = @("Get-JcSdkSystemInsightProgram", "Get-JcSdkSystemInsightApp", "Get-JcSdkSystemInsightLinuxPackage") - } + $resultList = $commands | ForEach-Object -Parallel { & $_ } + $searchAppResultsList.AddRange($resultList) } } Search { # Search for softwareName @@ -313,31 +300,28 @@ function Get-JCSystemApp () { } } } else { - Write-Debug "Test All" - # Get all the results with only softwarename - # Loop through each OS and get the results - foreach ($os in @('Windows', 'MacOs', 'Linux')) { - if ($os -eq 'Windows') { - Get-JcSdkSystemInsightProgram | ForEach-Object { - [void]$searchAppResultsList.Add($_) - } - } elseif ($os -eq 'MacOs') { - Get-JcSdkSystemInsightApp | ForEach-Object { - [void]$searchAppResultsList.Add($_) - } - } elseif ($os -eq 'Linux') { - Get-JcSdkSystemInsightLinuxPackage | ForEach-Object { - [void]$searchAppResultsList.Add($_) - } - } - } + $commands = @("Get-JcSdkSystemInsightProgram", "Get-JcSdkSystemInsightApp", "Get-JcSdkSystemInsightLinuxPackage") + # $commands | ForEach-Object { + # Start-Job -ScriptBlock { + # param($command) + # & $command + # } -ArgumentList $_ + # } + # Get-Job | Wait-Job | Receive-Job | ForEach-Object { + # [void]$searchAppResultsList.Add($_) + # } + $resultList = $commands | ForEach-Object -Parallel { & $_ } + $searchAppResultsList.AddRange($resultList) - $searchAppResultsList | ForEach-Object { - $results = $_ | Where-Object { ($_.name -match $SoftwareName) } - $results | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } + + $filteredResults = $searchAppResultsList | Where-Object { ($_.name -match $SoftwareName) } + $resultsArrayList = $filteredResults + # $searchAppResultsList | ForEach-Object { + # $results = $_ | Where-Object { ($_.name -match $SoftwareName) } + # $results | ForEach-Object { + # [void]$resultsArrayList.Add($_) + # } + # } } } else { From ec977f9044221b5f5c26126540b705883c05e359 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Thu, 2 Feb 2023 08:33:41 -0700 Subject: [PATCH 070/102] additional test cases (skipped for now) --- .../Public/Systems/Get-JCSystemApp.tests.ps1 | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index f9600f803..6332d925b 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -27,7 +27,9 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests that given a systemID, SoftwareName, an app is returned" { # Chess is always installed on MacOS and it CAN NOT be removed no matter what Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" - # TODO: Windows/ Linux Examples + # Skip until both systems have system insights enabled in pester orgs + # Get-JCSystemApp -SystemID $linux._id -SoftwareName "Curl" + # Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" } It "Tests that given a systemID, SoftwareName, SoftwareVersion, an app is returned" { # Chess is always installed on MacOS and it CAN NOT be removed no matter what @@ -42,7 +44,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { # TODO: Windows/ Linux Examples } # Create tests for Search - It "Tests for search given SystemOs and SoftwareName" { + It "Tests for search given SystemOs and SoftwareName for MacOS Systems" { # Chess is always installed on MacOS and it CAN NOT be removed no matter what { Get-JCSystemApp -Search | Should -Throw } { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemID $mac.Id | Should -Not -Throw } @@ -55,6 +57,32 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { # Searching chess on MacOs should return a result { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemOs "MacOs" | Should -Not -Throw } } + It "Tests for search given SystemOs and SoftwareName for Linux Systems" -skip { + # Curl is always installed on linux + { Get-JCSystemApp -Search | Should -Throw } + { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemID $linux._Id | Should -Not -Throw } + { Get-JCSystemApp -Search -SoftwareName "Curl" | Should -Not -Throw } + { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemOs "linux" | Should -Not -Throw } + # A null value version shouldn't be accepted + { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemOs "" | Should -Throw } + # A null value version shouldn't be accepted + { Get-JCSystemApp -Search -SoftwareName "" -SystemOs "linux" | Should -Throw } + # Searching Curl on linux should return a result + { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemOs "linux" | Should -Not -Throw } + } + It "Tests for search given SystemOs and SoftwareName for Windows Systems" -skip { + # Microsoft Edge is always installed on windows + { Get-JCSystemApp -Search | Should -Throw } + { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemID $windows._Id | Should -Not -Throw } + { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" | Should -Not -Throw } + { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "windows" | Should -Not -Throw } + # A null value version shouldn't be accepted + { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "" | Should -Throw } + # A null value version shouldn't be accepted + { Get-JCSystemApp -Search -SoftwareName "" -SystemOs "windows" | Should -Throw } + # Searching Microsoft Edge on windows should return a result + { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "windows" | Should -Not -Throw } + } It "Tests the search functionatily of a software app" { # results with no data should be null or empty From 8f27bda608c67db22c2c2923de273fa253bbfaf1 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 2 Feb 2023 11:15:07 -0800 Subject: [PATCH 071/102] Added tests that included windows and linux --- .../Public/Systems/Get-JCSystemApp.ps1 | 148 ++++++++---------- .../Public/Systems/Get-JCSystemApp.tests.ps1 | 133 ++++++++++++++-- 2 files changed, 183 insertions(+), 98 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 1dc70651b..8f8a60a54 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -22,8 +22,10 @@ function Get-JCSystemApp () { if ($JCAPIKEY.length -ne 40) { Connect-JCOnline } - $searchAppResultsList = New-Object -TypeName System.Collections.ArrayList + $Parallel = $JCConfig.parallel.Calculated + $searchAppResultsList = New-Object -TypeName System.Collections.ArrayList + $commands = @("Get-JcSdkSystemInsightProgram", "Get-JcSdkSystemInsightApp", "Get-JcSdkSystemInsightLinuxPackage") Write-Verbose 'Initilizing resultsArray' $resultsArrayList = New-Object -TypeName System.Collections.ArrayList @@ -57,8 +59,8 @@ function Get-JCSystemApp () { 'Windows' { # If Software title, version, and system ID are passed then return specific app if ($SoftwareVersion -and $SoftwareName) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + + if ($SystemID) { Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { [void]$resultsArrayList.Add($_) @@ -69,8 +71,8 @@ function Get-JCSystemApp () { } } } elseif ($SoftwareName) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + + if ($SystemID) { Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName") | ForEach-Object { [void]$resultsArrayList.Add($_) @@ -102,43 +104,44 @@ function Get-JCSystemApp () { if ($SoftwareName) { # Check for .app at the end of the software name + $macOsSoftwareName = $SoftwareName if (-not $SoftwareName.EndsWith('.app')) { Write-Debug "Adding .app to $SoftwareName" if ($SoftwareName.EndsWith('.App')) { Write-Debug "Replacing .App with .app" - $SoftwareName = $SoftwareName.Replace('.App', '.app') + $macOsSoftwareName = $macOsSoftwareName.Replace('.App', '.app') } else { - $SoftwareName = "$SoftwareName.app" + $macOsSoftwareName = "$macOsSoftwareName.app" } } else { - Write-Debug "$SoftwareName already ends with .app" + Write-Debug "$macOsSoftwareName already ends with .app" } } # If Software title, version, and system ID are passed then return specific app - if ($SoftwareVersion -and $SoftwareName) { - # Handle Special Characters - Write-Debug "Trying to get app with name $SoftwareName and version $SoftwareVersion" - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + if ($SoftwareVersion -and $macOsSoftwareName) { + + Write-Debug "Trying to get app with name $macOsSoftwareName and version $SoftwareVersion" + if ($SystemID) { - Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName", "bundle_short_version:eq:$SoftwareVersion") | ForEach-Object { + Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID", "name:eq:$macOsSoftwareName", "bundle_short_version:eq:$SoftwareVersion") | ForEach-Object { [void]$resultsArrayList.Add($_) } } elseif ($SystemOS) { - Get-JcSdkSystemInsightApp -Filter @("name:eq:$SoftwareName", "bundle_short_version:eq:$SoftwareVersion") | ForEach-Object { + Get-JcSdkSystemInsightApp -Filter @("name:eq:$macOsSoftwareName", "bundle_short_version:eq:$SoftwareVersion") | ForEach-Object { [void]$resultsArrayList.Add($_) } } - } elseif ($SoftwareName) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + } elseif ($macOsSoftwareName) { + + if ($SystemID) { - Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName") | ForEach-Object { + Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID", "name:eq:$macOsSoftwareName") | ForEach-Object { [void]$resultsArrayList.Add($_) } } elseif ($SystemOS) { - Get-JcSdkSystemInsightApp -Filter @("name:eq:$SoftwareName") | ForEach-Object { + Get-JcSdkSystemInsightApp -Filter @("name:eq:$macOsSoftwareName") | ForEach-Object { [void]$resultsArrayList.Add($_) } } @@ -164,8 +167,8 @@ function Get-JCSystemApp () { 'Linux' { if ($SoftwareVersion -and $SoftwareName) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) + + if ($SystemID) { Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { [void]$resultsArrayList.Add($_) @@ -176,8 +179,6 @@ function Get-JCSystemApp () { } } } elseif ($SoftwareName) { - # Handle Special Characters - $SoftwareName = [System.Web.HttpUtility]::UrlEncode($SoftwareName) if ($SystemID) { Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName") | ForEach-Object { [void]$resultsArrayList.Add($_) @@ -217,22 +218,24 @@ function Get-JCSystemApp () { [void]$resultsArrayList.Add($_) } } elseif ($os -eq 'MacOs') { + $macOsSoftwareName = $SoftwareName if (-not $SoftwareName.EndsWith('.app')) { Write-Debug "Adding .app to $SoftwareName" if ($SoftwareName.EndsWith('.App')) { Write-Debug "Replacing .App with .app" - $SoftwareName = $SoftwareName.Replace('.App', '.app') + $macOsSoftwareName = $macOsSoftwareName.Replace('.App', '.app') } else { - $SoftwareName = "$SoftwareName.app" + $macOsSoftwareName = "$macOsSoftwareName.app" } } else { - Write-Debug "$SoftwareName already ends with .app" + Write-Debug "$macOsSoftwareName already ends with .app" } - Get-JcSdkSystemInsightApp -Filter @("name:eq:$SoftwareName") | ForEach-Object { + Get-JcSdkSystemInsightApp -Filter @("name:eq:$macOsSoftwareName") | ForEach-Object { [void]$resultsArrayList.Add($_) } } elseif ($os -eq 'Linux') { + Write-Debug "Getting Linux software $SoftwareName" Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$SoftwareName") | ForEach-Object { [void]$resultsArrayList.Add($_) } @@ -243,10 +246,14 @@ function Get-JCSystemApp () { else { # Default/All Write-Debug "Get All" - $commands = @("Get-JcSdkSystemInsightProgram", "Get-JcSdkSystemInsightApp", "Get-JcSdkSystemInsightLinuxPackage") - - $resultList = $commands | ForEach-Object -Parallel { & $_ } - $searchAppResultsList.AddRange($resultList) + if ($Parallel) { + Write-Debug "Getting all software in parallel" + $result = $commands | ForEach-Object -Parallel { & $_ } + $resultsArrayList = $result + } else { + $result = $commands | ForEach-Object { & $_ } + $resultsArrayList = $result + } } } Search { # Search for softwareName @@ -256,72 +263,51 @@ function Get-JCSystemApp () { Throw 'You cannot specify software version when using -search for a software name' } elseif ($SystemId) { $OSType = Get-JcSdkSystem -ID $SystemID | Select-Object -ExpandProperty OSFamily - $OSType - if ($OSType -eq 'Windows') { - Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID") | ForEach-Object { - [void]$searchAppResultsList.Add($_) + Switch ($OSType) { + "Windows" { + $result = Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID") + $searchAppResultsList.AddRange($result) } - } elseif ($OSType -eq 'Darwin') { - Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID") | ForEach-Object { - [void]$searchAppResultsList.Add($_) + "Darwin" { + $result = Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID") + $searchAppResultsList.AddRange($result) } - } elseif ($OSType -eq 'Linux') { - Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID") | ForEach-Object { - [void]$searchAppResultsList.Add($_) + "Linux" { + $result = Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID") + $searchAppResultsList.AddRange($result) } } - $searchAppResultsList.Count - $searchAppResultsList | ForEach-Object { - $results = $_ | Where-Object { ($_.name -match $SoftwareName) } - $results | ForEach-Object { - [void]$resultsArrayList.Add($_) - } - } + $filteredResults = $searchAppResultsList | Where-Object { ($_.name -match $SoftwareName) } + $resultsArrayList = $filteredResults } elseif ($SystemOS) { Write-Debug "SystemOS $SystemOS" if ($SystemOS -eq 'Windows') { - Get-JcSdkSystemInsightProgram | ForEach-Object { - [void]$searchAppResultsList.Add($_) - } + $result = Get-JcSdkSystemInsightProgram + $searchAppResultsList.AddRange($result) } elseif ($SystemOS -eq 'MacOs') { - Get-JcSdkSystemInsightApp | ForEach-Object { - [void]$searchAppResultsList.Add($_) - } + $result = Get-JcSdkSystemInsightApp + $searchAppResultsList.AddRange($result) } elseif ($SystemOS -eq 'Linux') { - Get-JcSdkSystemInsightLinuxPackage | ForEach-Object { - [void]$searchAppResultsList.Add($_) - } - } - $searchAppResultsList | ForEach-Object { - $results = $_ | Where-Object { ($_.name -match $SoftwareName) } - $results | ForEach-Object { - [void]$resultsArrayList.Add($_) - } + $result = Get-JcSdkSystemInsightLinuxPackage + $searchAppResultsList.AddRange($result) } + $filteredResults = $searchAppResultsList | Where-Object { ($_.name -match $SoftwareName) } + $resultsArrayList = $filteredResults } else { - $commands = @("Get-JcSdkSystemInsightProgram", "Get-JcSdkSystemInsightApp", "Get-JcSdkSystemInsightLinuxPackage") - # $commands | ForEach-Object { - # Start-Job -ScriptBlock { - # param($command) - # & $command - # } -ArgumentList $_ - # } - # Get-Job | Wait-Job | Receive-Job | ForEach-Object { - # [void]$searchAppResultsList.Add($_) - # } - $resultList = $commands | ForEach-Object -Parallel { & $_ } - $searchAppResultsList.AddRange($resultList) + if ($Parallel) { + Write-Debug "Parallel" + $result = $commands | ForEach-Object -Parallel { & $_ } + [void]$searchAppResultsList.AddRange($result) + } else { + $result = $commands | ForEach-Object { & $_ } + [void]$searchAppResultsList.AddRange($result) + } $filteredResults = $searchAppResultsList | Where-Object { ($_.name -match $SoftwareName) } $resultsArrayList = $filteredResults - # $searchAppResultsList | ForEach-Object { - # $results = $_ | Where-Object { ($_.name -match $SoftwareName) } - # $results | ForEach-Object { - # [void]$resultsArrayList.Add($_) - # } - # } + } } else { diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index f9600f803..5f5599099 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -26,23 +26,45 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests that given a systemID, SoftwareName, an app is returned" { # Chess is always installed on MacOS and it CAN NOT be removed no matter what - Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" - # TODO: Windows/ Linux Examples + { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" } | Should -Not -BeNullOrEmpty + { Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" } | Should -Not -BeNullOrEmpty + { Get-JCSystemApp -SystemID $linux._id -SoftwareName "firefox" } | Should -Not -BeNullOrEmpty } It "Tests that given a systemID, SoftwareName, SoftwareVersion, an app is returned" { - # Chess is always installed on MacOS and it CAN NOT be removed no matter what - $ChessApp = Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" - { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion $ChessApp.Bundle_short_version } | Should -Throw + # MacOS + $macApp = Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" + { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion $macApp.Bundle_short_version } | Should -Throw # A null value version shouldn't be accepted { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion "" } | Should -Throw # A null value Name shouldn't be accepted { Get-JCSystemApp -SystemID $mac._id -SoftwareName "" } | Should -Throw # Using a version that doesn't exist should return nothing Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion "48.49.50.51" | Should -Be $null - # TODO: Windows/ Linux Examples + + #Windows + $windowsApp = Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" + { Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" -SoftwareVersion $windowsApp.version } | Should -Throw + # A null value version shouldn't be accepted + { Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" -SoftwareVersion "" } | Should -Throw + # A null value Name shouldn't be accepted + { Get-JCSystemApp -SystemID $windows._id -SoftwareName "" } | Should -Throw + # Using a version that doesn't exist should return nothing + Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" -SoftwareVersion "48.49.50.51" | Should -Be $null + + #Linux + #Windows + $linuxApp = Get-JCSystemApp -SystemID $linux._id -SoftwareName "firefox" + { Get-JCSystemApp -SystemID $linux._id -SoftwareName "firefox" -SoftwareVersion $linuxApp.version } | Should -Throw + # A null value version shouldn't be accepted + { Get-JCSystemApp -SystemID $linux._id -SoftwareName "firefox" -SoftwareVersion "" } | Should -Throw + # A null value Name shouldn't be accepted + { Get-JCSystemApp -SystemID $linux._id -SoftwareName "" } | Should -Throw + # Using a version that doesn't exist should return nothing + Get-JCSystemApp -SystemID $linux._id -SoftwareName "firefox" -SoftwareVersion "48.49.50.51" | Should -Be $null } # Create tests for Search It "Tests for search given SystemOs and SoftwareName" { + #Macos # Chess is always installed on MacOS and it CAN NOT be removed no matter what { Get-JCSystemApp -Search | Should -Throw } { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemID $mac.Id | Should -Not -Throw } @@ -54,40 +76,117 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { { Get-JCSystemApp -Search -SoftwareName "" -SystemOs "MacOs" | Should -Throw } # Searching chess on MacOs should return a result { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemOs "MacOs" | Should -Not -Throw } + + #Windows + { Get-JCSystemApp -Search | Should -Throw } + { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemID $windows.Id | Should -Not -Throw } + { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" | Should -Not -Throw } + { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "windows" | Should -Not -Throw } + # A null value version shouldn't be accepted + { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "" | Should -Throw } + # A null value version shouldn't be accepted + { Get-JCSystemApp -Search -SoftwareName "" -SystemOs "windows" | Should -Throw } + # Searching chess on MacOs should return a result + { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "windows" | Should -Not -Throw } + + #Linux + { Get-JCSystemApp -Search | Should -Throw } + { Get-JCSystemApp -Search -SoftwareName "firefox" -SystemID $linux.Id | Should -Not -Throw } + { Get-JCSystemApp -Search -SoftwareName "firefox" | Should -Not -Throw } + { Get-JCSystemApp -Search -SoftwareName "firefox" -SystemOs "linux" | Should -Not -Throw } + # A null value version shouldn't be accepted + { Get-JCSystemApp -Search -SoftwareName "firefox" -SystemOs "" | Should -Throw } + # A null value version shouldn't be accepted + { Get-JCSystemApp -Search -SoftwareName "" -SystemOs "linux" | Should -Throw } + # Searching chess on MacOs should return a result + { Get-JCSystemApp -Search -SoftwareName "firefox" -SystemOs "linux" | Should -Not -Throw } } It "Tests the search functionatily of a software app" { + #Tests for each OS # results with no data should be null or empty Get-JCSystemApp -SoftwareName "chess" | Should -BeNullOrEmpty + Get-JCSystemApp -SoftwareName "microsoft edge" | Should -BeNullOrEmpty + Get-JCSystemApp -SoftwareName "firefox" | Should -BeNullOrEmpty # when search is used to find an app the results should not be null or empty Get-JCSystemApp -SoftwareName "chess" -Search | Should -Not -BeNullOrEmpty + Get-JCSystemApp -SoftwareName "microsoft edge" -Search | Should -Not -BeNullOrEmpty + Get-JCSystemApp -SoftwareName "firefox" -Search | Should -Not -BeNullOrEmpty } It "Tests the search param with systemID" { - $apps = Get-JCSystemApp -Systemid $mac._id -SoftwareName "a" -search - $foundSystems = $apps.systemid | Select-Object -Unique + $macApps = Get-JCSystemApp -Systemid $mac._id -SoftwareName "a" -search + $windowsApps = Get-JCSystemApp -Systemid $windows._id -SoftwareName "a" -search + $linuxApps = Get-JCSystemApp -Systemid $linux._id -SoftwareName "a" -search + $foundMacSystems = $macApps.systemid | Select-Object -Unique + $foundWindowsSystems = $windowsApps.systemid | Select-Object -Unique + $foundLinuxSystems = $linuxApps.systemid | Select-Object -Unique # if you specify a systemID and Search, results should not contain multiple systems - $foundSystems.count | should -Be 1 + $foundMacSystems.count | should -Be 1 + $foundWindowsSystems.count | should -Be 1 + $foundLinuxSystems.count | should -Be 1 } It "Tests the search param with SystemOS" { + # MacOS $apps = Get-JCSystemApp -SystemOS "macos" -SoftwareName "a" -search - $foundSystems = $apps.systemid | Select-Object -Unique + $foundMacSystems = $apps.systemid | Select-Object -Unique # if you specify a systemOS and Search, results should not contain multiple systems foreach ($system in $foundSystems) { - $foundSystem = Get-JCSystem -SystemID $system - $foundSystem.osfamily | Should -be 'darwin' + $foundMacSystems = Get-JCSystem -SystemID $system + $foundMacSystems.osfamily | Should -be 'darwin' + } + # Windows + $apps = Get-JCSystemApp -SystemOS "windows" -SoftwareName "a" -search + $foundWindowsSystems = $apps.systemid | Select-Object -Unique + # if you specify a systemOS and Search, results should not contain multiple systems + foreach ($system in $foundWindowsSystems) { + $foundWindowsSystems = Get-JCSystem -SystemID $system + $foundWindowsSystems.osfamily | Should -be 'windows' + } + # Linux + $apps = Get-JCSystemApp -SystemOS "linux" -SoftwareName "a" -search + $foundLinuxSystems = $apps.systemid | Select-Object -Unique + # if you specify a systemOS and Search, results should not contain multiple systems + foreach ($system in $foundLinuxSystems) { + $foundLinuxSystems = Get-JCSystem -SystemID $system + $foundLinuxSystems.osfamily | Should -be 'windows' } } It "Tests compatability with the SDKs" { - $sdkChess = Get-JcSdkSystemInsightApp -filter @("system_id:eq:$($mac._id)", "bundle_name:eq:Chess") - $moduleChess = Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" - $moduleChessSearch = Get-JCSystemApp -SystemID $mac._id -SoftwareName "chess" -Search + #MacOS + $sdkMac = Get-JcSdkSystemInsightApp -filter @("system_id:eq:$($mac._id)", "name:eq:Chess.app") + $moduleMac = Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" + $moduleMacSearch = Get-JCSystemApp -SystemID $mac._id -SoftwareName "chess" -Search + # SDK Results should look exactly like module results when exact name is specified + $sdkMac.id | Should -Be $moduleMac.id + $sdkMac.name | Should -Be $moduleMac.name + # SDK Results should look exactly like module results when search is provided + $sdkMac.id | Should -Be $moduleMacSearch.id + $sdkMac.name | Should -Be $moduleMacSearch.name + + #Windows + $sdkWindows = Get-JcSdkSystemInsightProgram -filter @("system_id:eq:$($windows._id)", "name:eq:Microsoft Edge") + $moduleWindows = Get-JcSdkSystemInsightProgram -SystemID $windows._id -SoftwareName "Microsoft Edge" + $moduleWindowsSearch = Get-JcSdkSystemInsightProgram -SystemID $windows._id -SoftwareName "microsoft edge" -Search + # SDK Results should look exactly like module results when exact name is specified + $sdkWindows.id | Should -Be $moduleWindows.id + $sdkWindows.name | Should -Be $moduleWindows.name + # SDK Results should look exactly like module results when search is provided + $sdkWindows.id | Should -Be $moduleWindowsSearch.id + $sdkWindows.name | Should -Be $moduleWindowsSearch.name + + #Linux + $sdkLinux = Get-JcSdkSystemInsightLinuxPackage -filter @("system_id:eq:$($linux._id)", "name:eq:firefox") + $moduleLinux = Get-JcSdkSystemInsightLinuxPackage -SystemID $linux._id -SoftwareName "firefox" + $moduleLinuxSearch = Get-JcSdkSystemInsightLinuxPackage -SystemID $linux._id -SoftwareName "firefox" -Search # SDK Results should look exactly like module results when exact name is specified - $sdkChess | Should -Be $moduleChess + $sdkLinux.id | Should -Be $moduleLinux.id + $sdkLinux.name | Should -Be $moduleLinux.name # SDK Results should look exactly like module results when search is provided - $sdkChess | Should -Be $moduleChessSearch + $sdkLinux.id | Should -Be $moduleLinuxSearch.id + $sdkLinux.name | Should -Be $moduleLinuxSearch.name } It "Tests that incompatible parameters should not be used together" { From b80117a82f52228a40b4db5c2ec51b7ec6c3501f Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 2 Feb 2023 11:28:04 -0800 Subject: [PATCH 072/102] cleanup --- .../JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 8f8a60a54..11539690c 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -25,10 +25,8 @@ function Get-JCSystemApp () { $Parallel = $JCConfig.parallel.Calculated $searchAppResultsList = New-Object -TypeName System.Collections.ArrayList - $commands = @("Get-JcSdkSystemInsightProgram", "Get-JcSdkSystemInsightApp", "Get-JcSdkSystemInsightLinuxPackage") - Write-Verbose 'Initilizing resultsArray' $resultsArrayList = New-Object -TypeName System.Collections.ArrayList - + $commands = @("Get-JcSdkSystemInsightProgram", "Get-JcSdkSystemInsightApp", "Get-JcSdkSystemInsightLinuxPackage") Write-Verbose "Parameter Set: $($PSCmdlet.ParameterSetName)" } process { From 425619c848ec9795d62993c3a87fa82aa1ab0b48 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Thu, 2 Feb 2023 19:36:51 +0000 Subject: [PATCH 073/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index 76c187a91..145643723 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.2.0.7621-202301301741 + 2.2.0.7678-202302021934 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 6d58a5a95..346807c2f 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 1/30/2023 +# Generated on: 2/2/2023 # @{ From 0a9000c356fc22ed4388a97a36987b19e7b4ac71 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Thu, 2 Feb 2023 22:38:40 +0000 Subject: [PATCH 074/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index f8bf10130..ba6b37a0c 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] +Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] ``` ## DESCRIPTION From a651b057f4230f4494def02d9762e6ff0fdba8a8 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Fri, 3 Feb 2023 09:14:52 -0700 Subject: [PATCH 075/102] should not throw tests --- .../Public/Systems/Get-JCSystemApp.tests.ps1 | 57 +++++-------------- 1 file changed, 15 insertions(+), 42 deletions(-) diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index c147ddd23..853c4032b 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -67,65 +67,41 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests for search given SystemOs and SoftwareName for MacOS Systems" { # Chess is always installed on MacOS and it CAN NOT be removed no matter what { Get-JCSystemApp -Search | Should -Throw } - { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemID $mac.Id | Should -Not -Throw } - { Get-JCSystemApp -Search -SoftwareName "Chess" | Should -Not -Throw } - { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemOs "MacOs" | Should -Not -Throw } + { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemID $mac.Id } | should -Not -Throw + { Get-JCSystemApp -Search -SoftwareName "Chess" } | should -Not -Throw + { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemOs "MacOs" } | should -Not -Throw # A null value version shouldn't be accepted { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemOs "" | Should -Throw } # A null value version shouldn't be accepted { Get-JCSystemApp -Search -SoftwareName "" -SystemOs "MacOs" | Should -Throw } # Searching chess on MacOs should return a result - { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemOs "MacOs" | Should -Not -Throw } - - #Windows - { Get-JCSystemApp -Search | Should -Throw } - { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemID $windows.Id | Should -Not -Throw } - { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" | Should -Not -Throw } - { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "windows" | Should -Not -Throw } - # A null value version shouldn't be accepted - { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "" | Should -Throw } - # A null value version shouldn't be accepted - { Get-JCSystemApp -Search -SoftwareName "" -SystemOs "windows" | Should -Throw } - # Searching chess on MacOs should return a result - { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "windows" | Should -Not -Throw } - - #Linux - { Get-JCSystemApp -Search | Should -Throw } - { Get-JCSystemApp -Search -SoftwareName "firefox" -SystemID $linux.Id | Should -Not -Throw } - { Get-JCSystemApp -Search -SoftwareName "firefox" | Should -Not -Throw } - { Get-JCSystemApp -Search -SoftwareName "firefox" -SystemOs "linux" | Should -Not -Throw } - # A null value version shouldn't be accepted - { Get-JCSystemApp -Search -SoftwareName "firefox" -SystemOs "" | Should -Throw } - # A null value version shouldn't be accepted - { Get-JCSystemApp -Search -SoftwareName "" -SystemOs "linux" | Should -Throw } - # Searching chess on MacOs should return a result - { Get-JCSystemApp -Search -SoftwareName "firefox" -SystemOs "linux" | Should -Not -Throw } + { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemOs "MacOs" } | should -Not -Throw } It "Tests for search given SystemOs and SoftwareName for Linux Systems" -skip { # Curl is always installed on linux { Get-JCSystemApp -Search | Should -Throw } - { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemID $linux._Id | Should -Not -Throw } - { Get-JCSystemApp -Search -SoftwareName "Curl" | Should -Not -Throw } - { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemOs "linux" | Should -Not -Throw } + { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemID $linux._Id } | should -Not -Throw + { Get-JCSystemApp -Search -SoftwareName "Curl" } | should -Not -Throw + { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemOs "linux" } | should -Not -Throw # A null value version shouldn't be accepted { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemOs "" | Should -Throw } # A null value version shouldn't be accepted { Get-JCSystemApp -Search -SoftwareName "" -SystemOs "linux" | Should -Throw } # Searching Curl on linux should return a result - { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemOs "linux" | Should -Not -Throw } + { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemOs "linux" } | should -Not -Throw } It "Tests for search given SystemOs and SoftwareName for Windows Systems" -skip { # Microsoft Edge is always installed on windows { Get-JCSystemApp -Search | Should -Throw } - { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemID $windows._Id | Should -Not -Throw } - { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" | Should -Not -Throw } - { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "windows" | Should -Not -Throw } + { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemID $windows._Id } | should -Not -Throw + { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" } | should -Not -Throw + { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "windows" } | should -Not -Throw # A null value version shouldn't be accepted { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "" | Should -Throw } # A null value version shouldn't be accepted { Get-JCSystemApp -Search -SoftwareName "" -SystemOs "windows" | Should -Throw } # Searching Microsoft Edge on windows should return a result - { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "windows" | Should -Not -Throw } + { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "windows" } | should -Not -Throw } It "Tests the search functionatily of a software app" { @@ -158,8 +134,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { $apps = Get-JCSystemApp -SystemOS "macos" -SoftwareName "a" -search $foundMacSystems = $apps.systemid | Select-Object -Unique # if you specify a systemOS and Search, results should not contain multiple systems - foreach ($system in $foundSystems) - { + foreach ($system in $foundSystems) { $foundMacSystems = Get-JCSystem -SystemID $system $foundMacSystems.osfamily | Should -be 'darwin' } @@ -167,8 +142,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { $apps = Get-JCSystemApp -SystemOS "windows" -SoftwareName "a" -search $foundWindowsSystems = $apps.systemid | Select-Object -Unique # if you specify a systemOS and Search, results should not contain multiple systems - foreach ($system in $foundWindowsSystems) - { + foreach ($system in $foundWindowsSystems) { $foundWindowsSystems = Get-JCSystem -SystemID $system $foundWindowsSystems.osfamily | Should -be 'windows' } @@ -176,8 +150,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { $apps = Get-JCSystemApp -SystemOS "linux" -SoftwareName "a" -search $foundLinuxSystems = $apps.systemid | Select-Object -Unique # if you specify a systemOS and Search, results should not contain multiple systems - foreach ($system in $foundLinuxSystems) - { + foreach ($system in $foundLinuxSystems) { $foundLinuxSystems = Get-JCSystem -SystemID $system $foundLinuxSystems.osfamily | Should -be 'windows' } From 2f68de25efbff10b074a82cf252480810e442606 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Fri, 3 Feb 2023 09:17:42 -0700 Subject: [PATCH 076/102] break up tests by os & skip [ skip ci ] --- .../Tests/Public/Systems/Get-JCSystemApp.tests.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index 853c4032b..2e4a3480f 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -31,7 +31,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { # Get-JCSystemApp -SystemID $linux._id -SoftwareName "Curl" # Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" } - It "Tests that given a systemID, SoftwareName, SoftwareVersion, an app is returned" { + It "Tests that given a macOS systemID, SoftwareName, SoftwareVersion, an app is returned" { # MacOS $macApp = Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion $macApp.Bundle_short_version } | Should -Throw @@ -41,6 +41,8 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { { Get-JCSystemApp -SystemID $mac._id -SoftwareName "" } | Should -Throw # Using a version that doesn't exist should return nothing Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion "48.49.50.51" | Should -Be $null + } + It "Tests that given a windows systemID, SoftwareName, SoftwareVersion, an app is returned" -skip { #Windows $windowsApp = Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" @@ -51,7 +53,8 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { { Get-JCSystemApp -SystemID $windows._id -SoftwareName "" } | Should -Throw # Using a version that doesn't exist should return nothing Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" -SoftwareVersion "48.49.50.51" | Should -Be $null - + } + It "Tests that given a linux systemID, SoftwareName, SoftwareVersion, an app is returned" -skip { #Linux #Windows $linuxApp = Get-JCSystemApp -SystemID $linux._id -SoftwareName "firefox" From e3dcd1c82bacd7c1ab913da06d77d35a2e780078 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Fri, 3 Feb 2023 09:24:33 -0700 Subject: [PATCH 077/102] check if range is null, update tests [skip ci] --- .../Public/Systems/Get-JCSystemApp.ps1 | 32 ++++++++++++++----- .../Public/Systems/Get-JCSystemApp.tests.ps1 | 8 +++-- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 11539690c..d86847cdd 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -264,15 +264,21 @@ function Get-JCSystemApp () { Switch ($OSType) { "Windows" { $result = Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID") - $searchAppResultsList.AddRange($result) + if ($result) { + $searchAppResultsList.AddRange($result) + } } "Darwin" { $result = Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID") - $searchAppResultsList.AddRange($result) + if ($result) { + $searchAppResultsList.AddRange($result) + } } "Linux" { $result = Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID") - $searchAppResultsList.AddRange($result) + if ($result) { + $searchAppResultsList.AddRange($result) + } } } @@ -282,13 +288,19 @@ function Get-JCSystemApp () { Write-Debug "SystemOS $SystemOS" if ($SystemOS -eq 'Windows') { $result = Get-JcSdkSystemInsightProgram - $searchAppResultsList.AddRange($result) + if ($result) { + $searchAppResultsList.AddRange($result) + } } elseif ($SystemOS -eq 'MacOs') { $result = Get-JcSdkSystemInsightApp - $searchAppResultsList.AddRange($result) + if ($result) { + $searchAppResultsList.AddRange($result) + } } elseif ($SystemOS -eq 'Linux') { $result = Get-JcSdkSystemInsightLinuxPackage - $searchAppResultsList.AddRange($result) + if ($result) { + $searchAppResultsList.AddRange($result) + } } $filteredResults = $searchAppResultsList | Where-Object { ($_.name -match $SoftwareName) } $resultsArrayList = $filteredResults @@ -297,11 +309,15 @@ function Get-JCSystemApp () { if ($Parallel) { Write-Debug "Parallel" $result = $commands | ForEach-Object -Parallel { & $_ } - [void]$searchAppResultsList.AddRange($result) + if ($result) { + [void]$searchAppResultsList.AddRange($result) + } } else { $result = $commands | ForEach-Object { & $_ } - [void]$searchAppResultsList.AddRange($result) + if ($result) { + [void]$searchAppResultsList.AddRange($result) + } } $filteredResults = $searchAppResultsList | Where-Object { ($_.name -match $SoftwareName) } $resultsArrayList = $filteredResults diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index 2e4a3480f..32621472d 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -132,7 +132,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { $foundWindowsSystems.count | should -Be 1 $foundLinuxSystems.count | should -Be 1 } - It "Tests the search param with SystemOS" { + It "Tests the search param with macos SystemOS" { # MacOS $apps = Get-JCSystemApp -SystemOS "macos" -SoftwareName "a" -search $foundMacSystems = $apps.systemid | Select-Object -Unique @@ -141,6 +141,8 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { $foundMacSystems = Get-JCSystem -SystemID $system $foundMacSystems.osfamily | Should -be 'darwin' } + } + It "Tests the search param with windows SystemOS" { # Windows $apps = Get-JCSystemApp -SystemOS "windows" -SoftwareName "a" -search $foundWindowsSystems = $apps.systemid | Select-Object -Unique @@ -149,13 +151,15 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { $foundWindowsSystems = Get-JCSystem -SystemID $system $foundWindowsSystems.osfamily | Should -be 'windows' } + } + It "Tests the search param with linux SystemOS" { # Linux $apps = Get-JCSystemApp -SystemOS "linux" -SoftwareName "a" -search $foundLinuxSystems = $apps.systemid | Select-Object -Unique # if you specify a systemOS and Search, results should not contain multiple systems foreach ($system in $foundLinuxSystems) { $foundLinuxSystems = Get-JCSystem -SystemID $system - $foundLinuxSystems.osfamily | Should -be 'windows' + $foundLinuxSystems.osfamily | Should -be 'linux' } } From 9f99f9a6b077b3f5c9c277e6a3a364eb05357365 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Fri, 3 Feb 2023 10:13:13 -0700 Subject: [PATCH 078/102] JCSystemApp Tests (skip windows/ linux for now) --- .../Public/Systems/Get-JCSystemApp.tests.ps1 | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index 32621472d..2d95ece9f 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -163,7 +163,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { } } - It "Tests compatability with the SDKs" { + It "Tests compatability macOS with the SDKs" { #MacOS $sdkMac = Get-JcSdkSystemInsightApp -filter @("system_id:eq:$($mac._id)", "name:eq:Chess.app") $moduleMac = Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" @@ -174,22 +174,24 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { # SDK Results should look exactly like module results when search is provided $sdkMac.id | Should -Be $moduleMacSearch.id $sdkMac.name | Should -Be $moduleMacSearch.name - + } + It "Tests compatability windows with the SDKs" -skip { #Windows $sdkWindows = Get-JcSdkSystemInsightProgram -filter @("system_id:eq:$($windows._id)", "name:eq:Microsoft Edge") - $moduleWindows = Get-JcSdkSystemInsightProgram -SystemID $windows._id -SoftwareName "Microsoft Edge" - $moduleWindowsSearch = Get-JcSdkSystemInsightProgram -SystemID $windows._id -SoftwareName "microsoft edge" -Search + $moduleWindows = Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" + $moduleWindowsSearch = Get-JCSystemApp -SystemID $windows._id -SoftwareName "microsoft edge" -Search # SDK Results should look exactly like module results when exact name is specified $sdkWindows.id | Should -Be $moduleWindows.id $sdkWindows.name | Should -Be $moduleWindows.name # SDK Results should look exactly like module results when search is provided $sdkWindows.id | Should -Be $moduleWindowsSearch.id $sdkWindows.name | Should -Be $moduleWindowsSearch.name - + } + It "Tests compatability linux with the SDKs" -skip { #Linux - $sdkLinux = Get-JcSdkSystemInsightLinuxPackage -filter @("system_id:eq:$($linux._id)", "name:eq:firefox") - $moduleLinux = Get-JcSdkSystemInsightLinuxPackage -SystemID $linux._id -SoftwareName "firefox" - $moduleLinuxSearch = Get-JcSdkSystemInsightLinuxPackage -SystemID $linux._id -SoftwareName "firefox" -Search + $sdkLinux = Get-JcSdkSystemInsightLinuxPackage -filter @("system_id:eq:$($linux._id)", "name:eq:Curl") + $moduleLinux = Get-JCSystemApp -SystemID $linux._id -SoftwareName "Curl" + $moduleLinuxSearch = Get-JCSystemApp -SystemID $linux._id -SoftwareName "curl" -Search # SDK Results should look exactly like module results when exact name is specified $sdkLinux.id | Should -Be $moduleLinux.id $sdkLinux.name | Should -Be $moduleLinux.name @@ -224,6 +226,3 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" | Should -Not -BeNullOrEmpty } } - - - From 90d98609248f0d53df18014b0c0df31b078b0dc0 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Fri, 3 Feb 2023 17:23:22 +0000 Subject: [PATCH 079/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index ba6b37a0c..f8bf10130 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] +Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 346807c2f..5510b7363 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 2/2/2023 +# Generated on: 2/3/2023 # @{ From a9027f43fac072468e62deb067b636787e83451c Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Fri, 3 Feb 2023 17:31:00 +0000 Subject: [PATCH 080/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index f8bf10130..ba6b37a0c 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] +Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index 145643723..15e099955 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.2.0.7678-202302021934 + 2.2.0.7726-202302031728 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud From 45c71cec58344c3c484a1f44474b7ddb047ffc12 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Fri, 3 Feb 2023 12:37:39 -0700 Subject: [PATCH 081/102] last set of skips --- .../Public/Systems/Get-JCSystemApp.tests.ps1 | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index 2d95ece9f..6183b5d3d 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -57,14 +57,14 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests that given a linux systemID, SoftwareName, SoftwareVersion, an app is returned" -skip { #Linux #Windows - $linuxApp = Get-JCSystemApp -SystemID $linux._id -SoftwareName "firefox" - { Get-JCSystemApp -SystemID $linux._id -SoftwareName "firefox" -SoftwareVersion $linuxApp.version } | Should -Throw + $linuxApp = Get-JCSystemApp -SystemID $linux._id -SoftwareName "curl" + { Get-JCSystemApp -SystemID $linux._id -SoftwareName "curl" -SoftwareVersion $linuxApp.version } | Should -Throw # A null value version shouldn't be accepted - { Get-JCSystemApp -SystemID $linux._id -SoftwareName "firefox" -SoftwareVersion "" } | Should -Throw + { Get-JCSystemApp -SystemID $linux._id -SoftwareName "curl" -SoftwareVersion "" } | Should -Throw # A null value Name shouldn't be accepted { Get-JCSystemApp -SystemID $linux._id -SoftwareName "" } | Should -Throw # Using a version that doesn't exist should return nothing - Get-JCSystemApp -SystemID $linux._id -SoftwareName "firefox" -SoftwareVersion "48.49.50.51" | Should -Be $null + Get-JCSystemApp -SystemID $linux._id -SoftwareName "curl" -SoftwareVersion "48.49.50.51" | Should -Be $null } # Create tests for Search It "Tests for search given SystemOs and SoftwareName for MacOS Systems" { @@ -111,12 +111,14 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { #Tests for each OS # results with no data should be null or empty Get-JCSystemApp -SoftwareName "chess" | Should -BeNullOrEmpty - Get-JCSystemApp -SoftwareName "microsoft edge" | Should -BeNullOrEmpty - Get-JCSystemApp -SoftwareName "firefox" | Should -BeNullOrEmpty + # TODO: add when system insights is on each system + # Get-JCSystemApp -SoftwareName "microsoft edge" | Should -BeNullOrEmpty + # Get-JCSystemApp -SoftwareName "curl" | Should -BeNullOrEmpty # when search is used to find an app the results should not be null or empty Get-JCSystemApp -SoftwareName "chess" -Search | Should -Not -BeNullOrEmpty - Get-JCSystemApp -SoftwareName "microsoft edge" -Search | Should -Not -BeNullOrEmpty - Get-JCSystemApp -SoftwareName "firefox" -Search | Should -Not -BeNullOrEmpty + # TODO: add when system insights is on each system + # Get-JCSystemApp -SoftwareName "microsoft edge" -Search | Should -Not -BeNullOrEmpty + # Get-JCSystemApp -SoftwareName "curl" -Search | Should -Not -BeNullOrEmpty } It "Tests the search param with systemID" { From bf400daaa3664ab3340900b9c78b6788926711a8 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Fri, 3 Feb 2023 19:46:12 +0000 Subject: [PATCH 082/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index 15e099955..91c06f33e 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.2.0.7726-202302031728 + 2.2.0.7738-202302031943 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud From 8f429de74db57981973e33a9e5d6726fadeaaaaf Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Fri, 3 Feb 2023 14:25:26 -0700 Subject: [PATCH 083/102] re-run all tests --- .../Public/Systems/Get-JCSystemApp.tests.ps1 | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index 6183b5d3d..492de3331 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -27,9 +27,8 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests that given a systemID, SoftwareName, an app is returned" { # Chess is always installed on MacOS and it CAN NOT be removed no matter what Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" - # Skip until both systems have system insights enabled in pester orgs - # Get-JCSystemApp -SystemID $linux._id -SoftwareName "Curl" - # Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" + Get-JCSystemApp -SystemID $linux._id -SoftwareName "Curl" + Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" } It "Tests that given a macOS systemID, SoftwareName, SoftwareVersion, an app is returned" { # MacOS @@ -42,7 +41,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { # Using a version that doesn't exist should return nothing Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion "48.49.50.51" | Should -Be $null } - It "Tests that given a windows systemID, SoftwareName, SoftwareVersion, an app is returned" -skip { + It "Tests that given a windows systemID, SoftwareName, SoftwareVersion, an app is returned" { #Windows $windowsApp = Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" @@ -54,7 +53,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { # Using a version that doesn't exist should return nothing Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" -SoftwareVersion "48.49.50.51" | Should -Be $null } - It "Tests that given a linux systemID, SoftwareName, SoftwareVersion, an app is returned" -skip { + It "Tests that given a linux systemID, SoftwareName, SoftwareVersion, an app is returned" { #Linux #Windows $linuxApp = Get-JCSystemApp -SystemID $linux._id -SoftwareName "curl" @@ -80,7 +79,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { # Searching chess on MacOs should return a result { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemOs "MacOs" } | should -Not -Throw } - It "Tests for search given SystemOs and SoftwareName for Linux Systems" -skip { + It "Tests for search given SystemOs and SoftwareName for Linux Systems" { # Curl is always installed on linux { Get-JCSystemApp -Search | Should -Throw } { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemID $linux._Id } | should -Not -Throw @@ -93,7 +92,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { # Searching Curl on linux should return a result { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemOs "linux" } | should -Not -Throw } - It "Tests for search given SystemOs and SoftwareName for Windows Systems" -skip { + It "Tests for search given SystemOs and SoftwareName for Windows Systems" { # Microsoft Edge is always installed on windows { Get-JCSystemApp -Search | Should -Throw } { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemID $windows._Id } | should -Not -Throw @@ -111,14 +110,12 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { #Tests for each OS # results with no data should be null or empty Get-JCSystemApp -SoftwareName "chess" | Should -BeNullOrEmpty - # TODO: add when system insights is on each system - # Get-JCSystemApp -SoftwareName "microsoft edge" | Should -BeNullOrEmpty - # Get-JCSystemApp -SoftwareName "curl" | Should -BeNullOrEmpty + Get-JCSystemApp -SoftwareName "microsoft edge" | Should -BeNullOrEmpty + Get-JCSystemApp -SoftwareName "curl" | Should -BeNullOrEmpty # when search is used to find an app the results should not be null or empty Get-JCSystemApp -SoftwareName "chess" -Search | Should -Not -BeNullOrEmpty - # TODO: add when system insights is on each system - # Get-JCSystemApp -SoftwareName "microsoft edge" -Search | Should -Not -BeNullOrEmpty - # Get-JCSystemApp -SoftwareName "curl" -Search | Should -Not -BeNullOrEmpty + Get-JCSystemApp -SoftwareName "microsoft edge" -Search | Should -Not -BeNullOrEmpty + Get-JCSystemApp -SoftwareName "curl" -Search | Should -Not -BeNullOrEmpty } It "Tests the search param with systemID" { @@ -177,7 +174,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { $sdkMac.id | Should -Be $moduleMacSearch.id $sdkMac.name | Should -Be $moduleMacSearch.name } - It "Tests compatability windows with the SDKs" -skip { + It "Tests compatability windows with the SDKs" { #Windows $sdkWindows = Get-JcSdkSystemInsightProgram -filter @("system_id:eq:$($windows._id)", "name:eq:Microsoft Edge") $moduleWindows = Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" @@ -189,7 +186,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { $sdkWindows.id | Should -Be $moduleWindowsSearch.id $sdkWindows.name | Should -Be $moduleWindowsSearch.name } - It "Tests compatability linux with the SDKs" -skip { + It "Tests compatability linux with the SDKs" { #Linux $sdkLinux = Get-JcSdkSystemInsightLinuxPackage -filter @("system_id:eq:$($linux._id)", "name:eq:Curl") $moduleLinux = Get-JCSystemApp -SystemID $linux._id -SoftwareName "Curl" From 123c7a8f2ae8033fa323587caa1bce83a6e3b6cc Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Fri, 3 Feb 2023 21:32:27 +0000 Subject: [PATCH 084/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index ba6b37a0c..f8bf10130 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] +Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index 91c06f33e..7eb381bd0 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.2.0.7738-202302031943 + 2.2.0.7750-202302032130 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud From a5d5862e233134a24f2ac67c356d499b3893e78f Mon Sep 17 00:00:00 2001 From: Ken Maranion <97972790+kmaranionjc@users.noreply.github.com> Date: Fri, 3 Feb 2023 15:03:56 -0800 Subject: [PATCH 085/102] Update PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 [skip ci] Co-authored-by: Joe Workman <54448601+jworkmanjc@users.noreply.github.com> --- PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index d86847cdd..05a6db968 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -45,7 +45,7 @@ function Get-JCSystemApp () { } if ($SystemID) { - $OSType = Get-JcSdkSystem -ID $SystemID | Select-Object -ExpandProperty OSFamily + $OSType = Get-JcSdkSystem -ID $SystemID -Fields osfamily | Select-Object -ExpandProperty OSFamily } else { $OSType = $SystemOS if ($OSType -eq 'macOS') { From 8398d32aa391b739c7f0d07839fefa3d67f43abb Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Mon, 6 Feb 2023 08:17:46 -0800 Subject: [PATCH 086/102] pr changes --- .../Public/Systems/Get-JCSystemApp.ps1 | 105 ++++++++---------- 1 file changed, 49 insertions(+), 56 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 05a6db968..d3b425905 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -8,9 +8,9 @@ function Get-JCSystemApp () { [ValidateSet('Windows', 'macOS', 'Linux')][ValidateNotNullorEmpty()] [string]$SystemOS, [Parameter(Mandatory = $false, HelpMessage = 'The name of the application you want to search for ex. (JumpCloud-Agent, Slack). SoftwareName will always query the "name" property from system insights. Note, for macOS systems, ".app" will be applied. This field is case sensitive.' )][ValidateNotNullorEmpty()] - [string]$SoftwareName, + [string]$name, [Parameter(Mandatory = $false, HelpMessage = 'The version of the application you want to search for ex. 1.1.2')][ValidateNotNullorEmpty()] - [string]$SoftwareVersion, + [string]$version, [Parameter(Mandatory = $false, ParameterSetName = "Search", HelpMessage = "The Search parameter can be used in conjunction with the 'SoftwareName' parameter to perform a case-insensitive search for software. This is parameter switch is inherently slower than using just the 'softwareName' parameter but can be useful to identify the names of software titles on systems. If the exact name of a software title isn't known, the 'search' parameter can be used to find that name. Ex. Get-JCSoftwareApp -SystemID '63c9654cb357249876bfc05b' -SoftwareName 'chrome' -Search will attempt to perform a match for the term 'chrome' on all applications/ programs for the specified system. If a match, partial-match, case-insensitive match is found, it would be returned in the results. In this case, the 'name' of the software title is 'Google Chrome'. A subsequent search could be run to return all macOS systems which have 'Google Chrome' installed. Ex. Get-JCSystemApp -SystemOS macOS -softwareName 'Google Chrome', this would perform an exact match search for macOS systems that have google chrome which is substantially quicker than running: Get-JCSystemApp -SystemOS macOS -softwareName 'google chrome' -Search. The search parameter is a tool to help identify the 'name' attribute of software titles when searching bulk systems its recommended to not use the search parameter and instead specify the exact (case sensitive) name of the software title.")] [switch]$Search, [Parameter(DontShow, Mandatory = $false, ParameterSetName = "All", HelpMessage = 'Search for a specific application by name from all systems in the org')] @@ -56,32 +56,32 @@ function Get-JCSystemApp () { switch ($OSType) { 'Windows' { # If Software title, version, and system ID are passed then return specific app - if ($SoftwareVersion -and $SoftwareName) { + if ($version -and $name) { if ($SystemID) { - Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { + Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID", "name:eq:$name", "version:eq:$version") | ForEach-Object { [void]$resultsArrayList.Add($_) } } elseif ($SystemOS) { - Get-JcSdkSystemInsightProgram -Filter @("name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { + Get-JcSdkSystemInsightProgram -Filter @("name:eq:$name", "version:eq:$version") | ForEach-Object { [void]$resultsArrayList.Add($_) } } - } elseif ($SoftwareName) { + } elseif ($name) { if ($SystemID) { - Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName") | ForEach-Object { + Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID", "name:eq:$name") | ForEach-Object { [void]$resultsArrayList.Add($_) } } elseif ($SystemOS) { - Get-JcSdkSystemInsightProgram -Filter @("name:eq:$SoftwareName") | ForEach-Object { + Get-JcSdkSystemInsightProgram -Filter @("name:eq:$name") | ForEach-Object { [void]$resultsArrayList.Add($_) } } } elseif ($SystemID) { - if ($SoftwareVersion) { + if ($version) { Write-Error "Cannot search for software version on Windows without software name." } else { Get-JcSdkSystemInsightProgram -Filter @("system_id:eq:$SystemID") | ForEach-Object { @@ -89,7 +89,7 @@ function Get-JCSystemApp () { } } } elseif ($SystemOS) { - if ($SoftwareVersion) { + if ($version) { Write-Error "Cannot search for software version on Windows without software name." } else { Get-JcSdkSystemInsightProgram | ForEach-Object { @@ -100,34 +100,31 @@ function Get-JCSystemApp () { } 'Darwin' { - if ($SoftwareName) { + if ($name) { # Check for .app at the end of the software name - $macOsSoftwareName = $SoftwareName - if (-not $SoftwareName.EndsWith('.app')) { - Write-Debug "Adding .app to $SoftwareName" - if ($SoftwareName.EndsWith('.App')) { - Write-Debug "Replacing .App with .app" - $macOsSoftwareName = $macOsSoftwareName.Replace('.App', '.app') - } else { - $macOsSoftwareName = "$macOsSoftwareName.app" - } + $macOsSoftwareName = $name + $ending = $macOsSoftwareName.Substring($macOsSoftwareName.Length - 4) + If ($ending -match '.app') { + $macOsSoftwareName = $macOsSoftwareName.Replace($ending, $ending.toLower()) + Write-Debug "$macOsSoftwareName" } else { - Write-Debug "$macOsSoftwareName already ends with .app" + $macOsSoftwareName = "$macOsSoftwareName.app" + Write-Debug "$macOsSoftwareName" } } # If Software title, version, and system ID are passed then return specific app - if ($SoftwareVersion -and $macOsSoftwareName) { + if ($version -and $macOsSoftwareName) { - Write-Debug "Trying to get app with name $macOsSoftwareName and version $SoftwareVersion" + Write-Debug "Trying to get app with name $macOsSoftwareName and version $version" if ($SystemID) { - Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID", "name:eq:$macOsSoftwareName", "bundle_short_version:eq:$SoftwareVersion") | ForEach-Object { + Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID", "name:eq:$macOsSoftwareName", "bundle_short_version:eq:$version") | ForEach-Object { [void]$resultsArrayList.Add($_) } } elseif ($SystemOS) { - Get-JcSdkSystemInsightApp -Filter @("name:eq:$macOsSoftwareName", "bundle_short_version:eq:$SoftwareVersion") | ForEach-Object { + Get-JcSdkSystemInsightApp -Filter @("name:eq:$macOsSoftwareName", "bundle_short_version:eq:$version") | ForEach-Object { [void]$resultsArrayList.Add($_) } } @@ -144,7 +141,7 @@ function Get-JCSystemApp () { } } } elseif ($SystemID) { - if ($SoftwareVersion) { + if ($version) { Write-Error "Cannot search for software version on MacOs without software name." } else { Get-JcSdkSystemInsightApp -Filter @("system_id:eq:$SystemID") | ForEach-Object { @@ -152,7 +149,7 @@ function Get-JCSystemApp () { } } } elseif ($SystemOS) { - if ($SoftwareVersion) { + if ($version) { Write-Error "Cannot search for software version on MacOs without software name." } else { Get-JcSdkSystemInsightApp | ForEach-Object { @@ -164,30 +161,30 @@ function Get-JCSystemApp () { } 'Linux' { - if ($SoftwareVersion -and $SoftwareName) { + if ($version -and $name) { if ($SystemID) { - Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { + Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID", "name:eq:$name", "version:eq:$version") | ForEach-Object { [void]$resultsArrayList.Add($_) } } elseif ($SystemOS) { - Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$SoftwareName", "version:eq:$SoftwareVersion") | ForEach-Object { + Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$name", "version:eq:$version") | ForEach-Object { [void]$resultsArrayList.Add($_) } } - } elseif ($SoftwareName) { + } elseif ($name) { if ($SystemID) { - Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID", "name:eq:$SoftwareName") | ForEach-Object { + Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID", "name:eq:$name") | ForEach-Object { [void]$resultsArrayList.Add($_) } } elseif ($SystemOS) { - Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$SoftwareName") | ForEach-Object { + Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$name") | ForEach-Object { [void]$resultsArrayList.Add($_) } } } elseif ($SystemID) { - if ($SoftwareVersion) { + if ($version) { Write-Error "Cannot search for software version on Linux without software name." } else { Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID") | ForEach-Object { @@ -196,7 +193,7 @@ function Get-JCSystemApp () { } } elseif ($SystemOS) { - if ($SoftwareVersion) { + if ($version) { Write-Error "Cannot search for software version on Linux without software name." } else { Get-JcSdkSystemInsightLinuxPackage | ForEach-Object { @@ -207,34 +204,30 @@ function Get-JCSystemApp () { } } - } elseif ($SoftwareName) { + } elseif ($name) { # Loop through each OS and get the results - Write-Debug "SoftwareName only passed. Getting all software with name $SoftwareName" + Write-Debug "SoftwareName only passed. Getting all software with name $name" foreach ($os in @('Windows', 'MacOs', 'Linux')) { if ($os -eq 'Windows') { - Get-JcSdkSystemInsightProgram -Filter @("name:eq:$SoftwareName") | ForEach-Object { + Get-JcSdkSystemInsightProgram -Filter @("name:eq:$name") | ForEach-Object { [void]$resultsArrayList.Add($_) } } elseif ($os -eq 'MacOs') { - $macOsSoftwareName = $SoftwareName - if (-not $SoftwareName.EndsWith('.app')) { - Write-Debug "Adding .app to $SoftwareName" - if ($SoftwareName.EndsWith('.App')) { - Write-Debug "Replacing .App with .app" - $macOsSoftwareName = $macOsSoftwareName.Replace('.App', '.app') - } else { - $macOsSoftwareName = "$macOsSoftwareName.app" - } + $macOsSoftwareName = $name + $ending = $macOsSoftwareName.Substring($macOsSoftwareName.Length - 4) + If ($ending -match '.app') { + $macOsSoftwareName = $macOsSoftwareName.Replace($ending, $ending.toLower()) + Write-Debug "$macOsSoftwareName" } else { - Write-Debug "$macOsSoftwareName already ends with .app" + $macOsSoftwareName = "$macOsSoftwareName.app" + Write-Debug "$macOsSoftwareName" } Get-JcSdkSystemInsightApp -Filter @("name:eq:$macOsSoftwareName") | ForEach-Object { [void]$resultsArrayList.Add($_) } } elseif ($os -eq 'Linux') { - Write-Debug "Getting Linux software $SoftwareName" - Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$SoftwareName") | ForEach-Object { + Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$name") | ForEach-Object { [void]$resultsArrayList.Add($_) } } @@ -255,9 +248,9 @@ function Get-JCSystemApp () { } } Search { # Search for softwareName - Write-Debug "Search $SoftwareName" - if ($SoftwareName) { - if ($SoftwareVersion) { + Write-Debug "Search $name" + if ($name) { + if ($version) { Throw 'You cannot specify software version when using -search for a software name' } elseif ($SystemId) { $OSType = Get-JcSdkSystem -ID $SystemID | Select-Object -ExpandProperty OSFamily @@ -282,7 +275,7 @@ function Get-JCSystemApp () { } } - $filteredResults = $searchAppResultsList | Where-Object { ($_.name -match $SoftwareName) } + $filteredResults = $searchAppResultsList | Where-Object { ($_.name -match $name) } $resultsArrayList = $filteredResults } elseif ($SystemOS) { Write-Debug "SystemOS $SystemOS" @@ -302,7 +295,7 @@ function Get-JCSystemApp () { $searchAppResultsList.AddRange($result) } } - $filteredResults = $searchAppResultsList | Where-Object { ($_.name -match $SoftwareName) } + $filteredResults = $searchAppResultsList | Where-Object { ($_.name -match $name) } $resultsArrayList = $filteredResults } else { @@ -319,7 +312,7 @@ function Get-JCSystemApp () { [void]$searchAppResultsList.AddRange($result) } } - $filteredResults = $searchAppResultsList | Where-Object { ($_.name -match $SoftwareName) } + $filteredResults = $searchAppResultsList | Where-Object { ($_.name -match $name) } $resultsArrayList = $filteredResults } From b00eff0419c394c8505ac8350a56956f81495d3d Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 6 Feb 2023 16:25:24 +0000 Subject: [PATCH 087/102] Updating PowerShell Module;[skip ci] --- .../JumpCloud Module/Docs/Get-JCSystemApp.md | 49 ++++++------- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- .../JumpCloud Module/en-Us/JumpCloud-help.xml | 72 +++++++++---------- 3 files changed, 60 insertions(+), 63 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index afd1836e0..a40a29dd6 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -14,14 +14,14 @@ Returns the applications/programs/linux packages installed on JumpCloud managed ### All (Default) ``` -Get-JCSystemApp [-SystemID ] [-SystemOS ] [-SoftwareName ] [-SoftwareVersion ] +Get-JCSystemApp [-SystemID ] [-SystemOS ] [-name ] [-version ] [] ``` ### Search ``` -Get-JCSystemApp [-SystemID ] [-SystemOS ] [-SoftwareName ] [-SoftwareVersion ] - [-Search] [] +Get-JCSystemApp [-SystemID ] [-SystemOS ] [-name ] [-version ] [-Search] + [] ``` ## DESCRIPTION @@ -64,14 +64,12 @@ Returns any 'jumpcloud-agent' software installed in all the os systems ## PARAMETERS -### -Search -Search for a specific application by from all systems in the org ex. -(Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") -THIS PARAMETER DOES NOT TAKE INPUT +### -name +The name of the application you want to search for ex. (JumpCloud-Agent, Slack). SoftwareName will always query the "name" property from system insights. Note, for macOS systems, ".app" will be applied. This field is case sensitive. ```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: Search +Type: System.String +Parameter Sets: (All) Aliases: Required: False @@ -81,14 +79,14 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -SoftwareName -The name of the application you want to search for ex. -(JumpCloud-Agent, Slack) -SoftwareName will always query the 'name' property from system insights. Note, for macOS systems, '.app' will be applied +### -Search +Search for a specific application by from all systems in the org ex. +(Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") +THIS PARAMETER DOES NOT TAKE INPUT ```yaml -Type: System.String -Parameter Sets: (All) +Type: System.Management.Automation.SwitchParameter +Parameter Sets: Search Aliases: Required: False @@ -98,9 +96,8 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -SoftwareVersion -The version of the application you want to search for ex. -1.1.2 +### -SystemID +The System Id of the JumpCloud system you want to search for applications ```yaml Type: System.String @@ -114,35 +111,35 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -SystemID -The System Id of the JumpCloud system you want to search for applications +### -SystemOS +The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. +(Windows, macOs, Linux)) ```yaml Type: System.String Parameter Sets: (All) Aliases: +Accepted values: Windows, macOS, Linux Required: False Position: Named Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -SystemOS -The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. -(Windows, macOs, Linux)) +### -version +The version of the application you want to search for ex. 1.1.2 ```yaml Type: System.String Parameter Sets: (All) Aliases: -Accepted values: Windows, macOS, Linux Required: False Position: Named Default value: None -Accept pipeline input: True (ByPropertyName) +Accept pipeline input: False Accept wildcard characters: False ``` diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 5510b7363..3f01688e1 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 2/3/2023 +# Generated on: 2/6/2023 # @{ diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index 13fdc2ffa..95aa36ad9 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -7064,20 +7064,9 @@ PS C:\> $BackupJcOrganizationResults.User Get-JCSystemApp - Search - - Search for a specific application by from all systems in the org ex. (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") THIS PARAMETER DOES NOT TAKE INPUT - - - System.Management.Automation.SwitchParameter - - - False - - - SoftwareName + name - The name of the application you want to search for ex. (JumpCloud-Agent, Slack) SoftwareName will always query the 'name' property from system insights. Note, for macOS systems, '.app' will be applied + The name of the application you want to search for ex. (JumpCloud-Agent, Slack). SoftwareName will always query the "name" property from system insights. Note, for macOS systems, ".app" will be applied. This field is case sensitive. System.String @@ -7087,16 +7076,15 @@ PS C:\> $BackupJcOrganizationResults.User None - SoftwareVersion + Search - The version of the application you want to search for ex. 1.1.2 + Search for a specific application by from all systems in the org ex. (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") THIS PARAMETER DOES NOT TAKE INPUT - System.String - System.String + System.Management.Automation.SwitchParameter - None + False SystemID @@ -7127,37 +7115,49 @@ PS C:\> $BackupJcOrganizationResults.User None + + version + + The version of the application you want to search for ex. 1.1.2 + + System.String + + System.String + + + None + - Search + name - Search for a specific application by from all systems in the org ex. (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") THIS PARAMETER DOES NOT TAKE INPUT + The name of the application you want to search for ex. (JumpCloud-Agent, Slack). SoftwareName will always query the "name" property from system insights. Note, for macOS systems, ".app" will be applied. This field is case sensitive. - System.Management.Automation.SwitchParameter + System.String - System.Management.Automation.SwitchParameter + System.String - False + None - SoftwareName + Search - The name of the application you want to search for ex. (JumpCloud-Agent, Slack) SoftwareName will always query the 'name' property from system insights. Note, for macOS systems, '.app' will be applied + Search for a specific application by from all systems in the org ex. (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") THIS PARAMETER DOES NOT TAKE INPUT - System.String + System.Management.Automation.SwitchParameter - System.String + System.Management.Automation.SwitchParameter - None + False - SoftwareVersion + SystemID - The version of the application you want to search for ex. 1.1.2 + The System Id of the JumpCloud system you want to search for applications System.String @@ -7166,10 +7166,10 @@ PS C:\> $BackupJcOrganizationResults.User None - - SystemID + + SystemOS - The System Id of the JumpCloud system you want to search for applications + The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, macOs, Linux)) System.String @@ -7178,10 +7178,10 @@ PS C:\> $BackupJcOrganizationResults.User None - - SystemOS + + version - The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, macOs, Linux)) + The version of the application you want to search for ex. 1.1.2 System.String From e0f88b6cebb30c91dfa57b9ec46979c3ae02d53b Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Mon, 6 Feb 2023 08:59:43 -0800 Subject: [PATCH 088/102] updated the tests --- .../Public/Systems/Get-JCSystemApp.tests.ps1 | 122 +++++++++--------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index 492de3331..25e40060a 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -26,103 +26,103 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests that given a systemID, SoftwareName, an app is returned" { # Chess is always installed on MacOS and it CAN NOT be removed no matter what - Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" - Get-JCSystemApp -SystemID $linux._id -SoftwareName "Curl" - Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" + Get-JCSystemApp -SystemID $mac._id -name "Chess" + Get-JCSystemApp -SystemID $linux._id -name "Curl" + Get-JCSystemApp -SystemID $windows._id -name "Microsoft Edge" } It "Tests that given a macOS systemID, SoftwareName, SoftwareVersion, an app is returned" { # MacOS - $macApp = Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" - { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion $macApp.Bundle_short_version } | Should -Throw + $macApp = Get-JCSystemApp -SystemID $mac._id -name "Chess" + { Get-JCSystemApp -SystemID $mac._id -name "Chess" -version $macApp.Bundle_short_version } | Should -Throw # A null value version shouldn't be accepted - { Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion "" } | Should -Throw + { Get-JCSystemApp -SystemID $mac._id -name "Chess" -version "" } | Should -Throw # A null value Name shouldn't be accepted - { Get-JCSystemApp -SystemID $mac._id -SoftwareName "" } | Should -Throw + { Get-JCSystemApp -SystemID $mac._id -name "" } | Should -Throw # Using a version that doesn't exist should return nothing - Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" -SoftwareVersion "48.49.50.51" | Should -Be $null + Get-JCSystemApp -SystemID $mac._id -name "Chess" -version "48.49.50.51" | Should -Be $null } It "Tests that given a windows systemID, SoftwareName, SoftwareVersion, an app is returned" { #Windows - $windowsApp = Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" - { Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" -SoftwareVersion $windowsApp.version } | Should -Throw + $windowsApp = Get-JCSystemApp -SystemID $windows._id -name "Microsoft Edge" + { Get-JCSystemApp -SystemID $windows._id -name "Microsoft Edge" -version $windowsApp.version } | Should -Throw # A null value version shouldn't be accepted - { Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" -SoftwareVersion "" } | Should -Throw + { Get-JCSystemApp -SystemID $windows._id -name "Microsoft Edge" -version "" } | Should -Throw # A null value Name shouldn't be accepted - { Get-JCSystemApp -SystemID $windows._id -SoftwareName "" } | Should -Throw + { Get-JCSystemApp -SystemID $windows._id -name "" } | Should -Throw # Using a version that doesn't exist should return nothing - Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" -SoftwareVersion "48.49.50.51" | Should -Be $null + Get-JCSystemApp -SystemID $windows._id -name "Microsoft Edge" -version "48.49.50.51" | Should -Be $null } It "Tests that given a linux systemID, SoftwareName, SoftwareVersion, an app is returned" { #Linux #Windows - $linuxApp = Get-JCSystemApp -SystemID $linux._id -SoftwareName "curl" - { Get-JCSystemApp -SystemID $linux._id -SoftwareName "curl" -SoftwareVersion $linuxApp.version } | Should -Throw + $linuxApp = Get-JCSystemApp -SystemID $linux._id -name "curl" + { Get-JCSystemApp -SystemID $linux._id -name "curl" -version $linuxApp.version } | Should -Throw # A null value version shouldn't be accepted - { Get-JCSystemApp -SystemID $linux._id -SoftwareName "curl" -SoftwareVersion "" } | Should -Throw + { Get-JCSystemApp -SystemID $linux._id -name "curl" -version "" } | Should -Throw # A null value Name shouldn't be accepted - { Get-JCSystemApp -SystemID $linux._id -SoftwareName "" } | Should -Throw + { Get-JCSystemApp -SystemID $linux._id -name "" } | Should -Throw # Using a version that doesn't exist should return nothing - Get-JCSystemApp -SystemID $linux._id -SoftwareName "curl" -SoftwareVersion "48.49.50.51" | Should -Be $null + Get-JCSystemApp -SystemID $linux._id -name "curl" -version "48.49.50.51" | Should -Be $null } # Create tests for Search It "Tests for search given SystemOs and SoftwareName for MacOS Systems" { # Chess is always installed on MacOS and it CAN NOT be removed no matter what { Get-JCSystemApp -Search | Should -Throw } - { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemID $mac.Id } | should -Not -Throw - { Get-JCSystemApp -Search -SoftwareName "Chess" } | should -Not -Throw - { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemOs "MacOs" } | should -Not -Throw + { Get-JCSystemApp -Search -name "Chess" -SystemID $mac.Id } | should -Not -Throw + { Get-JCSystemApp -Search -name "Chess" } | should -Not -Throw + { Get-JCSystemApp -Search -name "Chess" -SystemOs "MacOs" } | should -Not -Throw # A null value version shouldn't be accepted - { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemOs "" | Should -Throw } + { Get-JCSystemApp -Search -name "Chess" -SystemOs "" | Should -Throw } # A null value version shouldn't be accepted - { Get-JCSystemApp -Search -SoftwareName "" -SystemOs "MacOs" | Should -Throw } + { Get-JCSystemApp -Search -name "" -SystemOs "MacOs" | Should -Throw } # Searching chess on MacOs should return a result - { Get-JCSystemApp -Search -SoftwareName "Chess" -SystemOs "MacOs" } | should -Not -Throw + { Get-JCSystemApp -Search -name "Chess" -SystemOs "MacOs" } | should -Not -Throw } It "Tests for search given SystemOs and SoftwareName for Linux Systems" { # Curl is always installed on linux { Get-JCSystemApp -Search | Should -Throw } - { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemID $linux._Id } | should -Not -Throw - { Get-JCSystemApp -Search -SoftwareName "Curl" } | should -Not -Throw - { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemOs "linux" } | should -Not -Throw + { Get-JCSystemApp -Search -name "Curl" -SystemID $linux._Id } | should -Not -Throw + { Get-JCSystemApp -Search -name "Curl" } | should -Not -Throw + { Get-JCSystemApp -Search -name "Curl" -SystemOs "linux" } | should -Not -Throw # A null value version shouldn't be accepted - { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemOs "" | Should -Throw } + { Get-JCSystemApp -Search -name "Curl" -SystemOs "" | Should -Throw } # A null value version shouldn't be accepted - { Get-JCSystemApp -Search -SoftwareName "" -SystemOs "linux" | Should -Throw } + { Get-JCSystemApp -Search -name "" -SystemOs "linux" | Should -Throw } # Searching Curl on linux should return a result - { Get-JCSystemApp -Search -SoftwareName "Curl" -SystemOs "linux" } | should -Not -Throw + { Get-JCSystemApp -Search -name "Curl" -SystemOs "linux" } | should -Not -Throw } It "Tests for search given SystemOs and SoftwareName for Windows Systems" { # Microsoft Edge is always installed on windows { Get-JCSystemApp -Search | Should -Throw } - { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemID $windows._Id } | should -Not -Throw - { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" } | should -Not -Throw - { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "windows" } | should -Not -Throw + { Get-JCSystemApp -Search -name "Microsoft Edge" -SystemID $windows._Id } | should -Not -Throw + { Get-JCSystemApp -Search -name "Microsoft Edge" } | should -Not -Throw + { Get-JCSystemApp -Search -name "Microsoft Edge" -SystemOs "windows" } | should -Not -Throw # A null value version shouldn't be accepted - { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "" | Should -Throw } + { Get-JCSystemApp -Search -name "Microsoft Edge" -SystemOs "" | Should -Throw } # A null value version shouldn't be accepted - { Get-JCSystemApp -Search -SoftwareName "" -SystemOs "windows" | Should -Throw } + { Get-JCSystemApp -Search -name "" -SystemOs "windows" | Should -Throw } # Searching Microsoft Edge on windows should return a result - { Get-JCSystemApp -Search -SoftwareName "Microsoft Edge" -SystemOs "windows" } | should -Not -Throw + { Get-JCSystemApp -Search -name "Microsoft Edge" -SystemOs "windows" } | should -Not -Throw } It "Tests the search functionatily of a software app" { #Tests for each OS # results with no data should be null or empty - Get-JCSystemApp -SoftwareName "chess" | Should -BeNullOrEmpty - Get-JCSystemApp -SoftwareName "microsoft edge" | Should -BeNullOrEmpty - Get-JCSystemApp -SoftwareName "curl" | Should -BeNullOrEmpty + Get-JCSystemApp -name "chess" | Should -BeNullOrEmpty + Get-JCSystemApp -name "microsoft edge" | Should -BeNullOrEmpty + Get-JCSystemApp -name "curl" | Should -BeNullOrEmpty # when search is used to find an app the results should not be null or empty - Get-JCSystemApp -SoftwareName "chess" -Search | Should -Not -BeNullOrEmpty - Get-JCSystemApp -SoftwareName "microsoft edge" -Search | Should -Not -BeNullOrEmpty - Get-JCSystemApp -SoftwareName "curl" -Search | Should -Not -BeNullOrEmpty + Get-JCSystemApp -name "chess" -Search | Should -Not -BeNullOrEmpty + Get-JCSystemApp -name "microsoft edge" -Search | Should -Not -BeNullOrEmpty + Get-JCSystemApp -name "curl" -Search | Should -Not -BeNullOrEmpty } It "Tests the search param with systemID" { - $macApps = Get-JCSystemApp -Systemid $mac._id -SoftwareName "a" -search - $windowsApps = Get-JCSystemApp -Systemid $windows._id -SoftwareName "a" -search - $linuxApps = Get-JCSystemApp -Systemid $linux._id -SoftwareName "a" -search + $macApps = Get-JCSystemApp -Systemid $mac._id -name "a" -search + $windowsApps = Get-JCSystemApp -Systemid $windows._id -name "a" -search + $linuxApps = Get-JCSystemApp -Systemid $linux._id -name "a" -search $foundMacSystems = $macApps.systemid | Select-Object -Unique $foundWindowsSystems = $windowsApps.systemid | Select-Object -Unique $foundLinuxSystems = $linuxApps.systemid | Select-Object -Unique @@ -133,7 +133,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { } It "Tests the search param with macos SystemOS" { # MacOS - $apps = Get-JCSystemApp -SystemOS "macos" -SoftwareName "a" -search + $apps = Get-JCSystemApp -SystemOS "macos" -name "a" -search $foundMacSystems = $apps.systemid | Select-Object -Unique # if you specify a systemOS and Search, results should not contain multiple systems foreach ($system in $foundSystems) { @@ -143,7 +143,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { } It "Tests the search param with windows SystemOS" { # Windows - $apps = Get-JCSystemApp -SystemOS "windows" -SoftwareName "a" -search + $apps = Get-JCSystemApp -SystemOS "windows" -name "a" -search $foundWindowsSystems = $apps.systemid | Select-Object -Unique # if you specify a systemOS and Search, results should not contain multiple systems foreach ($system in $foundWindowsSystems) { @@ -153,7 +153,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { } It "Tests the search param with linux SystemOS" { # Linux - $apps = Get-JCSystemApp -SystemOS "linux" -SoftwareName "a" -search + $apps = Get-JCSystemApp -SystemOS "linux" -name "a" -search $foundLinuxSystems = $apps.systemid | Select-Object -Unique # if you specify a systemOS and Search, results should not contain multiple systems foreach ($system in $foundLinuxSystems) { @@ -165,8 +165,8 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests compatability macOS with the SDKs" { #MacOS $sdkMac = Get-JcSdkSystemInsightApp -filter @("system_id:eq:$($mac._id)", "name:eq:Chess.app") - $moduleMac = Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" - $moduleMacSearch = Get-JCSystemApp -SystemID $mac._id -SoftwareName "chess" -Search + $moduleMac = Get-JCSystemApp -SystemID $mac._id -name "Chess" + $moduleMacSearch = Get-JCSystemApp -SystemID $mac._id -name "chess" -Search # SDK Results should look exactly like module results when exact name is specified $sdkMac.id | Should -Be $moduleMac.id $sdkMac.name | Should -Be $moduleMac.name @@ -177,8 +177,8 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests compatability windows with the SDKs" { #Windows $sdkWindows = Get-JcSdkSystemInsightProgram -filter @("system_id:eq:$($windows._id)", "name:eq:Microsoft Edge") - $moduleWindows = Get-JCSystemApp -SystemID $windows._id -SoftwareName "Microsoft Edge" - $moduleWindowsSearch = Get-JCSystemApp -SystemID $windows._id -SoftwareName "microsoft edge" -Search + $moduleWindows = Get-JCSystemApp -SystemID $windows._id -name "Microsoft Edge" + $moduleWindowsSearch = Get-JCSystemApp -SystemID $windows._id -name "microsoft edge" -Search # SDK Results should look exactly like module results when exact name is specified $sdkWindows.id | Should -Be $moduleWindows.id $sdkWindows.name | Should -Be $moduleWindows.name @@ -189,8 +189,8 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests compatability linux with the SDKs" { #Linux $sdkLinux = Get-JcSdkSystemInsightLinuxPackage -filter @("system_id:eq:$($linux._id)", "name:eq:Curl") - $moduleLinux = Get-JCSystemApp -SystemID $linux._id -SoftwareName "Curl" - $moduleLinuxSearch = Get-JCSystemApp -SystemID $linux._id -SoftwareName "curl" -Search + $moduleLinux = Get-JCSystemApp -SystemID $linux._id -name "Curl" + $moduleLinuxSearch = Get-JCSystemApp -SystemID $linux._id -name "curl" -Search # SDK Results should look exactly like module results when exact name is specified $sdkLinux.id | Should -Be $moduleLinux.id $sdkLinux.name | Should -Be $moduleLinux.name @@ -200,13 +200,13 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { } It "Tests that incompatible parameters should not be used together" { - # -SoftwareVersion should not be specified with -Search - { Get-JCSystemApp -SoftwareName "chess" -Search -SoftwareVersion "3.1.2" } | Should -Throw + # -version should not be specified with -Search + { Get-JCSystemApp -name "chess" -Search -version "3.1.2" } | Should -Throw # -SystemOS should not be specified with -SystemID { Get-JCsystemApp -SystemID $mac._id -SystemOS "windows" } | Should -Throw { Get-JCsystemApp -SystemID $mac._id -SystemOS "windows" } | Should -Throw - { Get-JCsystemApp -SystemID $mac._id -SystemOS "windows" -SoftwareName "Chess" } | Should -Throw - { Get-JCsystemApp -SystemID $mac._id -SystemOS "windows" -SoftwareName "Chess" -SoftwareVersion "1.2.3" } | Should -Throw + { Get-JCsystemApp -SystemID $mac._id -SystemOS "windows" -name "Chess" } | Should -Throw + { Get-JCsystemApp -SystemID $mac._id -SystemOS "windows" -name "Chess" -version "1.2.3" } | Should -Throw } It "Tests the exporability of a list of software apps" { @@ -220,8 +220,8 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { { Get-JCSystemApp -SystemID $linux._id | ConvertTo-Csv } | Should -Not -Throw } It "Tests macos functionatily to append .app to softwareName" { - Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess.app" | Should -Not -BeNullOrEmpty - Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess.App" | Should -Not -BeNullOrEmpty - Get-JCSystemApp -SystemID $mac._id -SoftwareName "Chess" | Should -Not -BeNullOrEmpty + Get-JCSystemApp -SystemID $mac._id -name "Chess.app" | Should -Not -BeNullOrEmpty + Get-JCSystemApp -SystemID $mac._id -name "Chess.App" | Should -Not -BeNullOrEmpty + Get-JCSystemApp -SystemID $mac._id -name "Chess" | Should -Not -BeNullOrEmpty } } From 5afb1ecff20007ce46387cbbc7fe8d9b7ad7b827 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 6 Feb 2023 17:06:44 +0000 Subject: [PATCH 089/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index 7eb381bd0..35cb5fd44 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.2.0.7750-202302032130 + 2.2.0.7783-202302061704 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud From 782faca4fabcbaa0820165006159fe90e86a72ac Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Mon, 6 Feb 2023 10:22:25 -0800 Subject: [PATCH 090/102] fixed get-jcsdksystem --- PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index d3b425905..595da5654 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -45,7 +45,7 @@ function Get-JCSystemApp () { } if ($SystemID) { - $OSType = Get-JcSdkSystem -ID $SystemID -Fields osfamily | Select-Object -ExpandProperty OSFamily + $OSType = Get-JcSdkSystem -ID $SystemID -Fields osFamily | Select-Object -ExpandProperty OSFamily } else { $OSType = $SystemOS if ($OSType -eq 'macOS') { From 912cabd9e5b5e732320b8552822597e807620c9d Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 6 Feb 2023 18:31:00 +0000 Subject: [PATCH 091/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index 35cb5fd44..b5fee53f1 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.2.0.7783-202302061704 + 2.2.0.7794-202302061828 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud From c13286c4bc5417b1d1556726af988b787168957b Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Mon, 6 Feb 2023 12:09:27 -0800 Subject: [PATCH 092/102] fix tests --- .../Tests/Public/Systems/Get-JCSystemApp.tests.ps1 | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index 25e40060a..97586abbf 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -33,7 +33,6 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests that given a macOS systemID, SoftwareName, SoftwareVersion, an app is returned" { # MacOS $macApp = Get-JCSystemApp -SystemID $mac._id -name "Chess" - { Get-JCSystemApp -SystemID $mac._id -name "Chess" -version $macApp.Bundle_short_version } | Should -Throw # A null value version shouldn't be accepted { Get-JCSystemApp -SystemID $mac._id -name "Chess" -version "" } | Should -Throw # A null value Name shouldn't be accepted @@ -45,7 +44,6 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { #Windows $windowsApp = Get-JCSystemApp -SystemID $windows._id -name "Microsoft Edge" - { Get-JCSystemApp -SystemID $windows._id -name "Microsoft Edge" -version $windowsApp.version } | Should -Throw # A null value version shouldn't be accepted { Get-JCSystemApp -SystemID $windows._id -name "Microsoft Edge" -version "" } | Should -Throw # A null value Name shouldn't be accepted @@ -57,7 +55,6 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { #Linux #Windows $linuxApp = Get-JCSystemApp -SystemID $linux._id -name "curl" - { Get-JCSystemApp -SystemID $linux._id -name "curl" -version $linuxApp.version } | Should -Throw # A null value version shouldn't be accepted { Get-JCSystemApp -SystemID $linux._id -name "curl" -version "" } | Should -Throw # A null value Name shouldn't be accepted @@ -111,7 +108,6 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { # results with no data should be null or empty Get-JCSystemApp -name "chess" | Should -BeNullOrEmpty Get-JCSystemApp -name "microsoft edge" | Should -BeNullOrEmpty - Get-JCSystemApp -name "curl" | Should -BeNullOrEmpty # when search is used to find an app the results should not be null or empty Get-JCSystemApp -name "chess" -Search | Should -Not -BeNullOrEmpty Get-JCSystemApp -name "microsoft edge" -Search | Should -Not -BeNullOrEmpty @@ -172,7 +168,7 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { $sdkMac.name | Should -Be $moduleMac.name # SDK Results should look exactly like module results when search is provided $sdkMac.id | Should -Be $moduleMacSearch.id - $sdkMac.name | Should -Be $moduleMacSearch.name + $moduleMacSearch.name | Should -Contain $sdkMac.name } It "Tests compatability windows with the SDKs" { #Windows @@ -184,19 +180,19 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { $sdkWindows.name | Should -Be $moduleWindows.name # SDK Results should look exactly like module results when search is provided $sdkWindows.id | Should -Be $moduleWindowsSearch.id - $sdkWindows.name | Should -Be $moduleWindowsSearch.name + $moduleWindowsSearch.name | Should -Contain $sdkWindows.name } It "Tests compatability linux with the SDKs" { #Linux - $sdkLinux = Get-JcSdkSystemInsightLinuxPackage -filter @("system_id:eq:$($linux._id)", "name:eq:Curl") - $moduleLinux = Get-JCSystemApp -SystemID $linux._id -name "Curl" + $sdkLinux = Get-JcSdkSystemInsightLinuxPackage -filter @("system_id:eq:$($linux._id)", "name:eq:curl") + $moduleLinux = Get-JCSystemApp -SystemID $linux._id -name "curl" $moduleLinuxSearch = Get-JCSystemApp -SystemID $linux._id -name "curl" -Search # SDK Results should look exactly like module results when exact name is specified $sdkLinux.id | Should -Be $moduleLinux.id $sdkLinux.name | Should -Be $moduleLinux.name # SDK Results should look exactly like module results when search is provided $sdkLinux.id | Should -Be $moduleLinuxSearch.id - $sdkLinux.name | Should -Be $moduleLinuxSearch.name + $moduleLinuxSearch.name | Should -Contain $sdkLinux.name } It "Tests that incompatible parameters should not be used together" { From 7267db031c73de48700b0c34e99b73238690b4c7 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 6 Feb 2023 20:19:35 +0000 Subject: [PATCH 093/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index f8bf10130..ba6b37a0c 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] +Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] ``` ## DESCRIPTION From fb87ccfb6d81bfb48d8655f0826ffc6bb6b2d420 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Mon, 6 Feb 2023 13:51:42 -0800 Subject: [PATCH 094/102] flip publish --- .circleci/workflows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 95c90779d..6c653469b 100755 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -49,7 +49,7 @@ parameters: PublishToPSGallery: description: "When `true` and when run against Master branch, this workflow will publish the latest code to PSGallery" type: boolean - default: false + default: true ManualModuleVersion: description: "When `true` the pipeline will use the Module Version specified in JumpCloud Module JumpCloud.psd1 file" type: boolean From 457405f760b5748106bc81b5728b16161e15d81e Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 6 Feb 2023 21:58:54 +0000 Subject: [PATCH 095/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index ba6b37a0c..f8bf10130 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] +Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index b5fee53f1..eac89ea12 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.2.0.7794-202302061828 + 2.2.0.7823-202302062156 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud From 389717258f566f0540db111b553926a75d0393aa Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Tue, 7 Feb 2023 06:30:32 -0700 Subject: [PATCH 096/102] Test draft release/ update documentation --- .circleci/workflows.yml | 14 ++++++-- .../JumpCloud Module/Docs/Get-JCSystemApp.md | 32 ++++++++++++++----- PowerShell/ModuleChangelog.md | 21 ++++-------- 3 files changed, 41 insertions(+), 26 deletions(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 6c653469b..6954c699c 100755 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -101,18 +101,25 @@ workflows: - Initial Setup - Build Modules context: aws-credentials - - Module Validation Tests: + - Invoke Git Commit: + requires: + - Initial Setup + - Build Help and Test Files + - Build Nuspec + - draft-github-release: + context: github-credentials-sa-releases requires: - Initial Setup - Build Help and Test Files - Build Nuspec - Invoke Git Commit - context: aws-credentials - - Invoke Git Commit: + - Module Validation Tests: requires: - Initial Setup - Build Help and Test Files - Build Nuspec + - Invoke Git Commit + context: aws-credentials - Pester Tests Windows: requires: - Initial Setup @@ -149,6 +156,7 @@ workflows: jobs: - Prepare for release - draft-github-release: + context: github-credentials-sa-releases requires: - Prepare for release - Approve Module: diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index a40a29dd6..26a81f812 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -8,28 +8,33 @@ schema: 2.0.0 # Get-JCSystemApp ## SYNOPSIS + Returns the applications/programs/linux packages installed on JumpCloud managed system(s). This function queries separate system insights tables to get data for macOS/windows/linux devices. ## SYNTAX ### All (Default) + ``` Get-JCSystemApp [-SystemID ] [-SystemOS ] [-name ] [-version ] [] ``` ### Search + ``` Get-JCSystemApp [-SystemID ] [-SystemOS ] [-name ] [-version ] [-Search] [] ``` ## DESCRIPTION + Get-JCSystem app function helps admins identify what applications/programs or linux packages exist on their JumpCloud managed systems. ## EXAMPLES ### Example 1 + ```powershell PS C:\> Get-JCSystemApp -SystemId '6363237ec991136ae59892e4' ``` @@ -37,6 +42,7 @@ PS C:\> Get-JCSystemApp -SystemId '6363237ec991136ae59892e4' Returns the applications installed in the system with the given -SystemId ### Example 2 + ```powershell PS C:\> Get-JCSystemApp -SystemOs 'macOS' ``` @@ -44,28 +50,32 @@ PS C:\> Get-JCSystemApp -SystemOs 'macOS' Returns the 'macOS' systems and all the applications installed for each system ### Example 3 + ```powershell -PS C:\> Get-JCSystemApp -SystemOs 'macOS' -SoftwareName 'JumpCloud-Agent' +PS C:\> Get-JCSystemApp -SystemOs 'macOS' -Name 'Jumpcloud' ``` ### Example 4 + ```powershell -PS C:\> Get-JCSystemApp -SystemOs 'macOS' -SoftwareName 'JumpCloud-Agent' -SoftwareVersion '1.12.5' +PS C:\> Get-JCSystemApp -SystemOs 'macOS' -Name 'Jumpcloud' -Version 'v1.16.2' ``` -Returns the 'macOS' systems that have a 'JumpCloud Agent' application with the version '1.12.5' +Returns the 'macOS' systems that have a 'Jumpcloud' tray application with the version 'v1.16.2' ### Example 5 + ```powershell -PS C:\> Get-JCSystemApp -SoftwareName 'jumpcloud-agent' -Search +PS C:\> Get-JCSystemApp -Name 'jumpcloud' -Search ``` -Returns any 'jumpcloud-agent' software installed in all the os systems +Returns any 'jumpcloud' software installed in all the OS systems (Windows/Linux/macOS) ## PARAMETERS ### -name -The name of the application you want to search for ex. (JumpCloud-Agent, Slack). SoftwareName will always query the "name" property from system insights. Note, for macOS systems, ".app" will be applied. This field is case sensitive. + +The name of the application you want to search for ex. (Jumpcloud, Slack). Name will always query the "name" property from system insights. Note, for macOS systems, ".app" will be applied. This field is case sensitive. ```yaml Type: System.String @@ -80,8 +90,9 @@ Accept wildcard characters: False ``` ### -Search + Search for a specific application by from all systems in the org ex. -(Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") +(Get-JCSystemApp -Search -Name "Jumpcloud") THIS PARAMETER DOES NOT TAKE INPUT ```yaml @@ -97,6 +108,7 @@ Accept wildcard characters: False ``` ### -SystemID + The System Id of the JumpCloud system you want to search for applications ```yaml @@ -112,6 +124,7 @@ Accept wildcard characters: False ``` ### -SystemOS + The type (windows, mac, linux) of the JumpCloud Command you wish to search ex. (Windows, macOs, Linux)) @@ -129,7 +142,8 @@ Accept wildcard characters: False ``` ### -version -The version of the application you want to search for ex. 1.1.2 + +The version of the application you want to search for ex. 1.1.2. Note: on Windows/ Linux devices, this parameter will filter on the 'version' property, for macOS applications this parameter will filter on the 'bundleShortVersion' property. ```yaml Type: System.String @@ -144,6 +158,7 @@ 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 @@ -153,6 +168,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## OUTPUTS ### System.Object + ## NOTES ## RELATED LINKS diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index be4c527f0..2ce31e121 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,28 +1,19 @@ ## 2.2.0 -Release Date: January 18, 2023 +Release Date: February 7, 2023 #### RELEASE NOTES ``` -This release adds new function Get-JCSystemApp +This release adds new function Get-JCSystemApp which enables admins to search for 'x' system and 'y' version on all managed JumpCloud systems. ``` #### FEATURES: -* Get-JCSystemApp command enables search by: - - applications installed in a system - - applications installed from all the systems in a specifc OS - - SoftwareName - - SoftwareName and SoftwareVersion - -#### IMPROVEMENTS: - -N/A - -#### BUG FIXES: - -N/A +- Get-JCSystemApp command enables search by: + - applications installed in a specific system + - applications installed from all the systems specified by OS + - Software Name and or Version ## 2.1.3 From dadab82a894b9e0b019ab2c0279f44d8502451c0 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Tue, 7 Feb 2023 13:39:30 +0000 Subject: [PATCH 097/102] Updating PowerShell Module;[skip ci] --- .../JumpCloud Module/Docs/Get-JCSystemApp.md | 4 ---- .../Docs/Set-JCSettingsFile.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- .../JumpCloud Module/en-Us/JumpCloud-help.xml | 22 +++++++++---------- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md index 26a81f812..eb7e79f10 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemApp.md @@ -14,14 +14,12 @@ Returns the applications/programs/linux packages installed on JumpCloud managed ## SYNTAX ### All (Default) - ``` Get-JCSystemApp [-SystemID ] [-SystemOS ] [-name ] [-version ] [] ``` ### Search - ``` Get-JCSystemApp [-SystemID ] [-SystemOS ] [-name ] [-version ] [-Search] [] @@ -158,7 +156,6 @@ 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 @@ -168,7 +165,6 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## OUTPUTS ### System.Object - ## NOTES ## RELATED LINKS diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index f8bf10130..ba6b37a0c 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] +Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 3f01688e1..e0e8790bf 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 2/6/2023 +# Generated on: 2/7/2023 # @{ diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index 95aa36ad9..a6138f089 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -7066,7 +7066,7 @@ PS C:\> $BackupJcOrganizationResults.User name - The name of the application you want to search for ex. (JumpCloud-Agent, Slack). SoftwareName will always query the "name" property from system insights. Note, for macOS systems, ".app" will be applied. This field is case sensitive. + The name of the application you want to search for ex. (Jumpcloud, Slack). Name will always query the "name" property from system insights. Note, for macOS systems, ".app" will be applied. This field is case sensitive. System.String @@ -7078,7 +7078,7 @@ PS C:\> $BackupJcOrganizationResults.User Search - Search for a specific application by from all systems in the org ex. (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") THIS PARAMETER DOES NOT TAKE INPUT + Search for a specific application by from all systems in the org ex. (Get-JCSystemApp -Search -Name "Jumpcloud") THIS PARAMETER DOES NOT TAKE INPUT System.Management.Automation.SwitchParameter @@ -7118,7 +7118,7 @@ PS C:\> $BackupJcOrganizationResults.User version - The version of the application you want to search for ex. 1.1.2 + The version of the application you want to search for ex. 1.1.2. Note: on Windows/ Linux devices, this parameter will filter on the 'version' property, for macOS applications this parameter will filter on the 'bundleShortVersion' property. System.String @@ -7133,7 +7133,7 @@ PS C:\> $BackupJcOrganizationResults.User name - The name of the application you want to search for ex. (JumpCloud-Agent, Slack). SoftwareName will always query the "name" property from system insights. Note, for macOS systems, ".app" will be applied. This field is case sensitive. + The name of the application you want to search for ex. (Jumpcloud, Slack). Name will always query the "name" property from system insights. Note, for macOS systems, ".app" will be applied. This field is case sensitive. System.String @@ -7145,7 +7145,7 @@ PS C:\> $BackupJcOrganizationResults.User Search - Search for a specific application by from all systems in the org ex. (Get-JCSystemApp -Search -SoftwareName "JumpCloud-Agent") THIS PARAMETER DOES NOT TAKE INPUT + Search for a specific application by from all systems in the org ex. (Get-JCSystemApp -Search -Name "Jumpcloud") THIS PARAMETER DOES NOT TAKE INPUT System.Management.Automation.SwitchParameter @@ -7181,7 +7181,7 @@ PS C:\> $BackupJcOrganizationResults.User version - The version of the application you want to search for ex. 1.1.2 + The version of the application you want to search for ex. 1.1.2. Note: on Windows/ Linux devices, this parameter will filter on the 'version' property, for macOS applications this parameter will filter on the 'bundleShortVersion' property. System.String @@ -7233,23 +7233,23 @@ PS C:\> $BackupJcOrganizationResults.User -------------------------- Example 3 -------------------------- - PS C:\> Get-JCSystemApp -SystemOs 'macOS' -SoftwareName 'JumpCloud-Agent' + PS C:\> Get-JCSystemApp -SystemOs 'macOS' -Name 'Jumpcloud' -------------------------- Example 4 -------------------------- - PS C:\> Get-JCSystemApp -SystemOs 'macOS' -SoftwareName 'JumpCloud-Agent' -SoftwareVersion '1.12.5' + PS C:\> Get-JCSystemApp -SystemOs 'macOS' -Name 'Jumpcloud' -Version 'v1.16.2' - Returns the 'macOS' systems that have a 'JumpCloud Agent' application with the version '1.12.5' + Returns the 'macOS' systems that have a 'Jumpcloud' tray application with the version 'v1.16.2' -------------------------- Example 5 -------------------------- - PS C:\> Get-JCSystemApp -SoftwareName 'jumpcloud-agent' -Search + PS C:\> Get-JCSystemApp -Name 'jumpcloud' -Search - Returns any 'jumpcloud-agent' software installed in all the os systems + Returns any 'jumpcloud' software installed in all the OS systems (Windows/Linux/macOS) From 91812e0fbf06fc82d8074dc1df9941c2cca06158 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Tue, 7 Feb 2023 07:44:49 -0700 Subject: [PATCH 098/102] remove test draft release step from CI jobs --- .circleci/workflows.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 6954c699c..5d627a52c 100755 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -106,13 +106,6 @@ workflows: - Initial Setup - Build Help and Test Files - Build Nuspec - - draft-github-release: - context: github-credentials-sa-releases - requires: - - Initial Setup - - Build Help and Test Files - - Build Nuspec - - Invoke Git Commit - Module Validation Tests: requires: - Initial Setup From 2d742611fc3db269c02288f361a95d6b4b7cd213 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Tue, 7 Feb 2023 09:35:08 -0800 Subject: [PATCH 099/102] name and version logic and added test --- .../Public/Systems/Get-JCSystemApp.ps1 | 58 ++++++++++++------- .../Public/Systems/Get-JCSystemApp.tests.ps1 | 17 ++++-- 2 files changed, 50 insertions(+), 25 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 index 595da5654..e846d82b7 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemApp.ps1 @@ -1,7 +1,6 @@ function Get-JCSystemApp () { [CmdletBinding(DefaultParameterSetName = 'All')] param ( - [Parameter(Mandatory = $false, HelpMessage = 'The System Id of the system you want to search for applications')][ValidateNotNullorEmpty()] [string]$SystemID, [Parameter(Mandatory = $false , ValueFromPipelineByPropertyName, HelpMessage = 'The type (windows, macOS, linux) of the JumpCloud system you wish to search. Ex. (Windows, macOS, Linux))')] @@ -11,11 +10,10 @@ function Get-JCSystemApp () { [string]$name, [Parameter(Mandatory = $false, HelpMessage = 'The version of the application you want to search for ex. 1.1.2')][ValidateNotNullorEmpty()] [string]$version, - [Parameter(Mandatory = $false, ParameterSetName = "Search", HelpMessage = "The Search parameter can be used in conjunction with the 'SoftwareName' parameter to perform a case-insensitive search for software. This is parameter switch is inherently slower than using just the 'softwareName' parameter but can be useful to identify the names of software titles on systems. If the exact name of a software title isn't known, the 'search' parameter can be used to find that name. Ex. Get-JCSoftwareApp -SystemID '63c9654cb357249876bfc05b' -SoftwareName 'chrome' -Search will attempt to perform a match for the term 'chrome' on all applications/ programs for the specified system. If a match, partial-match, case-insensitive match is found, it would be returned in the results. In this case, the 'name' of the software title is 'Google Chrome'. A subsequent search could be run to return all macOS systems which have 'Google Chrome' installed. Ex. Get-JCSystemApp -SystemOS macOS -softwareName 'Google Chrome', this would perform an exact match search for macOS systems that have google chrome which is substantially quicker than running: Get-JCSystemApp -SystemOS macOS -softwareName 'google chrome' -Search. The search parameter is a tool to help identify the 'name' attribute of software titles when searching bulk systems its recommended to not use the search parameter and instead specify the exact (case sensitive) name of the software title.")] + [Parameter(Mandatory = $false, ParameterSetName = "Search", HelpMessage = "The Search parameter can be used in conjunction with the 'SoftwareName' parameter to perform a case-insensitive search for software. This is parameter switch is inherently slower than using just the 'softwareName' parameter but can be useful to identify the names of software titles on systems. If the exact name of a software title isn't known, the 'search' parameter can be used to find that name. Ex. Get-JCSoftwareApp -SystemID '63c9654cb357249876bfc05b' -name 'chrome' -Search will attempt to perform a match for the term 'chrome' on all applications/ programs for the specified system. If a match, partial-match, case-insensitive match is found, it would be returned in the results. In this case, the 'name' of the software title is 'Google Chrome'. A subsequent search could be run to return all macOS systems which have 'Google Chrome' installed. Ex. Get-JCSystemApp -SystemOS macOS -name 'Google Chrome', this would perform an exact match search for macOS systems that have google chrome which is substantially quicker than running: Get-JCSystemApp -SystemOS macOS -name 'google chrome' -Search. The search parameter is a tool to help identify the 'name' attribute of software titles when searching bulk systems its recommended to not use the search parameter and instead specify the exact (case sensitive) name of the software title.")] [switch]$Search, [Parameter(DontShow, Mandatory = $false, ParameterSetName = "All", HelpMessage = 'Search for a specific application by name from all systems in the org')] [switch]$SearchAllSystems - ) begin { Write-Verbose 'Verifying JCAPI Key' @@ -23,7 +21,6 @@ function Get-JCSystemApp () { Connect-JCOnline } $Parallel = $JCConfig.parallel.Calculated - $searchAppResultsList = New-Object -TypeName System.Collections.ArrayList $resultsArrayList = New-Object -TypeName System.Collections.ArrayList $commands = @("Get-JcSdkSystemInsightProgram", "Get-JcSdkSystemInsightApp", "Get-JcSdkSystemInsightLinuxPackage") @@ -43,7 +40,7 @@ function Get-JCSystemApp () { if ($SystemID -and $SystemOS) { Throw "Cannot specify both SystemID and SystemOS" } - + # Get the OS Type if ($SystemID) { $OSType = Get-JcSdkSystem -ID $SystemID -Fields osFamily | Select-Object -ExpandProperty OSFamily } else { @@ -53,9 +50,10 @@ function Get-JCSystemApp () { } } Write-Debug "OSType: $OSType" + # Switch for OS Type switch ($OSType) { + # Check whether a systemId or systemOS is used 'Windows' { - # If Software title, version, and system ID are passed then return specific app if ($version -and $name) { @@ -160,10 +158,7 @@ function Get-JCSystemApp () { } 'Linux' { - if ($version -and $name) { - - if ($SystemID) { Get-JcSdkSystemInsightLinuxPackage -Filter @("system_id:eq:$SystemID", "name:eq:$name", "version:eq:$version") | ForEach-Object { [void]$resultsArrayList.Add($_) @@ -202,16 +197,24 @@ function Get-JCSystemApp () { } } } - } + # IF no systemOs or systemID is passed with name } elseif ($name) { # Loop through each OS and get the results - Write-Debug "SoftwareName only passed. Getting all software with name $name" + Write-Debug "name and or version only passed. Getting all software with name $name" + foreach ($os in @('Windows', 'MacOs', 'Linux')) { if ($os -eq 'Windows') { - Get-JcSdkSystemInsightProgram -Filter @("name:eq:$name") | ForEach-Object { - [void]$resultsArrayList.Add($_) + if ($version) { + Get-JcSdkSystemInsightProgram -Filter @("name:eq:$name", "version:eq:$version") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } else { + Get-JcSdkSystemInsightProgram -Filter @("name:eq:$name") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } } + } elseif ($os -eq 'MacOs') { $macOsSoftwareName = $name $ending = $macOsSoftwareName.Substring($macOsSoftwareName.Length - 4) @@ -222,19 +225,32 @@ function Get-JCSystemApp () { $macOsSoftwareName = "$macOsSoftwareName.app" Write-Debug "$macOsSoftwareName" } - Get-JcSdkSystemInsightApp -Filter @("name:eq:$macOsSoftwareName") | ForEach-Object { - - [void]$resultsArrayList.Add($_) + if ($version) { + Get-JcSdkSystemInsightApp -Filter @("name:eq:$macOsSoftwareName", "bundle_short_version:eq:$version") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } else { + Get-JcSdkSystemInsightApp -Filter @("name:eq:$macOsSoftwareName") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } } + } elseif ($os -eq 'Linux') { - Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$name") | ForEach-Object { - [void]$resultsArrayList.Add($_) + if ($version) { + Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$name", "version:eq:$version") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } + } else { + Get-JcSdkSystemInsightLinuxPackage -Filter @("name:eq:$name") | ForEach-Object { + [void]$resultsArrayList.Add($_) + } } + } } - } - + } # End of name and or version only passed else { + # Get all software in all systems in the org # Default/All Write-Debug "Get All" if ($Parallel) { @@ -247,6 +263,7 @@ function Get-JCSystemApp () { } } } Search { + # Case-insensitive search # Search for softwareName Write-Debug "Search $name" if ($name) { @@ -274,7 +291,6 @@ function Get-JCSystemApp () { } } } - $filteredResults = $searchAppResultsList | Where-Object { ($_.name -match $name) } $resultsArrayList = $filteredResults } elseif ($SystemOS) { diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 index 97586abbf..028c84744 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemApp.tests.ps1 @@ -26,9 +26,18 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { It "Tests that given a systemID, SoftwareName, an app is returned" { # Chess is always installed on MacOS and it CAN NOT be removed no matter what - Get-JCSystemApp -SystemID $mac._id -name "Chess" - Get-JCSystemApp -SystemID $linux._id -name "Curl" - Get-JCSystemApp -SystemID $windows._id -name "Microsoft Edge" + Get-JCSystemApp -SystemID $mac._id -name "Chess" | Should -Not -BeNullOrEmpty + Get-JCSystemApp -SystemID $linux._id -name "curl" | Should -Not -BeNullOrEmpty + Get-JCSystemApp -SystemID $windows._id -name "Microsoft Edge" | Should -Not -BeNullOrEmpty + } + It "Tests that given a name and version, app is returned" { + # Chess is always installed on MacOS and it CAN NOT be removed no matter what + $macApp = Get-JCSystemApp -SystemID $mac._id -name "Chess" + $linuxApp = Get-JCSystemApp -SystemID $linux._id -name "curl" + $windowsApp = Get-JCSystemApp -SystemID $windows._id -name "Microsoft Edge" + { Get-JCSystemApp -name "Chess" -version $macApp.bundleshortversion } | Should -Not -BeNullOrEmpty + { Get-JCSystemApp -name "curl" -version $linuxApp.version } | Should -Not -BeNullOrEmpty + { Get-JCSystemApp -name "Microsoft Edge" -version $windowsApp.version } | Should -Not -BeNullOrEmpty } It "Tests that given a macOS systemID, SoftwareName, SoftwareVersion, an app is returned" { # MacOS @@ -220,4 +229,4 @@ Describe -Tag:('JCSystemApp') 'Get-JCSystemApp' { Get-JCSystemApp -SystemID $mac._id -name "Chess.App" | Should -Not -BeNullOrEmpty Get-JCSystemApp -SystemID $mac._id -name "Chess" | Should -Not -BeNullOrEmpty } -} +} \ No newline at end of file From e8e6f9bd81920375c3b3fb445b8f083973a4d396 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Tue, 7 Feb 2023 17:43:22 +0000 Subject: [PATCH 100/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index ba6b37a0c..f8bf10130 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,7 +14,7 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-moduleBannerMessageCount ] [-parallelOverride ] [] +Set-JCSettingsFile [-parallelOverride ] [-moduleBannerMessageCount ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index eac89ea12..f5c4619cb 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.2.0.7823-202302062156 + 2.2.0.7857-202302071740 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud From 488cf5e70bad0668e2640a58d421f3dd08e2e44e Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Tue, 7 Feb 2023 12:15:04 -0800 Subject: [PATCH 101/102] modulechangelog [skip ci] --- PowerShell/ModuleChangelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 2ce31e121..42621d474 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -5,7 +5,7 @@ Release Date: February 7, 2023 #### RELEASE NOTES ``` -This release adds new function Get-JCSystemApp which enables admins to search for 'x' system and 'y' version on all managed JumpCloud systems. +This release adds new function Get-JCSystemApp which enables admins to search for 'x' software and 'y' version on specific device, devices in a specific os, or all managed JumpCloud devices. ``` #### FEATURES: From 93c5cdbbbc7d4ca4f60475b9b67affefc740563a Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Tue, 7 Feb 2023 20:24:59 +0000 Subject: [PATCH 102/102] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/JumpCloud.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.nuspec b/PowerShell/JumpCloud Module/JumpCloud.nuspec index f5c4619cb..5bcba3a57 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.nuspec +++ b/PowerShell/JumpCloud Module/JumpCloud.nuspec @@ -2,7 +2,7 @@ JumpCloud - 2.2.0.7857-202302071740 + 2.2.0.7873-202302072022 PowerShell functions to manage a JumpCloud Directory-as-a-Service JumpCloud Solutions Architect Team JumpCloud