Skip to content

Commit 07a4bf1

Browse files
Merge pull request #11 from ActiveDirectoryManagementFramework/development
1.2.12
2 parents 8b61f4a + 32ee637 commit 07a4bf1

21 files changed

+450
-111
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
# ignore the settings folder and files for VSCode and PSS
3-
.vscode/*
43
*.psproj
54
*TempPoint*
65

.vscode/admf.code-snippets

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"Help_ServerCredential": {
3+
"scope": "powershell",
4+
"prefix": "helpsc",
5+
"body": [
6+
".PARAMETER Server",
7+
"\tThe server / domain to work with.",
8+
"",
9+
".PARAMETER Credential",
10+
"\tThe credentials to use for this operation."
11+
],
12+
"description": "[ADMF] Default help for server & credentials"
13+
}
14+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.formatOnSave": true
3+
}

ADMF.Core/ADMF.Core.psd1

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
@{
22
# Script module or binary module file associated with this manifest
3-
RootModule = 'ADMF.Core.psm1'
3+
RootModule = 'ADMF.Core.psm1'
44

55
# Version number of this module.
6-
ModuleVersion = '1.1.9'
6+
ModuleVersion = '1.2.12'
77

88
# ID used to uniquely identify this module
9-
GUID = '11e2d894-33d7-4020-a65e-f13c2f1893aa'
9+
GUID = '11e2d894-33d7-4020-a65e-f13c2f1893aa'
1010

1111
# Author of this module
12-
Author = 'Friedrich Weinmann'
12+
Author = 'Friedrich Weinmann'
1313

1414
# Company or vendor of this module
15-
CompanyName = 'Microsoft'
15+
CompanyName = 'Microsoft'
1616

1717
# Copyright statement for this module
18-
Copyright = 'Copyright (c) 2020 Friedrich Weinmann'
18+
Copyright = 'Copyright (c) 2020 Friedrich Weinmann'
1919

2020
# Description of the functionality provided by this module
21-
Description = 'Central Tooling used across available across all ADMF Project modules'
21+
Description = 'Central Tooling used across available across all ADMF Project modules'
2222

2323
# Minimum version of the Windows PowerShell engine required by this module
2424
PowerShellVersion = '5.0'
2525

2626
# Modules that must be imported into the global environment prior to importing
2727
# this module
28-
RequiredModules = @(
29-
@{ ModuleName = 'PSFramework'; ModuleVersion = '1.7.270' }
28+
RequiredModules = @(
29+
@{ ModuleName = 'PSFramework'; ModuleVersion = '1.13.416' }
3030

3131
# @{ ModuleName = 'ResolveString'; ModuleVersion = '1.0.0' }
3232
)
@@ -38,14 +38,18 @@
3838
# TypesToProcess = @('xml\ADMF.Core.Types.ps1xml')
3939

4040
# Format files (.ps1xml) to be loaded when importing this module
41-
FormatsToProcess = @('xml\ADMF.Core.Format.ps1xml')
41+
FormatsToProcess = @('xml\ADMF.Core.Format.ps1xml')
4242

4343
# Functions to export from this module
4444
FunctionsToExport = @(
4545
'Clear-AdcConfiguration'
4646
'Compare-AdcProperty'
4747
'Get-AdcExchangeVersion'
48+
'Get-AdcRemotingConfig'
4849
'New-AdcChange'
50+
'New-AdcPSSession'
51+
'Remove-AdcRemotingConfig'
52+
'Set-AdcRemotingConfig'
4953
'Sync-AdcObject'
5054
'Write-AdcChangeLog'
5155
)
@@ -66,19 +70,19 @@
6670
# FileList = @()
6771

6872
# Private data to pass to the module specified in ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
69-
PrivateData = @{
73+
PrivateData = @{
7074

7175
#Support for PowerShellGet galleries.
7276
PSData = @{
7377

7478
# Tags applied to this module. These help with module discovery in online galleries.
75-
Tags = @('activedirectory', 'configuration', 'admf', 'management')
79+
Tags = @('activedirectory', 'configuration', 'admf', 'management')
7680

7781
# A URL to the license for this module.
78-
LicenseUri = 'https://github.com/ActiveDirectoryManagementFramework/ADMF.Core/blob/master/LICENSE'
82+
LicenseUri = 'https://github.com/ActiveDirectoryManagementFramework/ADMF.Core/blob/master/LICENSE'
7983

8084
# A URL to the main website for this project.
81-
ProjectUri = 'https://admf.one'
85+
ProjectUri = 'https://admf.one'
8286

8387
# A URL to an icon representing this module.
8488
# IconUri = ''

ADMF.Core/changelog.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.2.12 (2025-10-31)
4+
5+
- New: Remoting config handling, to allow specifying the settings used during invocation.
6+
37
## 1.1.9 (2023-05-16)
48

59
- New: Command Write-AdcChangeLog - Writes a log entry for change objects.
@@ -23,6 +27,4 @@
2327

2428
## 1.0.0 (2020-09-10)
2529

26-
- New: Some Stuff
27-
- Upd: Moar Stuff
28-
- Fix: Much Stuff
30+
- Initial Release

ADMF.Core/en-us/strings.psd1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
'Get-LdapObject.SearchError' = 'Failed to execute ldap request.' #
55
'Get-LdapObject.Searchfilter' = 'Searching with filter: {0}' # $LdapFilter
66
'Get-LdapObject.SearchRoot' = 'Searching {0} in {1}' # $SearchScope, $searcher.SearchRoot.Path
7+
8+
'New-AdcPSSession.Connecting' = 'Connecting via PS Remoting to {0}' # $ComputerName
9+
'New-AdcPSSession.Connecting.Config' = 'Remoting Config used for {0} | Target: {1} | Options: {2} | SSH: {3} | Parameters: {4}' # $ComputerName, $config.Target, $config.HasOptions, $config.UseSSH, @($config.Parameters).Count
710

811
'Sync-AdcObject.ConnectError' = 'Failed to connect to {0}' # $errorObject.TargetObject
912

File renamed without changes.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
function Get-AdcRemotingConfig {
2+
<#
3+
.SYNOPSIS
4+
Retrieve the list of remoting configurations.
5+
6+
.DESCRIPTION
7+
Retrieve the list of remoting configurations.
8+
Remoting configurations apply to all remote connections via WinRM or - optionally - SSH.
9+
They can be defined for specific servers or all machines in a domain.
10+
11+
For more details, see Set-AdcRemotingConfig.
12+
13+
.PARAMETER Target
14+
The target the settings apply to.
15+
Defaults to: *
16+
17+
.EXAMPLE
18+
PS C:\> Get-AdcRemotingConfig
19+
20+
Retrieve the list of all remoting configurations.
21+
#>
22+
[CmdletBinding()]
23+
param (
24+
[PsfArgumentCompleter('ADMF.Core.RemotingTarget')]
25+
[string]
26+
$Target = '*'
27+
)
28+
process {
29+
($script:PSRemotingConfig.Values | Where-Object Target -Like $Target)
30+
}
31+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
function New-AdcPSSession {
2+
<#
3+
.SYNOPSIS
4+
Establish a new PowerShell remoting session to the target computer.
5+
6+
.DESCRIPTION
7+
Establish a new PowerShell remoting session to the target computer.
8+
Respects the configuration provided via Set-AdcRemotingConfig.
9+
10+
.PARAMETER ComputerName
11+
The computer to connect to.
12+
Specify thhe full FQDN.
13+
14+
.PARAMETER Credential
15+
The credentials to use for the connection.
16+
17+
.EXAMPLE
18+
PS C:\> New-AdcPSSession -ComputerName dc1.contoso.com
19+
20+
Establish a session to dc1.contoso.com using the settings for either dc1.contoso.com or contoso.com
21+
#>
22+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
23+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSPossibleIncorrectUsageOfAssignmentOperator", "")]
24+
[CmdletBinding()]
25+
param (
26+
[PSFComputer]
27+
$ComputerName,
28+
29+
[PSCredential]
30+
$Credential
31+
)
32+
process {
33+
$credParam = @{}
34+
if ($Credential) { $credParam.Credential = $Credential }
35+
36+
$target = "$ComputerName"
37+
$config = $null
38+
do {
39+
if ($config = $script:PSRemotingConfig[$target]) { break }
40+
$null, $target = $target -split "\.", 2
41+
}
42+
while ($target -match '\.')
43+
44+
if (-not $config) {
45+
Invoke-PSFProtectedCommand -ActionString 'New-AdcPSSession.Connecting' -ActionStringValues $ComputerName -ScriptBlock {
46+
New-PSSession @credParam -ComputerName $ComputerName -ErrorAction Stop
47+
} -Target $ComputerName -EnableException $true -PSCmdlet $PSCmdlet
48+
return
49+
}
50+
51+
$param = $config.Parameters | ConvertTo-PSFHashtable -ReferenceCommand New-PSSession
52+
if ($config.Options) { $param.SessionOption = $config.Options }
53+
if (-not $config.UseSSH) {
54+
$param.ComputerName = $ComputerName
55+
if ($Credential) { $param.Credential = $Credential }
56+
}
57+
else {
58+
$param.HostName = $ComputerName
59+
if ($config.Ssh.UserName) { $param.UserName = $config.Ssh.UserName }
60+
if ($config.Ssh.KeyFilePath) { $param.KeyFilePath = $config.Ssh.KeyFilePath }
61+
if ($config.Ssh.Subsystem) { $param.Subsystem = $config.Ssh.Subsystem }
62+
if ($config.Ssh.Transport) { $param.SSHTransport = $config.Ssh.Transport }
63+
if ($config.Ssh.Options.Count -gt 0) { $param.Options = $config.Ssh.Options }
64+
}
65+
66+
Write-PSFMessage -Level Debug -String 'New-AdcPSSession.Connecting.Config' -StringValues $ComputerName, $config.Target, $config.HasOptions, $config.UseSSH, $config.Parameters.Count -Target $ComputerName -Data @{ Config = $config }
67+
Invoke-PSFProtectedCommand -ActionString 'New-AdcPSSession.Connecting' -ActionStringValues $ComputerName -ScriptBlock {
68+
New-PSSession @param -ErrorAction Stop
69+
} -Target $ComputerName -EnableException $true -PSCmdlet $PSCmdlet
70+
}
71+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
function Remove-AdcRemotingConfig {
2+
<#
3+
.SYNOPSIS
4+
Removes a powershell remoting configuration.
5+
6+
.DESCRIPTION
7+
Removes a powershell remoting configuration.
8+
Use Set-AdcRemotingConfig to define how connections to a target are established when calling New-AdcPSSession.
9+
10+
.PARAMETER Target
11+
The target the configuration applies to.
12+
13+
.EXAMPLE
14+
PS C:\> Remove-AdcRemotingConfig -Target contoso.com
15+
16+
Removes a powershell remoting configuration targeting contoso.com.
17+
#>
18+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
19+
[CmdletBinding()]
20+
param (
21+
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
22+
[PsfArgumentCompleter('ADMF.Core.RemotingTarget')]
23+
[string]
24+
$Target
25+
)
26+
process {
27+
$null = $script:PSRemotingConfig.Remove($Target)
28+
}
29+
}

0 commit comments

Comments
 (0)