Skip to content

Commit

Permalink
Merge pull request #593 from TheJumpCloud/CUT-4228_GetJCAdmin
Browse files Browse the repository at this point in the history
CUT-4228: Get-JCAdmin Function
  • Loading branch information
gweinjc authored Aug 8, 2024
2 parents 351806d + ab172bd commit 0687bb7
Show file tree
Hide file tree
Showing 91 changed files with 1,326 additions and 316 deletions.
84 changes: 83 additions & 1 deletion PowerShell/Deploy/Build-HelpFiles.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,59 @@ Param(
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = 'Name of module')][ValidateNotNullOrEmpty()][System.String]$ModuleName = 'JumpCloud'
, [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = 'Path to module root')][ValidateNotNullOrEmpty()][System.String]$ModulePath = './PowerShell/JumpCloud Module' # $PSScriptRoot
, [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = 'Which parameter set to be used for New-MarkdownHelp')][ValidateNotNullOrEmpty()][ValidateSet('FromCommand', 'FromModule')][System.String]$NewMarkdownHelpParamSet = 'FromCommand'
, [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = 'Language locale')][ValidateNotNullOrEmpty()][System.String]$Locale = 'en-US'
, [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = 'Language locale')][ValidateNotNullOrEmpty()][System.String]$Locale = 'en-Us'
, [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = 'For adding comment based help')][ValidateNotNullOrEmpty()][System.Boolean]$AddCommentBasedHelp = $false
)
# modified from source: https://github.com/PowerShell/platyPS/issues/595#issuecomment-1820971702
function Remove-CommonParameterFromMarkdown {
<#
.SYNOPSIS
Remove a PlatyPS generated parameter block.
.DESCRIPTION
Removes parameter block for the provided parameter name from the markdown file provided.
#>
param(
[Parameter(Mandatory)]
[string[]]
$Path,

[Parameter(Mandatory = $false)]
[string[]]
$ParameterName = @('ProgressAction')
)
$ErrorActionPreference = 'Stop'
$Docs = Get-ChildItem -Path $Path -Recurse
foreach ($p in $Docs) {
Write-Host "[status]Removing ProgressAction from $p"
$content = (Get-Content -Path $p -Raw).TrimEnd()
$updateFile = $false
foreach ($param in $ParameterName) {
if (-not ($Param.StartsWith('-'))) {
$param = "-$($param)"
}
# Remove the parameter block
$pattern = "(?m)^### $param\r?\n[\S\s]*?(?=#{2,3}?)"
$newContent = $content -replace $pattern, ''
# Remove the parameter from the syntax block
$pattern = " \[$param\s?.*?]"
$newContent = $newContent -replace $pattern, ''
if ($null -ne (Compare-Object -ReferenceObject $content -DifferenceObject $newContent)) {
Write-Verbose "Added $param to $p"
# Update file content
$content = $newContent
$updateFile = $true
}
}
# Save file if content has changed
if ($updateFile) {
$newContent | Out-File -Encoding utf8 -FilePath $p
Write-Verbose "Updated file: $p"
}
}
return
}
# Define misc. vars
$FilePath_Psd1 = "$ModulePath/$ModuleName.psd1"
$FolderPath_Docs = "$ModulePath/Docs"
Expand Down Expand Up @@ -140,6 +190,38 @@ Try {
# Creating: .\en-Us\$ModuleName-help.xml and .\en-Us\about_$ModuleName.help.txt
Write-Host ("[status]Creating: .\en-Us\$ModuleName-help.xml and .\en-Us\about_$ModuleName.help.txt")
New-ExternalHelp -Path:($FolderPath_Docs) -OutputPath:($FolderPath_enUS) -Force # -ApplicableTag <String> -Encoding <Encoding> -MaxAboutWidth <Int32> -ErrorLogFile <String> -ShowProgress
# Remove ProgressAction from Doc files (PowerShell 7.4.1 with PlatyPS)
Remove-CommonParameterFromMarkdown -Path:($FolderPath_Docs)
$ProgressActionXML1 = @"
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">System.Management.Automation.ActionPreference</command:parameterValue>
<dev:type>
<maml:name>System.Management.Automation.ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
"@
$ProgressActionXML2 = @"
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
<maml:name>ProgressAction</maml:name>
<maml:description>
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">System.Management.Automation.ActionPreference</command:parameterValue>
<dev:type>
<maml:name>System.Management.Automation.ActionPreference</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>None</dev:defaultValue>
</command:parameter>
"@
(Get-Content -Path "$FolderPath_enUS/JumpCloud-help.xml" -Raw).Replace($ProgressActionXML1, '') | Set-Content "$FolderPath_enUS/JumpCloud-help.xml"
(Get-Content -Path "$FolderPath_enUS/JumpCloud-help.xml" -Raw).Replace($ProgressActionXML2, '') | Set-Content "$FolderPath_enUS/JumpCloud-help.xml"
} Catch {
Write-Error ($_)
}
Expand Down
12 changes: 7 additions & 5 deletions PowerShell/JumpCloud Module/Docs/Add-JCAssociation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ Create an association between two object within the JumpCloud console.

