Skip to content

Commit

Permalink
Release Commit of Major Changes (some changes in other commits)
Browse files Browse the repository at this point in the history
- Handled Auto add aliases on build #9 so added aliases are available to users.
- Implemented Add foghost name tab completion #8
- Added github actions for testing build and releasing versions
- Fixed issue with getting fog inventory in 1.6
- Implemented #16 for getting and setting fog global settings in fog 1.6
- Implemented #14 for getting the fog version
- Implemented #13 for invoking  wol task for a host
- Added basic pipeline functionality for foghost objects in all applicable functions.
- Made it possible to send multiple specified snapins in a single start-fogsnapin call
- Added tab completion of server specific host names and snapin names in various functions like get-foghost, start-fogsnapin. set-fogsnapins, remove-usbmac
- removed advanced function begin/end blocks where they weren't being used as such, kept things in process block
- implemented Add https option to fog server settings #15 by making it so you can put http://fogserver or https://fogserver or fogserver as the fogserver property in settings to implement that change with minimal issues with existing setting configs. Added an enable-FogApiHTTPS funcction as well as a disable to easily enable that.
- Implemented Add function for attempting to set windows machine to boot to pxe from within windows #17
  • Loading branch information
darksidemilk committed Aug 22, 2024
1 parent a3ea3bc commit 03d4daa
Show file tree
Hide file tree
Showing 67 changed files with 2,725 additions and 412 deletions.
33 changes: 18 additions & 15 deletions FogApi/FogApi.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: JJ Fullmer
#
# Generated on: 8/18/2024
# Generated on: 8/22/2024
#

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

# Version number of this module.
ModuleVersion = '2408.6.15'
ModuleVersion = '2408.9.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand All @@ -27,7 +27,7 @@ Author = 'JJ Fullmer'
CompanyName = 'FOG Project'

# Copyright statement for this module
Copyright = '(c) 2018 JJ Fullmer. All rights reserved.'
Copyright = '2018-2024'

# Description of the functionality provided by this module
Description = 'This module is used to easily run Fog API commands on your fogserver from a powershell console or script.
Expand Down Expand Up @@ -122,7 +122,8 @@ PowerShellVersion = '3.0'

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'Add-FogHostMac', 'Add-FogResultData', 'Approve-FogPendingMac',
'Deny-FogPendingMac', 'Find-FogObject', 'Get-FogActiveTasks',
'Deny-FogPendingMac', 'Disable-FogApiHTTPS', 'Dismount-WinEfi',
'Enable-FogApiHTTPS', 'Find-FogObject', 'Get-FogActiveTasks',
'Get-FogGroupAssociations', 'Get-FogGroupByName', 'Get-FogGroups',
'Get-FogHost', 'Get-FogHostAssociatedSnapins', 'Get-FogHostGroup',
'Get-FogHostMacs', 'Get-FogHostPendingMacs', 'Get-FogHosts',
Expand All @@ -131,14 +132,15 @@ FunctionsToExport = 'Add-FogHostMac', 'Add-FogResultData', 'Approve-FogPendingMa
'Get-FogSecsSinceEpoch', 'Get-FogServerSettings',
'Get-FogServerSettingsFile', 'Get-FogSetting', 'Get-FogSettings',
'Get-FogSnapinAssociations', 'Get-FogSnapins', 'Get-FogVersion',
'Get-LastImageTime', 'Install-FogService', 'Invoke-FogApi',
'New-FogHost', 'New-FogObject', 'Receive-FogImage', 'Remove-FogObject',
'Get-LastImageTime', 'Get-WinBcdPxeID', 'Get-WinEfiMountLetter',
'Install-FogService', 'Invoke-FogApi', 'Mount-WinEfi', 'New-FogHost',
'New-FogObject', 'Receive-FogImage', 'Remove-FogObject',
'Remove-UsbMac', 'Repair-FogSnapinAssociations',
'Reset-HostEncryption', 'Resolve-HostID', 'Send-FogImage',
'Send-FogWolTask', 'Set-FogInventory', 'Set-FogServerSettings',
'Set-FogServerSettingsFileSecurity', 'Set-FogSetting',
'Set-FogSnapins', 'Start-FogSnapin', 'Start-FogSnapins',
'Test-FogVerAbove1dot6', 'Update-FogObject'
'Set-FogSnapins', 'Set-WinToBootToPxe', 'Start-FogSnapin',
'Start-FogSnapins', 'Test-FogVerAbove1dot6', 'Update-FogObject'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
Expand All @@ -147,11 +149,12 @@ CmdletsToExport = @()
VariablesToExport = '*'

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = 'Remove-FogMac', 'Get-FogAssociatedSnapins', 'Get-FogHostSnapins',
'Get-FogHostSnapinAssociations', 'Get-FogGroup', 'Get-MacsForHost',
'Get-FogMacs', 'Add-FogHost', 'Add-FogObject', 'Save-FogImage',
'Invoke-FogImageCapture', 'Capture-FogImage', 'Pull-FogImage',
'Push-FogImage', 'Deploy-FogImage', 'Add-FogSnapins', 'Set-FogObject'
AliasesToExport = 'Add-FogHost', 'Add-FogObject', 'Add-FogSnapins', 'Capture-FogImage',
'Deploy-FogImage', 'Get-FogAssociatedSnapins', 'Get-FogGroup',
'Get-FogHostInventory', 'Get-FogHostSnapinAssociations',
'Get-FogHostSnapins', 'Get-FogMacs', 'Get-MacsForHost',
'Get-WinInventoryForFog', 'Invoke-FogImageCapture', 'Pull-FogImage',
'Push-FogImage', 'Remove-FogMac', 'Save-FogImage', 'Set-FogObject'

