Skip to content

Commit

Permalink
Merge pull request #256 from TheJumpCloud/JumpCloudModule_1.18.1
Browse files Browse the repository at this point in the history
JumpCloudModule_1.18.1
  • Loading branch information
jworkmanjc authored Aug 20, 2020
2 parents b350ad3 + d33b079 commit 2f22cd8
Show file tree
Hide file tree
Showing 21 changed files with 281 additions and 137 deletions.
6 changes: 0 additions & 6 deletions PowerShell/Deploy/Build-HelpFiles.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
. ($PSScriptRoot + '/' + 'Get-Config.ps1')
###########################################################################
Write-Host ('[status]Importing current module: ' + $ModuleName)
Import-Module ($FilePath_psd1) -Force
# Install module onto system
If (-not (Get-InstalledModule -Name:('PlatyPS') -ErrorAction SilentlyContinue)) { Install-Module -Force -Name:('PlatyPS') }
# Import module into session
If (-not (Get-Module -Name:('PlatyPS'))) { Import-Module -Force -Name:('PlatyPS') }
Write-Host ('[status]Creating/Updating help files')
$Functions_Public | ForEach-Object {
$FunctionName = $_.BaseName
Expand Down
15 changes: 0 additions & 15 deletions PowerShell/Deploy/Functions/Create-ModuleManifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,6 @@ Function New-JCModuleManifest
$FunctionParameters.Add($_.Key, $_.Value) | Out-Null
}
}
If ($FunctionParameters.RequiredModules)
{
$FunctionParameters.RequiredModules | ForEach-Object {
If ([System.String]::IsNullOrEmpty((Get-InstalledModule).Where( { $_.Name -eq $_ })))
{
Write-Host ('Installing: ' + $_)
Install-Module -Name:($_) -Force
}
If (!(Get-Module -Name:($_)))
{
Write-Host ('Importing: ' + $_)
Import-Module -Name:($_) -Force
}
}
}
}
Else
{
Expand Down
8 changes: 5 additions & 3 deletions PowerShell/Deploy/Functions/Get-PSGalleryModuleVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Function Get-PSGalleryModuleVersion
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 1)][ValidateNotNullOrEmpty()][ValidateSet('Major', 'Minor', 'Patch', 'Manual')][string]$RELEASETYPE
)
# Check to see if module already exists to set version number
$PowerShellGalleryModule = Find-Module -Name:($Name) -ErrorAction:('Ignore')
$PowerShellGalleryModule = Find-Module -Repository:('PSGallery') -Name:($Name) -ErrorAction:('Ignore')
If ([string]::IsNullOrEmpty($PowerShellGalleryModule))
{
$ModuleVersion = [PSCustomObject]@{
Expand Down Expand Up @@ -48,10 +48,12 @@ Function Get-PSGalleryModuleVersion
}

}
if ($RELEASETYPE -eq 'Manual'){
if ($RELEASETYPE -eq 'Manual')
{
$NextVersion = ($Psd1).ModuleVersion
}
else {
Else
{
$NextVersion = ($ModuleVersion.Major, $ModuleVersion.Minor, $ModuleVersion.Patch) -join '.'
}
Add-Member -InputObject:($ModuleVersion) -MemberType:('NoteProperty') -Name:('NextVersion') -Value:($NextVersion)
Expand Down
55 changes: 23 additions & 32 deletions PowerShell/Deploy/Get-Config.ps1
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
# Log statuses
Write-Host ('[status]Platform: ' + [environment]::OSVersion.Platform)
Write-Host ('[status]PowerShell Version: ' + ($PSVersionTable.PSVersion -join '.'))
Write-Host ('[status]Host: ' + (Get-Host).Name)
Write-Host ('[status]Loaded config: ' + $MyInvocation.MyCommand.Path)
# Set variables from Azure Pipelines
# Define variables that come from Azure DevOps Pipeline
$ModuleName = $env:MODULENAME
$ModuleFolderName = $env:MODULEFOLDERNAME
$DEPLOYFOLDER = $env:DEPLOYFOLDER
$GitSourceBranch = $env:BUILD_SOURCEBRANCHNAME
$GitSourceRepo = $env:BUILD_REPOSITORY_URI
$StagingDirectory = $env:BUILD_ARTIFACTSTAGINGDIRECTORY
$GitSourceRepoWiki = $GitSourceRepo + '.wiki'
$ScriptRoot = Switch ($env:DEPLOYFOLDER) { $true { $env:DEPLOYFOLDER } Default { $PSScriptRoot } }
$FolderPath_ModuleRootPath = (Get-Item -Path:($ScriptRoot)).Parent.FullName
$GitSourceRepoWiki = "$($GitSourceRepo).wiki"
$RELEASETYPE = $env:RELEASETYPE
$XAPIKEY_PESTER = $env:XAPIKEY_PESTER
$XAPIKEY_MTP = $env:XAPIKEY_MTP
$NUGETAPIKEY = $env:NUGETAPIKEY
$EnvironmentConfig = 'TestEnvironmentVariables.ps1'
$SYSTEM_ACCESSTOKEN = $env:SYSTEM_ACCESSTOKEN
# Log statuses
Write-Host ('[status]Platform: ' + [environment]::OSVersion.Platform)
Write-Host ('[status]PowerShell Version: ' + ($PSVersionTable.PSVersion -join '.'))
Write-Host ('[status]Host: ' + (Get-Host).Name)
Write-Host ('[status]Loaded config: ' + $MyInvocation.MyCommand.Path)
# Set variables from Azure Pipelines
$ScriptRoot = Switch ($DEPLOYFOLDER) { $true { $DEPLOYFOLDER } Default { $PSScriptRoot } }
$FolderPath_ModuleRootPath = (Get-Item -Path:($ScriptRoot)).Parent.FullName
$GitHubWikiUrl = 'https://github.com/TheJumpCloud/support/wiki/'
$FilePath_ModuleBanner = $FolderPath_ModuleRootPath + '/ModuleBanner.md'
$FilePath_ModuleChangelog = $FolderPath_ModuleRootPath + '/ModuleChangelog.md'
# Define required files and folders variables
$RequiredFiles = ('LICENSE', 'psm1', 'psd1', 'PesterConfig')
$RequiredFiles = ('LICENSE', 'psm1', 'psd1')
$RequiredFolders = ('Docs', 'Private', 'Public', 'Tests', 'en-US')
# Define folder path variables
$FolderPath_Module = $FolderPath_ModuleRootPath + '/' + $ModuleFolderName
Expand All @@ -32,32 +34,21 @@ $RequiredFolders | ForEach-Object {
New-Variable -Name:('FolderPath_' + $_.Replace('-', '')) -Value:($FolderPath) -Force
}
$RequiredFiles | ForEach-Object {
$FileName = If ($_ -in ('psm1', 'psd1')) { $ModuleName + '.' + $_ } ElseIf ($_ -eq 'PesterConfig') { $EnvironmentConfig } Else { $_ }
$FilePath = If ($_ -eq 'PesterConfig') { $FolderPath_Module + '/' + $FolderName_Tests + '/' + $FileName } Else { $FolderPath_Module + '/' + $FileName }
$FileName = If ($_ -in ('psm1', 'psd1')) { $ModuleName + '.' + $_ } Else { $_ }
$FilePath = $FolderPath_Module + '/' + $FileName
New-Variable -Name:('FileName_' + $_) -Value:($FileName) -Force;
New-Variable -Name:('FilePath_' + $_) -Value:($FilePath) -Force;
}
# Get module function names
$Functions_Public = If (Test-Path -Path:($FolderPath_Public)) { Get-ChildItem -Path:($FolderPath_Public + '/' + '*.ps1') -Recurse }
$Functions_Private = If (Test-Path -Path:($FolderPath_Private)) { Get-ChildItem -Path:($FolderPath_Private + '/' + '*.ps1') -Recurse }
# Get psd1 contents
# Get .psd1 contents
$Psd1 = Import-PowerShellDataFile -Path:($FilePath_psd1)
$RequiredModules = $Psd1.RequiredModules
# Load deploy functions
$DeployFunctions = @(Get-ChildItem -Path:($PSScriptRoot + '/Functions/*.ps1') -Recurse)
Foreach ($DeployFunction In $DeployFunctions)
# Get module function names
$Functions_Public = If (Test-Path -Path:($FolderPath_Public))
{
Try
{
. $DeployFunction.FullName
}
Catch
{
Write-Error -Message:('Failed to import function: ' + $DeployFunction.FullName)
}
Get-ChildItem -Path:($FolderPath_Public + '/' + '*.ps1') -Recurse
}
# Install NuGet
If (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('SilentlyContinue')))
$Functions_Private = If (Test-Path -Path:($FolderPath_Private))
{
Write-Host ('[status]Installing package provider NuGet'); Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force
Get-ChildItem -Path:($FolderPath_Private + '/' + '*.ps1') -Recurse
}
# Setup-Dependencies.ps1
.("$ScriptRoot/Setup-Dependencies.ps1")
64 changes: 56 additions & 8 deletions PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1
Original file line number Diff line number Diff line change
@@ -1,17 +1,66 @@
. ((Get-Item -Path:($PSScriptRoot)).Parent.FullName + '/' + 'Get-Config.ps1')
###########################################################################
Install-Module -Name:('PSScriptAnalyzer') -Force
$ApprovedFunctions = [Ordered]@{
'JumpCloud.SDK.DirectoryInsights' = @(
[PSCustomObject]@{
Destination = '/Public/DirectoryInsights'
Name = 'Get-JcSdkEvent'
Name = 'Get-JcSdkEvent';
Destination = '/Public/DirectoryInsights';
},
[PSCustomObject]@{
Destination = '/Public/DirectoryInsights'
Name = 'Get-JcSdkEventCount'
Name = 'Get-JcSdkEventCount';
Destination = '/Public/DirectoryInsights';
}
)
);
# 'JumpCloud.SDK.V2' = @(
# [PSCustomObject]@{
# Name = 'Get-JcSdkAppleMdm';
# Destination = '/Public/AppleMdm';
# },
# [PSCustomObject]@{
# Name = 'Remove-JcSdkAppleMdm';
# Destination = '/Public/AppleMdm';
# },
# [PSCustomObject]@{
# Name = 'Set-JcSdkAppleMdm';
# Destination = '/Public/AppleMdm';
# },
# [PSCustomObject]@{
# Name = 'Get-JcSdkAppleMdmCsr';
# Destination = '/Public/AppleMdm';
# },
# [PSCustomObject]@{
# Name = 'Get-JcSdkAppleMdmDepKey';
# Destination = '/Public/AppleMdm';
# },
# [PSCustomObject]@{
# Name = 'Clear-JcSdkAppleMdmDevice';
# Destination = '/Public/AppleMdm';
# },
# [PSCustomObject]@{
# Name = 'Get-JcSdkAppleMdmDevice';
# Destination = '/Public/AppleMdm';
# },
# [PSCustomObject]@{
# Name = 'Lock-JcSdkAppleMdmDevice';
# Destination = '/Public/AppleMdm';
# },
# [PSCustomObject]@{
# Name = 'Restart-JcSdkAppleMdmDevice';
# Destination = '/Public/AppleMdm';
# },
# [PSCustomObject]@{
# Name = 'Stop-JcSdkAppleMdmDevice';
# Destination = '/Public/AppleMdm';
# },
# [PSCustomObject]@{
# Name = 'Sync-JcSdkAppleMdmDevice';
# Destination = '/Public/AppleMdm';
# },
# [PSCustomObject]@{
# Name = 'Get-JcSdkAppleMdmEnrollmentProfile';
# Destination = '/Public/AppleMdm';
# }
# )
}
$SdkPrefix = 'JcSdk'
$JumpCloudModulePrefix = 'JC'
Expand All @@ -21,9 +70,8 @@ $Divider = '|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|'
$FunctionTemplate = "{0}`nFunction {1}`n{{`n$($IndentChar){2}`n$($IndentChar)Param(`n{3}`n$($IndentChar))`n$($IndentChar)Begin`n$($IndentChar){{`n{4}`n$($IndentChar)}}`n$($IndentChar)Process`n$($IndentChar){{`n{5}`n$($IndentChar)}}`n$($IndentChar)End`n$($IndentChar){{`n{6}`n$($IndentChar)}}`n}}"
$ScriptAnalyzerResults = @()
$JumpCloudModulePath = (Get-Item -Path:($PSScriptRoot)).Parent.Parent.FullName + '/JumpCloud Module'
Import-Module -Name:($RequiredModules)
Get-Module -Refresh -ListAvailable -All | Out-Null
$Modules = Get-Module -Name:($RequiredModules | Where-Object { $_ -in $ApprovedFunctions.Keys })
$Modules = Get-Module -Name:($Psd1.RequiredModules | Where-Object { $_ -in $ApprovedFunctions.Keys })
If (-not [System.String]::IsNullOrEmpty($Modules))
{
ForEach ($Module In $Modules)
Expand Down
64 changes: 57 additions & 7 deletions PowerShell/Deploy/Setup-Dependencies.ps1
Original file line number Diff line number Diff line change
@@ -1,18 +1,68 @@
. ($PSScriptRoot + '/' + 'Get-Config.ps1')
###########################################################################
ForEach ($RequiredModule In $RequiredModules)
# Install NuGet
If (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('SilentlyContinue')))
{
Write-Host("Setting up dependency '$RequiredModule'")
Write-Host ('[status]Installing package provider NuGet');
Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force
}
# Install dependent modules
$DependentModules = @('PSScriptAnalyzer', 'PlatyPS')
ForEach ($DependentModule In $DependentModules)
{
Write-Host("[status]Setting up dependency '$DependentModule'")
# Check to see if the module is installed
If ([System.String]::IsNullOrEmpty((Get-InstalledModule).Where( { $_.Name -eq $DependentModule })))
{
Write-Host("[status]Installing '$DependentModule' from 'PSGallery'")
Install-Module -Repository:('PSGallery') -Force -Name:($DependentModule) -Scope:('CurrentUser')
}
# Get-Module -Refresh -ListAvailable
If ([System.String]::IsNullOrEmpty((Get-Module).Where( { $_.Name -eq $DependentModule })))
{
Write-Host("[status]Importing '$DependentModule'")
Import-Module -Name:($DependentModule) -Force
}
}
# Register PSRepository
$Password = $SYSTEM_ACCESSTOKEN | ConvertTo-SecureString -AsPlainText -Force
$Credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $SYSTEM_ACCESSTOKEN, $Password
If (-not (Get-PackageSource -Name:('JumpCloudPowershell-Dev') -ErrorAction SilentlyContinue))
{
Write-Host("[status]Register-PackageSource 'JumpCloudPowershell-Dev'")
Register-PackageSource -Trusted -ProviderName:("PowerShellGet") -Name:('JumpCloudPowershell-Dev') -Location:("https://pkgs.dev.azure.com/JumpCloudPowershell/_packaging/Dev/nuget/v2/") -Credential:($Credentials)
}
# Install required modules
ForEach ($RequiredModule In $Psd1.RequiredModules)
{
Write-Host("[status]Setting up dependency '$RequiredModule'")
# Check to see if the module is installed
If ([System.String]::IsNullOrEmpty((Get-InstalledModule).Where( { $_.Name -eq $RequiredModule })))
{
Write-Host("Installing '$RequiredModule'")
Install-Module -Name:($RequiredModule) -Force
Write-Host("[status]Installing '$RequiredModule' from 'JumpCloudPowershell-Dev'")
Install-Module -Repository:('JumpCloudPowershell-Dev') -AllowPrerelease -Force -Name:($RequiredModule) -Credential:($Credentials) -Scope:('CurrentUser')
}
# Get-Module -Refresh -ListAvailable
If ([System.String]::IsNullOrEmpty((Get-Module).Where( { $_.Name -eq $RequiredModule })))
{
Write-Host("Importing '$RequiredModule'")
Write-Host("[status]Importing '$RequiredModule'")
Import-Module -Name:($RequiredModule) -Force
}
}
# Load current module
If ([System.String]::IsNullOrEmpty((Get-Module).Where( { $_.Name -eq $ModuleName })))
{
Write-Host("[status]Importing '$ModuleName'")
Import-Module ($FilePath_psd1) -Force
}
# Load "Deploy" functions
$DeployFunctions = @(Get-ChildItem -Path:($PSScriptRoot + '/Functions/*.ps1') -Recurse)
Foreach ($DeployFunction In $DeployFunctions)
{
Try
{
. $DeployFunction.FullName
}
Catch
{
Write-Error -Message:('Failed to import function: ' + $DeployFunction.FullName)
}
}
2 changes: 0 additions & 2 deletions PowerShell/Deploy/Tests/PSScriptAnalyzer.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# # }
# # Context 'PSScriptAnalyzer Tests' {
# # It 'Passes Invoke-PSScriptAnalyzer' {
Write-Host ('[status]Installing module: PSScriptAnalyzer')
Install-Module -Name:('PSScriptAnalyzer') -Force -Scope:('CurrentUser')
Write-Host ('[status]Running PSScriptAnalyzer on: ' + $FolderPath_Module)
$ScriptAnalyzerResults = Invoke-ScriptAnalyzer -Path:($FolderPath_Module) -Recurse
# # $ScriptAnalyzerResults | Should BeNullOrEmpty
Expand Down
6 changes: 3 additions & 3 deletions PowerShell/JumpCloud Module/Docs/Get-JCSystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ Get-JCSystem [[-hostname] <String>] [-displayName <String>] [-version <String>]
[-systemTimezone <String>] [-active <Boolean>] [-allowMultiFactorAuthentication <Boolean>]
[-allowPublicKeyAuthentication <Boolean>] [-allowSshPasswordAuthentication <Boolean>]
[-allowSshRootLogin <Boolean>] [-modifySSHDConfig <Boolean>] [-hasServiceAccount <Boolean>]
[-filterDateProperty <String>] [-returnProperties <String[]>] -dateFilter <String> -date <String>
[-filterDateProperty <String>] [-returnProperties <String[]>] -dateFilter <String> -date <DateTime>
[<CommonParameters>]
```

### ByID
```
Get-JCSystem -SystemID <String> [-SystemFDEKey] -dateFilter <String> -date <String> [<CommonParameters>]
Get-JCSystem -SystemID <String> [-SystemFDEKey] -dateFilter <String> -date <DateTime> [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -216,7 +216,7 @@ Accept wildcard characters: False
Date to filter on.
```yaml
Type: System.String
Type: System.DateTime
Parameter Sets: (All)
Aliases:

Expand Down
6 changes: 3 additions & 3 deletions PowerShell/JumpCloud Module/Docs/Get-JCUser.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ Get-JCUser [[-username] <String>] [-firstname <String>] [-lastname <String>] [-e
[-filterDateProperty <String>] [-returnProperties <String[]>] [-middlename <String>] [-displayname <String>]
[-jobTitle <String>] [-employeeIdentifier <String>] [-department <String>] [-costCenter <String>]
[-company <String>] [-employeeType <String>] [-description <String>] [-location <String>]
[-external_dn <String>] [-external_source_type <String>] -dateFilter <String> -date <String>
[-external_dn <String>] [-external_source_type <String>] -dateFilter <String> -date <DateTime>
[<CommonParameters>]
```

### ByID
```
Get-JCUser -userid <String> -dateFilter <String> -date <String> [<CommonParameters>]
Get-JCUser -userid <String> -dateFilter <String> -date <DateTime> [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -153,7 +153,7 @@ Accept wildcard characters: False
Date to filter on.
```yaml
Type: System.String
Type: System.DateTime
Parameter Sets: (All)
Aliases:

Expand Down
2 changes: 1 addition & 1 deletion PowerShell/JumpCloud Module/JumpCloud.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>JumpCloud</id>
<version>1.18.0</version>
<version>1.18.1</version>
<description>PowerShell functions to manage a JumpCloud Directory-as-a-Service</description>
<authors>JumpCloud Solutions Architect Team</authors>
<owners>JumpCloud</owners>
Expand Down
4 changes: 2 additions & 2 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/14/2020
# Generated on: 8/20/2020
#

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

# Version number of this module.
ModuleVersion = '1.18.0'
ModuleVersion = '1.18.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
2 changes: 1 addition & 1 deletion PowerShell/JumpCloud Module/ModuleUpdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $GitHubWikiUrl = 'https://github.com/TheJumpCloud/support/wiki/'
Write-Host ('[status]Importing current module: ' + $ModuleName)
Import-Module ($FilePath_Psd1) -Force
Write-Host ('[status]Installing module: PlatyPS')
Install-Module -Name:('PlatyPS') -Force
Install-Module -Repository:('PSGallery') -Name:('PlatyPS') -Force
# Clear out existing docs
If (-not [System.String]::IsNullOrEmpty($IncludeList))
{
Expand Down
Loading

0 comments on commit 2f22cd8

Please sign in to comment.