-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #606 from TheJumpCloud/JumpCloudModule_2.14.0
JumpCloud Module 2.14.0 Release
- Loading branch information
Showing
10 changed files
with
379 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
PowerShell/JumpCloud Module/Public/Systems/Get-JCSystemKB.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemKB.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Oops, something went wrong.