diff --git a/PowerShell/JumpCloud Module/Docs/Connect-JCOnline.md b/PowerShell/JumpCloud Module/Docs/Connect-JCOnline.md index 162c96bac..939c52a85 100644 --- a/PowerShell/JumpCloud Module/Docs/Connect-JCOnline.md +++ b/PowerShell/JumpCloud Module/Docs/Connect-JCOnline.md @@ -13,7 +13,7 @@ The Connect-JCOnline function sets the global variable $JCAPIKEY ## SYNTAX ``` -Connect-JCOnline [-force] [[-JumpCloudApiKey] <String>] +Connect-JCOnline [-force] [-JumpCloudApiKey] <String> [[-JumpCloudOrgId] <String>] [[-JCEnvironment] <String>] [<CommonParameters>] ``` @@ -88,7 +88,7 @@ Type: System.String Parameter Sets: (All) Aliases: -Required: False +Required: True Position: 1 Default value: None Accept pipeline input: True (ByPropertyName) diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystemKB.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystemKB.md new file mode 100644 index 000000000..2cd837caf --- /dev/null +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystemKB.md @@ -0,0 +1,113 @@ +--- +external help file: JumpCloud-help.xml +Module Name: JumpCloud +online version: https://github.com/TheJumpCloud/support/wiki/ +schema: 2.0.0 +--- + +# Get-JCSystemKB + +## SYNOPSIS +Returns applied hotfixes/KBs on Windows devices + +## SYNTAX + +### All (Default) +``` +Get-JCSystemKB [<CommonParameters>] +``` + +### SearchFilter +``` +Get-JCSystemKB [-SystemID <String[]>] [-KB <String[]>] + [<CommonParameters>] +``` + +## DESCRIPTION +The Get-JCSystemKB function returns all applied hotfixes/KBs on Windows Devices. The function can be used to filter based on a specific hotfix/KB, a specific system, or both. An object is returned that contains information on the hotfix/KB including the description of the KB and when it was installed + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Get-JCSystemKB +``` + +This example returns all installed hotfixes/KBs on all of the Windows devices in the organization + +### Example 2 +```powershell +PS C:\> Get-JCSystemKB -SystemID 59f2s305383coo7t369ef7r2 +``` + +This example returns all installed hotfixes/KBs on one Windows device + +### Example 3 +```powershell +PS C:\> Get-JCSystemKB -KB KB5000736 +``` + +This example returns all devices that have the hotfix/KB installed + +### Example 4 +```powershell +PS C:\> Get-JCSystemKB -KB KB5000736 -SystemID 59f2s305383coo7t369ef7r2 +``` + +This example checks a specific system for a specific hotfix/KB + +### Example 5 +```powershell +PS C:\> Get-JCSystem -hostname JC-Windows-01 | Get-JCSystemKB +``` + +This example uses pipeline input from Get-JCSystem to find all installed KBs for the system with the hostname JC-Windows-01 + +## PARAMETERS + +### -KB +The KB(s) you wish to search for. +Accepts comma separated strings. +Ex: KB5006670, KB5005699, KB5000736, ... + +```yaml +Type: System.String[] +Parameter Sets: SearchFilter +Aliases: hotfix_id + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SystemID +The System Id(s) of the system(s) you want to search for KBs. +Accepts comma separated strings. +Ex: 618972a694380d17e4145626, 63210fc54861961ac387f0ac, ... + +```yaml +Type: System.String[] +Parameter Sets: SearchFilter +Aliases: system_id, id, _id + +Required: False +Position: Named +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 2cdb89d4b..36ad47751 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.13.1 +Help Version: 2.14.0 Locale: en-Us --- @@ -111,6 +111,9 @@ Returns the System Group members of a JumpCloud System Group. JumpCloud's System Insights feature provides admins with the ability to easily interrogate their fleet of systems to find important pieces of information. Using this function you can easily gather heightened levels of information from your fleet of JumpCloud managed systems. +### [Get-JCSystemKB](Get-JCSystemKB.md) +Returns applied hotfixes/KBs on Windows devices + ### [Get-JCSystemUser](Get-JCSystemUser.md) Returns all JumpCloud Users associated with a JumpCloud System. diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index 1bb2c174f..7f6b8fb85 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,8 +14,8 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-parallelOverride <PSObject>] - [-moduleBannerMessageCount <PSObject>] [<CommonParameters>] +Set-JCSettingsFile [-moduleBannerMessageCount <PSObject>] + [-parallelOverride <PSObject>] [<CommonParameters>] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index e96f04f57..ad432ab03 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: 8/20/2024 +# Generated on: 9/24/2024 # @{ @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '2.13.1' +ModuleVersion = '2.14.0' # Supported PSEditions # CompatiblePSEditions = @() @@ -83,10 +83,10 @@ FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget', 'Add-JCGsuiteMem 'Get-JCPolicyTargetSystem', 'Get-JCRadiusReplyAttribute', 'Get-JCRadiusServer', 'Get-JCScheduledUserstate', 'Get-JCSystem', 'Get-JCSystemApp', 'Get-JCSystemGroupMember', 'Get-JCSystemInsights', - 'Get-JCSystemUser', 'Get-JCUser', 'Get-JCUserGroupMember', - 'Import-JCCommand', 'Import-JCMSPFromCSV', 'Import-JCUsersFromCSV', - 'Invoke-JCCommand', 'Invoke-JCDeployment', 'New-JCCommand', - 'New-JCDeploymentTemplate', 'New-JCImportTemplate', + 'Get-JCSystemKB', 'Get-JCSystemUser', 'Get-JCUser', + 'Get-JCUserGroupMember', 'Import-JCCommand', 'Import-JCMSPFromCSV', + 'Import-JCUsersFromCSV', 'Invoke-JCCommand', 'Invoke-JCDeployment', + 'New-JCCommand', 'New-JCDeploymentTemplate', 'New-JCImportTemplate', 'New-JCMSPImportTemplate', 'New-JCPolicy', 'New-JCRadiusServer', 'New-JCSystemGroup', 'New-JCUser', 'New-JCUserGroup', 'Remove-JCAssociation', 'Remove-JCCommand', 'Remove-JCCommandResult', diff --git a/PowerShell/JumpCloud Module/Public/Policies/Get-JCPolicy.ps1 b/PowerShell/JumpCloud Module/Public/Policies/Get-JCPolicy.ps1 index f1305908b..c10fdff42 100755 --- a/PowerShell/JumpCloud Module/Public/Policies/Get-JCPolicy.ps1 +++ b/PowerShell/JumpCloud Module/Public/Policies/Get-JCPolicy.ps1 @@ -70,7 +70,9 @@ Function Get-JCPolicy () { $Result = Invoke-JCApi -Method:('GET') -Paginate:($true) -Url:($URL) } - $Result | Add-Member -MemberType NoteProperty -Name "templateID" -Value $Result.template.id + $Result | ForEach-Object { + $_ | Add-Member -MemberType NoteProperty -Name "templateID" -Value $_.template.id + } if ($result.id) { $Results += $Result } @@ -81,4 +83,4 @@ Function Get-JCPolicy () { Return $Results | Select-Object -Property "name", "id", "templateID", "values", "template" } } -} +} \ No newline at end of file diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemKB.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemKB.ps1 new file mode 100644 index 000000000..fc7b9db90 --- /dev/null +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemKB.ps1 @@ -0,0 +1,87 @@ +function Get-JCSystemKB () { + [CmdletBinding(DefaultParameterSetName = 'All')] + param ( + [Parameter( + Mandatory = $false, + HelpMessage = 'The System Id(s) of the system(s) you want to search for KBs. Accepts comma separated strings. Ex: 618972a694380d17e4145626, 63210fc54861961ac387f0ac, ...', + ValueFromPipelineByPropertyName, + ParameterSetName = 'SearchFilter' + )] + [Alias("system_id", "id", "_id")] + [ValidateNotNullorEmpty()] + [string[]]$SystemID, + [Parameter( + Mandatory = $false , + ParameterSetName = 'SearchFilter', + HelpMessage = 'The KB(s) you wish to search for. Accepts comma separated strings. Ex: KB5006670, KB5005699, KB5000736, ...')] + + [Alias("hotfix_id")] + [string[]]$KB + ) + begin { + Write-Verbose 'Verifying JCAPI Key' + if ($JCAPIKEY.length -ne 40) { + Connect-JCOnline + } + $Parallel = $JCConfig.parallel.Calculated + } + process { + [int]$limit = '10000' + Write-Verbose "Setting limit to $limit" + + [int]$skip = '0' + Write-Verbose "Setting skip to $skip" + + $SystemInsightsURL = "$JCUrlBasePath/api/v2/systeminsights/patches" + + switch ($PSCmdlet.ParameterSetName) { + All { + if ($Parallel) { + $systemInsightsPatches = Get-JCResults -URL $SystemInsightsURL -method "GET" -limit $limit -Parallel $true + } else { + $systemInsightsPatches = Get-JCResults -URL $SystemInsightsURL -method "GET" -limit $limit + } + } + SearchFilter { + $filter = @() + foreach ($param in $PSBoundParameters.GetEnumerator()) { + switch ($param.Key) { + SystemID { + if ($param.Value.Count -gt 1) { + $filter += "system_id:in:$($param.Value -join '|')" + } else { + $filter += "system_id:eq:$($param.Value)" + } + } + KB { + if ($param.Value.Count -gt 1) { + $filter += "hotfix_id:in:$($param.Value -join '|')" + } else { + $filter += "hotfix_id:eq:$($param.Value)" + } + } + Default { + continue + } + } + } + + if ($filter.Count -gt 1) { + $URL = "$($SystemInsightsURL)?filter[0]=$($filter[0])&filter[1]=$($filter[1])" + } else { + $URL = "$($SystemInsightsURL)?filter=$($filter)" + } + + + if ($Parallel) { + $systemInsightsPatches = Get-JCResults -URL $URL -method "GET" -limit $limit -Parallel $true + } else { + $systemInsightsPatches = Get-JCResults -URL $URL -method "GET" -limit $limit + } + } + } + } + end { + return $systemInsightsPatches + } +} \ No newline at end of file diff --git a/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemKB.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemKB.Tests.ps1 new file mode 100644 index 000000000..5a7b14ab8 --- /dev/null +++ b/PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemKB.Tests.ps1 @@ -0,0 +1,30 @@ +Describe -Tag:('JCSystemKB') 'Get-JCSystemKB' { + BeforeAll { + $systems = Get-JCSystem + $windows = $systems | Where-Object { $_.osFamily -match "windows" } + } + It "Gets all available KBs on all systems" { + { Get-JCSystemKB } | Should -Not -Throw + $KB = Get-JCSystemKB + $KB | Should -Not -BeNullOrEmpty + } + It "Gets all KBs from one system" { + $windowsMachine = $windows | Select-Object -First 1 + { Get-JCSystemKB -SystemID $windowsMachine._id } | Should -Not -Throw + Get-JCSystemKB -SystemID $windowsMachine._id | Should -Not -BeNullOrEmpty + } + It "Gets one KB from all systems" { + $SingleKB = Get-JCSystemKB | Select-Object hotfix_id -First 1 + { Get-JCSystemKB -KB $SingleKB.hotfix_id } | Should -Not -Throw + Get-JCSystemKB -KB $SingleKB.hotfix_id | Should -Not -BeNullOrEmpty + } + It "Gets one KB from one system" { + $SingleKB = Get-JCSystemKB | Select-Object -First 1 + { Get-JCSystemKB -SystemID $SingleKB.system_id -KB $SingleKB.hotfix_id } | Should -Not -Throw + Get-JCSystemKB -SystemID $SingleKB.system_id -KB $SingleKB.hotfix_id | Should -Not -BeNullOrEmpty + } + It "Accepts pipeline input from Get-JCSystem" { + $windowsMachine = $windows | Select-Object -First 1 + { $windowsMachine | Get-JCSystemKB } | Should -Not -Throw + } +} \ No newline at end of file diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index 2d4ef6574..58f035cb1 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -2441,7 +2441,7 @@ PS C:\> $BackupJcOrganizationResults.User</dev:code> <command:syntax> <command:syntaxItem> <maml:name>Connect-JCOnline</maml:name> - <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> + <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>JumpCloudApiKey</maml:name> <maml:description> <maml:para>Please enter your JumpCloud API key. This can be found in the JumpCloud admin console within "API Settings" accessible from the drop down icon next to the admin email address in the top right corner of the JumpCloud admin console.</maml:para> @@ -2520,7 +2520,7 @@ PS C:\> $BackupJcOrganizationResults.User</dev:code> </dev:type> <dev:defaultValue>None</dev:defaultValue> </command:parameter> - <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> + <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="1" aliases="none"> <maml:name>JumpCloudApiKey</maml:name> <maml:description> <maml:para>Please enter your JumpCloud API key. This can be found in the JumpCloud admin console within "API Settings" accessible from the drop down icon next to the admin email address in the top right corner of the JumpCloud admin console.</maml:para> @@ -8794,6 +8794,116 @@ PS C:\> $BackupJcOrganizationResults.User</dev:code> </maml:navigationLink> </command:relatedLinks> </command:command> + <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> + <command:details> + <command:name>Get-JCSystemKB</command:name> + <command:verb>Get</command:verb> + <command:noun>JCSystemKB</command:noun> + <maml:description> + <maml:para>{{ Fill in the Synopsis }}</maml:para> + </maml:description> + </command:details> + <maml:description> + <maml:para>{{ Fill in the Description }}</maml:para> + </maml:description> + <command:syntax> + <command:syntaxItem> + <maml:name>Get-JCSystemKB</maml:name> + <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="hotfix_id"> + <maml:name>KB</maml:name> + <maml:description> + <maml:para>The KB(s) you wish to search for. Accepts comma separated strings. Ex: KB5006670, KB5005699, KB5000736, ...</maml:para> + </maml:description> + <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> + <dev:type> + <maml:name>System.String[]</maml:name> + <maml:uri /> + </dev:type> + <dev:defaultValue>None</dev:defaultValue> + </command:parameter> + + <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="system_id, id, _id"> + <maml:name>SystemID</maml:name> + <maml:description> + <maml:para>The System Id(s) of the system(s) you want to search for KBs. Accepts comma separated strings. Ex: 618972a694380d17e4145626, 63210fc54861961ac387f0ac, ...</maml:para> + </maml:description> + <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> + <dev:type> + <maml:name>System.String[]</maml:name> + <maml:uri /> + </dev:type> + <dev:defaultValue>None</dev:defaultValue> + </command:parameter> + </command:syntaxItem> + </command:syntax> + <command:parameters> + <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="hotfix_id"> + <maml:name>KB</maml:name> + <maml:description> + <maml:para>The KB(s) you wish to search for. Accepts comma separated strings. Ex: KB5006670, KB5005699, KB5000736, ...</maml:para> + </maml:description> + <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> + <dev:type> + <maml:name>System.String[]</maml:name> + <maml:uri /> + </dev:type> + <dev:defaultValue>None</dev:defaultValue> + </command:parameter> + + <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="system_id, id, _id"> + <maml:name>SystemID</maml:name> + <maml:description> + <maml:para>The System Id(s) of the system(s) you want to search for KBs. Accepts comma separated strings. Ex: 618972a694380d17e4145626, 63210fc54861961ac387f0ac, ...</maml:para> + </maml:description> + <command:parameterValue required="true" variableLength="false">System.String[]</command:parameterValue> + <dev:type> + <maml:name>System.String[]</maml:name> + <maml:uri /> + </dev:type> + <dev:defaultValue>None</dev:defaultValue> + </command:parameter> + </command:parameters> + <command:inputTypes> + <command:inputType> + <dev:type> + <maml:name>System.String[]</maml:name> + </dev:type> + <maml:description> + <maml:para></maml:para> + </maml:description> + </command:inputType> + </command:inputTypes> + <command:returnValues> + <command:returnValue> + <dev:type> + <maml:name>System.Object</maml:name> + </dev:type> + <maml:description> + <maml:para></maml:para> + </maml:description> + </command:returnValue> + </command:returnValues> + <maml:alertSet> + <maml:alert> + <maml:para></maml:para> + </maml:alert> + </maml:alertSet> + <command:examples> + <command:example> + <maml:title>-------------------------- Example 1 --------------------------</maml:title> + <dev:code>PS C:\> {{ Add example code here }}</dev:code> + <dev:remarks> + <maml:para>{{ Add example description here }}</maml:para> + </dev:remarks> + </command:example> + </command:examples> + <command:relatedLinks> + <maml:navigationLink> + <maml:linkText>Online Version:</maml:linkText> + <maml:uri>https://github.com/TheJumpCloud/support/wiki/</maml:uri> + </maml:navigationLink> + </command:relatedLinks> + </command:command> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp"> <command:details> <command:name>Get-JCSystemUser</command:name> diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index a19c0f544..4806829c0 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,6 +1,24 @@ +## 2.14.0 + +Release Date: September 24, 2024 + +#### RELEASE NOTES + +``` +Introduces the `Get-JCSystemKB` Function - This function will allow you to search for applied hotfixes/KBs on your Windows devices across your organization +``` +#### BUG FIXES: + +Fixed a bug where Get-JCPolicy would return multiple templateIDs per policy + +#### FEATURES: + +- Get-JCSystemKB - Returns applied hotfixes/KBs on Windows devices in your organization + + ## 2.13.1 -Release Date: August 20, 2024 +Release Date: September 09, 2024 #### RELEASE NOTES