### ById (Default)
```
Add-JCAssociation [-Type] <String> [-Force] [-Id] <String[]> [[-TargetType] <String[]>] [[-TargetId] <String>]
[[-TargetName] <String>] [[-Attributes] <PSObject>] [<CommonParameters>]
Add-JCAssociation [-Type] <String> [-Force] [-Id] <String[]>
[[-TargetType] <String[]>] [[-TargetId] <String>] [[-TargetName] <String>] [[-Attributes] <PSObject>]
[<CommonParameters>]
```

### ByName
```
Add-JCAssociation [-Type] <String> [-Force] [-Name] <String[]> [[-TargetType] <String[]>]
[[-TargetId] <String>] [[-TargetName] <String>] [[-Attributes] <PSObject>] [<CommonParameters>]
Add-JCAssociation [-Type] <String> [-Force] [-Name] <String[]>
[[-TargetType] <String[]>] [[-TargetId] <String>] [[-TargetName] <String>] [[-Attributes] <PSObject>]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -181,4 +183,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
### System.Object
## NOTES
## RELATED LINKS
## RELATED LINKS
11 changes: 7 additions & 4 deletions PowerShell/JumpCloud Module/Docs/Add-JCCommandTarget.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ Associates a JumpCloud system or a JumpCloud system group with a JumpCloud comma

### SystemID (Default)
```
Add-JCCommandTarget [-CommandID] <String> [-SystemID] <Object> [<CommonParameters>]
Add-JCCommandTarget [-CommandID] <String> [-SystemID] <Object>
[<CommonParameters>]
```

### GroupID
```
Add-JCCommandTarget [-CommandID] <String> [-GroupID] <Object> [<CommonParameters>]
Add-JCCommandTarget [-CommandID] <String> [-GroupID] <Object>
[<CommonParameters>]
```

### GroupName
```
Add-JCCommandTarget [-CommandID] <String> [-GroupName] <Object> [<CommonParameters>]
Add-JCCommandTarget [-CommandID] <String> [-GroupName] <Object>
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -131,4 +134,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
### System.Object
## NOTES
## RELATED LINKS
## RELATED LINKS
2 changes: 1 addition & 1 deletion PowerShell/JumpCloud Module/Docs/Add-JCGsuiteMember.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
### System.Object
## NOTES
## RELATED LINKS
## RELATED LINKS
2 changes: 1 addition & 1 deletion PowerShell/JumpCloud Module/Docs/Add-JCOffice365Member.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
### System.Object
## NOTES
## RELATED LINKS
## RELATED LINKS
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Adds Radius reply attributes to a JumpCloud user group.

```
Add-JCRadiusReplyAttribute [-GroupName] <String> [-VLAN <String>] [-NumberOfAttributes <Int32>]
-Attribute1_name <String> -Attribute1_value <String> -Attribute2_name <String> -Attribute2_value <String>
[-VLANTag <String>] [<CommonParameters>]
-Attribute1_name <String> -Attribute1_value <String>
-Attribute2_name <String> -Attribute2_value <String> [-VLANTag <String>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -208,4 +208,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
### System.Object
## NOTES
## RELATED LINKS
## RELATED LINKS
5 changes: 3 additions & 2 deletions PowerShell/JumpCloud Module/Docs/Add-JCSystemGroupMember.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Adds a JumpCloud System to a JumpCloud System Group

### ByName (Default)
```
Add-JCSystemGroupMember [-GroupName] <String> -SystemID <String> [<CommonParameters>]
Add-JCSystemGroupMember [-GroupName] <String> -SystemID <String>
[<CommonParameters>]
```

### ByID
Expand Down Expand Up @@ -153,4 +154,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
### System.Object
## NOTES
## RELATED LINKS
## RELATED LINKS
8 changes: 5 additions & 3 deletions PowerShell/JumpCloud Module/Docs/Add-JCSystemUser.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ Associates a JumpCloud User account with a local account on a JumpCloud managed

### ByName (Default)
```
Add-JCSystemUser [-Username] <String> -SystemID <String> [-Administrator <Boolean>] [<CommonParameters>]
Add-JCSystemUser [-Username] <String> -SystemID <String> [-Administrator <Boolean>]
[<CommonParameters>]
```

### ByID
```
Add-JCSystemUser -UserID <String> -SystemID <String> [-Administrator <Boolean>] [<CommonParameters>]
Add-JCSystemUser -UserID <String> -SystemID <String> [-Administrator <Boolean>]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -143,4 +145,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
### System.Object
## NOTES
## RELATED LINKS
## RELATED LINKS
8 changes: 5 additions & 3 deletions PowerShell/JumpCloud Module/Docs/Add-JCUserGroupMember.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ Adds a JumpCloud user to a JumpCloud User Group.