# DSC resources to export from this module
# DscResourcesToExport = @()
Expand Down Expand Up @@ -184,9 +187,9 @@ PrivateData = @{

# ReleaseNotes of this module
ReleaseNotes = '
# 2408.6.15
# 2408.9.1
Implemented geting and setting fog settings in fog 1.6. Setting names support tab complete of names'
resolves Auto add aliases on build #9 '

# Prerelease string of this module
# Prerelease = ''
Expand Down
2 changes: 1 addition & 1 deletion FogApi/Private/Export-FogImageDefinitions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function Export-FogImageDefinitions {


process {
if ($IsLinux -AND ($env:HOSTNAME -eq (Get-FogServerSettings).fogserver) -AND ([string]::IsNullOrEmpty($exportPath))) {
if ($IsLinux -AND ($env:HOSTNAME -match (Get-FogServerSettings).fogserver) -AND ([string]::IsNullOrEmpty($exportPath))) {
"This is linux, is the fogserver set in the api settings and no export path was given" | Out-Host;
"Assuming you want to create a /images/imageDefinitions folder for migrating your fog server images to another server" | out-host;
$exportPath = "/images/imageDefinitions"
Expand Down
19 changes: 18 additions & 1 deletion FogApi/Public/Add-FogHostMac.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,34 @@ function Add-FogHostMac {
#>

[CmdletBinding()]
[CmdletBinding(DefaultParameterSetName='byHost')]
param (
[parameter(ValueFromPipeline=$true,ParameterSetName='byHost')]
$fogHost,
[parameter(ParameterSetName='byId')]
$hostID,
[parameter(ParameterSetName='byHost')]
[parameter(ParameterSetName='byId')]
$macAddress,
[parameter(ParameterSetName='byHost')]
[parameter(ParameterSetName='byId')]
[switch]$primary,
[parameter(ParameterSetName='byHost')]
[parameter(ParameterSetName='byId')]
[switch]$ignoreMacOnClient,
[parameter(ParameterSetName='byHost')]
[parameter(ParameterSetName='byId')]
[switch]$ignoreMacForImaging,
[parameter(ParameterSetName='byHost')]
[parameter(ParameterSetName='byId')]
[switch]$forceUpdate
)

process {
if ($null -ne $_) {
$fogHost = $_;
$hostID = $fogHost.id;
}
$hostID = Resolve-HostID $hostID
if ($null -ne $hostID) {
if ($primary) {
Expand Down
4 changes: 4 additions & 0 deletions FogApi/Public/Approve-FogPendingMac.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ function Approve-FogPendingMac {

[CmdletBinding()]
param (
[parameter(ValueFromPipeline=$true)]
[object]$macObject
)

process {
if ($null -ne $_) {
$macObject = $_;
}
$macObject.pending = '0';
$data = ($macObject | ConvertTo-Json);
$result = Update-FogObject -type object -coreObject macaddressassociation -IDofObject $macObject.id -jsonData $data
Expand Down
5 changes: 4 additions & 1 deletion FogApi/Public/Deny-FogPendingMac.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ function Deny-FogPendingMac {
[CmdletBinding()]
[Alias('Remove-FogMac')]
param (
[Parameter(Mandatory=$true)]
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
$macObject
)

process {
if ($null -ne $_) {
$macObject = $_;
}
return Remove-FogObject -type object -coreObject macaddressassociation -IDofObject $macObject.id;
}

Expand Down
32 changes: 32 additions & 0 deletions FogApi/Public/Disable-FogApiHTTPS.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function Disable-FogApiHTTPS {
<#
.SYNOPSIS
Enforce http in the url used in all api calls
.DESCRIPTION
Prepends http to the fogserver property of fog server settings
#>
[CmdletBinding()]
param (

)

process {
$fogServer = (Get-FogServerSettings).fogserver;
if ($fogServer -notlike "http://*") {
if ($fogServer -like "https://*") {
$fogServer = $fogServer.replace("https://","http://")
} else {
$fogServer = "http://$fogserver"
}
$result = Set-FogServerSettings -fogServer $fogServer;
Write-Verbose "result is $($result | out-string)";
} else {
Write-Verbose "Http already enabled!"
# $result = $true;
}
return $fogserver;
}

}
26 changes: 26 additions & 0 deletions FogApi/Public/Dismount-WinEfi.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function Dismount-WinEfi {
<#
.SYNOPSIS
Dismounts the EFI system partition if it is currently mounted
.DESCRIPTION
Gets the efi partition mount letter and dismounts it with the mountvol tool
#>

[CmdletBinding()]
param ()

process {
$mountLtr=(Get-EfiMountLetter)
if ($null -eq $mountLtr) {
Write-Debug "EFI Partition is not mounted";
return $null
} else {
$mountVol = "C:\Windows\System32\mountvol.exe";
return Start-Process -FilePath $mountVol -Wait -NoNewWindow -ArgumentList @($mountLtr, '/D');
}
}

}

32 changes: 32 additions & 0 deletions FogApi/Public/Enable-FogApiHTTPS.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function Enable-FogApiHTTPS {
<#
.SYNOPSIS
Enforce https in the url used in all api calls
.DESCRIPTION
Prepends https to the fogserver property of fog server settings
#>
[CmdletBinding()]
param (

)

process {
$fogServer = (Get-FogServerSettings).fogserver;
if ($fogServer -notlike "https://*") {
if ($fogServer -like "http://*") {
$fogServer = $fogServer.replace("http://","https://")
} else {
$fogServer = "https://$fogserver"
}
$result = Set-FogServerSettings -fogServer $fogServer;
Write-Verbose "result is $($result | out-string)";
} else {
Write-Verbose "Https already enabled!"
# $result = $true;
}
return $fogserver;
}

}
6 changes: 3 additions & 3 deletions FogApi/Public/Get-FogHost.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ function Get-FogHost {
[ArgumentCompleter({
param($Command, $Parameter, $WordToComplete, $CommandAst, $FakeBoundParams)
if(Test-FogVerAbove1dot6) {
$r = (Get-FogHosts).Name
$r = Get-FogHosts;

if ($WordToComplete) {
$r.Where{ $_ -match "^$WordToComplete" }
$r.Name.Where{ $_ -match "^$WordToComplete" }
}
else {
$r
$r.Name
}
}
})]
Expand Down
7 changes: 7 additions & 0 deletions FogApi/Public/Get-FogHostAssociatedSnapins.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ function Get-FogHostAssociatedSnapins {
[CmdletBinding()]
[Alias('Get-FogAssociatedSnapins','Get-FogHostSnapins','Get-FogHostSnapinAssociations')]
param (
[parameter(ValueFromPipeline=$true,ParameterSetName='byHost')]
$fogHost = (Get-FogHost),
[parameter(ParameterSetName='byId')]
$hostId=((Get-FogHost).id)
)

process {
if ($null -ne $_) {
$fogHost = $_;
$hostId = $fogHost.id;
}
# $AllAssocs = (Invoke-FogApi -Method GET -uriPath snapinassociation).snapinassociations;
$AllAssocs = Get-FogSnapinAssociations
$snapins = New-Object System.Collections.Generic.List[object];
Expand Down
9 changes: 8 additions & 1 deletion FogApi/Public/Get-FogHostGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@ function Get-FogHostGroup {
Gets the fog group membership(s) of the fog host with the name computerName
#>
[CmdletBinding()]
[CmdletBinding(DefaultParameterSetName='byId')]
[Alias('Get-FogGroup')]
param (
[parameter(ValueFromPipeline=$true,ParameterSetName='byHost')]
$fogHost,
[parameter(ParameterSetName='byId')]
[int]$hostId
)

process {
if ($null -ne $_) {
$fogHost = $_;
$hostId = $fogHost.id;
}
if (!$hostId) {
$hostId = (Get-FogHost).id;
}
Expand Down
6 changes: 5 additions & 1 deletion FogApi/Public/Get-FogHostMacs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ function Get-FogHostMacs {
[CmdletBinding()]
[Alias('Get-MacsForHost')]
param (
[Parameter(ParameterSetName='byHostObject')]
[Parameter(ParameterSetName='byHostObject',ValueFromPipeline=$true)]
$hostObject = (Get-FogHost),
[Parameter(ParameterSetName='byHostID')]
$hostID
)

process {
if ($null -ne $_) {
$hostObject = $_;
$hostID = $hostObject.id;
}
$hostID = Resolve-HostID $hostID
if ($null -ne $hostID) {
$macs = Get-FogMacAddresses;
Expand Down
9 changes: 8 additions & 1 deletion FogApi/Public/Get-FogHostPendingMacs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ function Get-FogHostPendingMacs {
#>

[Alias('Get-PendingMacsForHost')]
[CmdletBinding()]
[CmdletBinding(DefaultParameterSetName='byId')]
param (
[parameter(ValueFromPipeline=$true,ParameterSetName='byHost')]
$fogHost,
[parameter(ParameterSetName='byId')]
$hostID
)


process {
if ($null -ne $_) {
$fogHost = $_;
$hostId = $fogHost.id;
}
$hostID = Resolve-HostID -hostID $hostid;
if ($null -ne $hostID) {
$hostMacs = Get-FogHostMacs -hostid $hostID;
Expand Down
5 changes: 5 additions & 0 deletions FogApi/Public/Get-FogInventory.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ function Get-FogInventory {
#>

[CmdletBinding()]
[Alias('Get-FogHostInventory','Get-WinInventoryForFog')]
param (
[Parameter(ValueFromPipeline=$true)]
$hostObj = (Get-FogHost),
[switch]$fromFog
)

process {
if ($null -ne $_) {
$hostObj = $_;
}
if ($IsLinux -OR $fromFog) {
if ($IsLinux) {
"Not yet implemented for getting the host inventory from linux inline, returning the hosts currently set inventory object" | out-host;
Expand Down
Loading

0 comments on commit 03d4daa

Please sign in to comment.