Skip to content

Commit

Permalink
Merge pull request #89 from NickETH/master
Browse files Browse the repository at this point in the history
Update version check to R2024x
  • Loading branch information
baramundi-ahaugk authored Dec 12, 2024
2 parents ad90daf + b64725b commit 056cce8
Show file tree
Hide file tree
Showing 10 changed files with 603 additions and 26 deletions.
35 changes: 16 additions & 19 deletions bConnect/Private/Get-bConnectVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Function Get-bConnectVersion() {
Checks for supported bConnect version and returns the version (e.g. "v1.0").
#>

[CmdletBinding()]
Param (
[switch]$bMSVersion
)
Expand All @@ -16,26 +15,24 @@ Function Get-bConnectVersion() {
$_bmsVersion = $_info.bMSVersion

switch -Wildcard ($_bmsVersion) {
"19.*" {
Write-Verbose "DEPRECATED! bConnect 2019 R1 or newer"
}

"20.*" {
Write-Verbose "bConnect 2020 R1 or newer"
}

"19.*" {
Write-Verbose "DEPRECATED! bConnect 2019 R1 or newer"
}
"20.*" {
Write-Verbose "bConnect 2020 R1 or newer"
}
"21.*" {
Write-Verbose "bConnect 2021 R1 or newer"
}

Write-Verbose "bConnect 2021 R1 or newer"
}
"22.*" {
Write-Verbose "bConnect 2022 R1 or newer"
}

"23.*" {
Write-Verbose "bConnect 2023 R1 or newer"
}

Write-Verbose "bConnect 2022 R1 or newer"
}
"23.*" {
Write-Verbose "bConnect 2023 R1 or newer"
}
"24.*" {
Write-Verbose "bConnect 2023 R1 or newer"
}
default {
Write-Warning "UNSUPPORTED bMS Version $($_bmsVersion)! Unknown bConnect Version -> Fallback to $($script:_bConnectFallbackVersion)"
$_bcVersion = $script:_bConnectFallbackVersion
Expand Down
65 changes: 65 additions & 0 deletions bConnect/Public/Edit-bConnectJobWindowsOptions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Function Edit-bConnectJobWindowsOptions() {

<#
.Synopsis
Creates a new WindowsOptions object for Jobs.
Empty or filled with given information.
.Parameter JobWindowsOptions
A valid JobWindowsOptions object.
.Parameter LatestLogOff
If true the user will be logged off as late as possible.
.Parameter LatestLogon
If true the user will be logged on as late as possible.
.Parameter LogoffUserBeforeJobStart
If true the user will be logged off before job start.
.Parameter UserDelayShutdown
If true the user is able to delay shutdowns.
.Parameter UseForceLogoff
If true the user will be logged off even if there are unsaved changes.
.Parameter UsersettingsPerUser
If true, the user settings will be executed per user during software deployment.
.Parameter WillReinstall
If true, the job will reinstall the client.
.Parameter IgnoreBandwidth
If true, the job will be executed ignoring the configured MinBandwidth.
.Parameter IgnoreBITS
If true, the job will not support baramundi background transfer.
.Parameter SupportEndpointsInInternetMode
If true, the job will also be executed on clients which are currently roaming.
.Outputs
WindowsOptions object (see bConnect documentation for more details)
#>

[OutputType("System.Management.Automations.PSObject")]
Param(
[Parameter(Mandatory=$true)][PSCustomObject]$JobWindowsOptions,
[bool]$LatestLogOff,
[bool]$LatestLogon,
[bool]$LogoffUserBeforeJobStart,
[bool]$UserDelayShutdown,
[bool]$UseForceLogoff,
[bool]$UsersettingsPerUser,
[bool]$WillReinstall,
[bool]$IgnoreBandwidth,
[bool]$IgnoreBITS,
[bool]$SupportEndpointsInInternetMode
)

$_new_JobWindowsOptions = ConvertTo-Hashtable $JobWindowsOptions

# We remove the input object from the argument hash table.
# Because we want to iterate through it later.
$TrashResult = $PSBoundParameters.Remove('JobWindowsOptions')

Foreach($_property in $PsBoundParameters.GetEnumerator()) {
# Write-Output ("Key={0} Value={1}" -f $_property.Key,$_property.Value)
if($_new_JobWindowsOptions.($_property.Key)){
$_new_JobWindowsOptions.($_property.Key) = $_property.Value
}else{
$_new_JobWindowsOptions.Add($_property.Key,$_property.Value)
}

}
#Write-Output $_new_JobWindowsOptions
return $_new_JobWindowsOptions
}
6 changes: 3 additions & 3 deletions bConnect/Public/Edit-bConnectStaticGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
}
$StaticGroup.EndpointIds = $_endpointIds

Foreach($_property in $_propertyList) {
If($StaticGroup[$_property] -ine $_old_group[$_property]) {
Foreach($_property in $_propertyList) {
If(($StaticGroup[$_property] -join ', ') -ine ($_old_group[$_property] -join ', ')) {
$_new_group += @{ $_property = $StaticGroup[$_property] }
}
}
}

return Invoke-bConnectPatch -Controller "StaticGroups" -Version $_connectVersion -objectGuid $StaticGroup.Id -Data $_new_group
} else {
Expand Down
130 changes: 130 additions & 0 deletions bConnect/Public/New-bConnectJob.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
Function New-bConnectJob() {
<#
.Synopsis
Create a new job.
.Parameter Name
Name of a job
.Parameter DisplayName
Display name of a job. Visible in the bMA TrayNotifier and Kiosk.
.Parameter Type
Job type: Windows, Mobile, Universal
.Parameter Steps
The job steps which the job will execute.
.Parameter ParentId
The GUID of the new jobs parent OU.
.Parameter Id
The GUID of the new job object, optional.
.Parameter Category
The job’s category.
.Parameter Description
The job’s description.
.Parameter Comments
Admin’s comment.
.Parameter IconId
The id of the job’s icon, which is visible in the Kiosk.
.Parameter JobExecutionTimeout
The execution timeout of the job.
.Parameter AbortOnError
If set to true the job aborts after an erroneous job step.
.Parameter RemoveInstanceAfterCompletion
If set to true the job assignment will be deleted after successful execution.
.Parameter WindowsProperties
The windows properties of the job. Must not be null if job is for windows endpoints. Must be null if job is for mobile or mac endpoints.
.Parameter MobileAndMacProperties
The mobile and mac properties of the job. Must not be null if job is for mobile or mac endpoints. Must be null if the job is for windows endpoints.
.Parameter UniversalProperties
The properties of a universal job. Must be null if the job is for windows or mobile endpoints.
.Outputs
NewJob (see bConnect documentation for more details).
#>

[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'low')]
[OutputType("System.Management.Automations.PSObject","System.Boolean")]
Param (
[Parameter(Mandatory=$true)][string]$Name,
[Parameter(Mandatory=$true)][string]$DisplayName,
[Parameter(Mandatory=$true)][ValidateSet("Windows","Mobile","Universal",ignoreCase=$true)][string]$Type,
[Parameter(Mandatory=$true)][PSCustomObject[]]$Steps,
[string]$ParentId = "C6567FDB-74B4-40C1-846D-12011A163B4A", #guid of "Job Management" as fallback
[string]$Id,
[string]$Category,
[string]$Description,
[string]$Comments,
[string]$IconId,
[int]$JobExecutionTimeout = 0,
[bool]$AbortOnError = $true,
[bool]$RemoveInstanceAfterCompletion = $false,
[PSCustomObject]$WindowsProperties,
[PSCustomObject]$MobileAndMacProperties,
[PSCustomObject]$UniversalProperties
)

$_connectVersion = Get-bConnectVersion
If($_connectVersion -ge "1.0") {
$_body = @{
# Id = $Id;
Name = $Name;
DisplayName = $DisplayName;
Type = $Type;
Steps = $Steps;
ParentId = $ParentId;
JobExecutionTimeout = $JobExecutionTimeout;
AbortOnError = $AbortOnError;
RemoveInstanceAfterCompletion = $RemoveInstanceAfterCompletion
}

If(![string]::IsNullOrEmpty($Id)) {
$_body += @{ Id = $Id }
}

If(![string]::IsNullOrEmpty($Category)) {
$_body += @{ Category = $Category }
}

If(![string]::IsNullOrEmpty($Description)) {
$_body += @{ Description = $Description }
}

If(![string]::IsNullOrEmpty($Comments)) {
$_body += @{ Comments = $Comments }
}

If(![string]::IsNullOrEmpty($IconId)) {
$_body += @{ IconId = $IconId }
}

<# If($JobExecutionTimeout.HasValue()) {
$_body += @{ JobExecutionTimeout = $JobExecutionTimeout }
}
If($AbortOnError.HasValue()) {
$_body += @{ AbortOnError = $AbortOnError }
}
If($RemoveInstanceAfterCompletion.HasValue()) {
$_body += @{ RemoveInstanceAfterCompletion = $RemoveInstanceAfterCompletion }
} #>

If($WindowsProperties) {
$_body += @{ WindowsProperties = $WindowsProperties }
}

If($MobileAndMacProperties) {
$_body += @{ MobileAndMacProperties = $MobileAndMacProperties }
}

If($UniversalProperties) {
$_body += @{ UniversalProperties = $UniversalProperties }
}

if($PSCmdlet.ShouldProcess($_body.Name, "Create new job.")){
return Invoke-bConnectPost -Controller "Jobs" -Version $_connectVersion -Data $_body
} else {
return $false
}
} else {
return $false
}
}
74 changes: 74 additions & 0 deletions bConnect/Public/New-bConnectJobIntervall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Function New-bConnectJobIntervall() {
<#
.Synopsis
Creates a new Intervall object for Jobs.
Empty or filled with given information.
.Parameter IntervalType
The type of the interval.
.Parameter Days
The list of valid days when specifying IntervalType “Weekdays”. Must be empty otherwise.
.Parameter Multiplicator
The hour/day/minute multiplicator. Can only be used when specifying IntervalTypes ‘EveryXDays’, ‘EveryXHours’ or ‘EveryXMinutes’
.Parameter StartTime
The time the job will be started. Hour(from 0 – 23): Minute(from 0 - 59).
.Parameter Repetitions
The number of job repetitions.
.Parameter RescheduleOnError
The job will be rescheduled, even if the previous execution wasn’t successful.
.Outputs
JobIntervall object (see bConnect documentation for more details)
#>

[OutputType("System.Management.Automations.PSObject")]
Param(
[Parameter(Mandatory=$true)][ValidateSet("Weekdays","Every1stOfMonth","Every15thOfMonth","EveryXHours","EveryXDays","EveryXMinutes",ignoreCase=$true)][string]$IntervalType="Weekdays",
[ValidateScript({
# This parameter must only be used with IntervalType=Weekdays
if($IntervalType -in "Weekdays"){
$_.count -gt 0
}
})]
[ValidateSet("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday",ignoreCase=$true)][string[]]$Days,
[ValidateScript({
# This parameter must only be used with IntervalType 'EveryXDays', 'EveryXHours' or 'EveryXMinutes'
if($IntervalType -in "EveryXHours","EveryXDays","EveryXMinutes"){
$_ -is [int]
}
})]
[int]$Multiplicator,
[Parameter(Mandatory=$true)][ValidateLength(5,5)][ValidatePattern("\d{2}[:]\d{2}")][string]$StartTime,
[int]$Repetitions = -1,
[bool]$RescheduleOnError = $true
)
$time_seprtr = ":"
$StartTime_ary = $StartTime.Split($time_seprtr)
$_new_StartTime = @{
Hour = [int]$StartTime_ary[0];
Minute = [int]$StartTime_ary[1];
}

$_new_JobIntervall = @{
StartTime = [PSCustomObject]$_new_StartTime;
Repetitions = $Repetitions;
RescheduleOnError = $RescheduleOnError;
}

if($IntervalType -in "EveryXHours","EveryXDays","EveryXMinutes"){
$FinalDays = @('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday')
}
elseif($IntervalType -in "Weekdays"){
$FinalDays = $Days
}
If(![string]::IsNullOrEmpty($IntervalType)) {
$_new_JobIntervall += @{ IntervalType = $IntervalType }
}
If($FinalDays) {
$_new_JobIntervall += @{ Days = $FinalDays }
}

If($Multiplicator) {
$_new_JobIntervall += @{ Multiplicator = $Multiplicator }
}

return $_new_JobIntervall
}
18 changes: 14 additions & 4 deletions bConnect/Public/New-bConnectJobStep.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Function New-bConnectJobStep() {
Set the sequence of the job step.
.Parameter JobStepType
Set the type of job step.
.Parameter IsBundle
Set to $true, if step contains a bundle.
.Parameter BundleName
Valid bundle name.
.Outputs
Jobstep object (see bConnect documentation for more details)
#>
Expand All @@ -16,12 +20,18 @@ Function New-bConnectJobStep() {
Param(
[Parameter(Mandatory=$true)][string]$ApplicationGuid,
[Parameter(Mandatory=$true)][int]$Sequence = 1,
[Parameter(Mandatory=$true)][ValidateSet("Deploy","SoftwareDeployUninstall",ignoreCase=$true)][string]$JobStepType
[Parameter(Mandatory=$true)][ValidateSet("Deploy","SoftwareDeployUninstall",ignoreCase=$true)][string]$JobStepType,
[Parameter(Mandatory=$false)][boolean]$IsBundle = $false,
[Parameter(Mandatory=$false)][string]$BundleName
)
if ($IsBundle -eq $false) {
$_AppTemp = Get-bConnectApplication -ApplicationGuid $ApplicationGuid
$_new_application_props = [PSCustomObject]@{Id = $ApplicationGuid; Name = $_AppTemp.Vendor + " " + $_AppTemp.Name + " " + $_AppTemp.Version;}
}else {
$_new_application_props = [PSCustomObject]@{Id = $ApplicationGuid; Name = $BundleName; Isbundle = $True}

$_AppTemp = Get-bConnectApplication -ApplicationGuid $ApplicationGuid
$_new_application_props = [PSCustomObject]@{Id = $ApplicationGuid; Name = $_AppTemp.Vendor + " " + $_AppTemp.Name + " " + $_AppTemp.Version;}
$_new_application_arr = @($_new_application_props)
}
$_new_application_arr = @($_new_application_props)
$_new_jobstep = [PSCustomObject]@{Applications = $_new_application_arr; Sequence = $Sequence; Type = $JobStepType;}
return $_new_jobstep
}
Loading

0 comments on commit 056cce8

Please sign in to comment.