Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JumpCloud Module 2.14.0 Release #606

Merged
merged 8 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PowerShell/JumpCloud Module/Docs/Connect-JCOnline.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>]
```

Expand Down Expand Up @@ -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)
Expand Down
113 changes: 113 additions & 0 deletions PowerShell/JumpCloud Module/Docs/Get-JCSystemKB.md
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion PowerShell/JumpCloud Module/Docs/JumpCloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Module Name: JumpCloud
Module Guid: 31c023d1-a901-48c4-90a3-082f91b31646
Download Help Link: https://github.com/TheJumpCloud/support/wiki
Help Version: 2.13.1
Help Version: 2.14.0
Locale: en-Us
---

Expand Down Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions PowerShell/JumpCloud Module/JumpCloud.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: JumpCloud Solutions Architect Team
#
# Generated on: 8/20/2024
# Generated on: 9/24/2024
#

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

# Version number of this module.
ModuleVersion = '2.13.1'
ModuleVersion = '2.14.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -81,4 +83,4 @@ Function Get-JCPolicy () {
Return $Results | Select-Object -Property "name", "id", "templateID", "values", "template"
}
}
}
}
87 changes: 87 additions & 0 deletions PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemKB.ps1
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
Loading
Loading