### ByName (Default)
```
Add-JCUserGroupMember [-GroupName] <String> [-Username] <String> [<CommonParameters>]
Add-JCUserGroupMember [-GroupName] <String> [-Username] <String>
[<CommonParameters>]
```

### ByID
```
Add-JCUserGroupMember [[-GroupName] <String>] [-ByID] [-GroupID <String>] -UserID <String> [<CommonParameters>]
Add-JCUserGroupMember [[-GroupName] <String>] [-ByID] [-GroupID <String>] -UserID <String>
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -169,4 +171,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
### System.Object
## NOTES
## RELATED LINKS
## RELATED LINKS
5 changes: 3 additions & 2 deletions PowerShell/JumpCloud Module/Docs/Backup-JCOrganization.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Backup your JumpCloud organization to local json files

### All (Default)
```
Backup-JCOrganization -Path <String> [-All] [-Format <String>] [-PassThru] [<CommonParameters>]
Backup-JCOrganization -Path <String> [-All] [-Format <String>] [-PassThru]
[<CommonParameters>]
```

### Type
Expand Down Expand Up @@ -171,4 +172,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## RELATED LINKS
[https://github.com/TheJumpCloud/support/tree/master/PowerShell/JumpCloud%20Module/Docs/Backup-JCOrganization.md](https://github.com/TheJumpCloud/support/tree/master/PowerShell/JumpCloud%20Module/Docs/Backup-JCOrganization.md)
[https://github.com/TheJumpCloud/support/tree/master/PowerShell/JumpCloud%20Module/Docs/Backup-JCOrganization.md](https://github.com/TheJumpCloud/support/tree/master/PowerShell/JumpCloud%20Module/Docs/Backup-JCOrganization.md)
6 changes: 3 additions & 3 deletions PowerShell/JumpCloud Module/Docs/Connect-JCOnline.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ The Connect-JCOnline function sets the global variable $JCAPIKEY
## SYNTAX

```
Connect-JCOnline [-force] [-JumpCloudApiKey] <String> [[-JumpCloudOrgId] <String>] [[-JCEnvironment] <String>]
[<CommonParameters>]
Connect-JCOnline [-force] [-JumpCloudApiKey] <String>
[[-JumpCloudOrgId] <String>] [[-JCEnvironment] <String>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -122,4 +122,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
### System.Object
## NOTES
## RELATED LINKS
## RELATED LINKS
12 changes: 7 additions & 5 deletions PowerShell/JumpCloud Module/Docs/Copy-JCAssociation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ Copy the associations from one object to another.

### ById (Default)
```
Copy-JCAssociation [-Type] <String> [-Force] [-Id] <String[]> [[-TargetId] <String>] [[-TargetName] <String>]
[-RemoveExisting] [[-IncludeType] <String[]>] [[-ExcludeType] <String[]>] [<CommonParameters>]
Copy-JCAssociation [-Type] <String> [-Force] [-Id] <String[]>
[[-TargetId] <String>] [[-TargetName] <String>] [-RemoveExisting] [[-IncludeType] <String[]>]
[[-ExcludeType] <String[]>] [<CommonParameters>]
```

### ByName
```
Copy-JCAssociation [-Type] <String> [-Force] [-Name] <String[]> [[-TargetId] <String>] [[-TargetName] <String>]
[-RemoveExisting] [[-IncludeType] <String[]>] [[-ExcludeType] <String[]>] [<CommonParameters>]
Copy-JCAssociation [-Type] <String> [-Force] [-Name] <String[]>
[[-TargetId] <String>] [[-TargetName] <String>] [-RemoveExisting] [[-IncludeType] <String[]>]
[[-ExcludeType] <String[]>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -196,4 +198,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
### System.Object
## NOTES
## RELATED LINKS
## RELATED LINKS
Loading

0 comments on commit 0687bb7

Please sign in to comment.