mirror of
https://github.com/Grace-Solutions/Invoke-OpenSSHConfiguration.git
synced 2026-07-26 11:38:14 +00:00
Fix TimeSpan error and firewall profile enumeration
- Added ExecutionTimeout and ExecutionTimeoutInterval to ssh-keygen calls (2 min timeout)
- Added ExecutionTimeout and ExecutionTimeoutInterval to sshd -t validation (30 sec timeout)
- Fixed firewall profile enumeration: use string array instead of unavailable type
- Profiles now use simple array: @('Domain', 'Private', 'Public')
This commit is contained in:
@@ -241,53 +241,64 @@ Function Start-ProcessWithOutput
|
||||
[System.TimeSpan]$InputObject
|
||||
)
|
||||
|
||||
$InputObjectMessageBuilder = New-Object -TypeName 'System.Text.StringBuilder'
|
||||
|
||||
$InputObjectProperties = $InputObject | Select-Object -Property @('Days', 'Hours', 'Minutes', 'Seconds', 'Milliseconds')
|
||||
|
||||
$InputObjectPropertyNameList = New-Object -TypeName 'System.Collections.Generic.List[System.String]'
|
||||
|
||||
($InputObjectProperties.PSObject.Properties | Where-Object {($_.Value -gt 0)}).Name | ForEach-Object {($InputObjectPropertyNameList.Add($_))}
|
||||
|
||||
$InputObjectPropertyNameListUpperBound = $InputObjectPropertyNameList.ToArray().GetUpperBound(0)
|
||||
|
||||
For ($InputObjectPropertyNameListIndex = 0; $InputObjectPropertyNameListIndex -lt $InputObjectPropertyNameList.Count; $InputObjectPropertyNameListIndex++)
|
||||
{
|
||||
$InputObjectPropertyName = $InputObjectPropertyNameList[$InputObjectPropertyNameListIndex]
|
||||
|
||||
$InputObjectPropertyValue = $InputObject.$($InputObjectPropertyName)
|
||||
|
||||
Switch ($True)
|
||||
{
|
||||
{($InputObjectPropertyNameList.Count -gt 1) -and ($InputObjectPropertyNameListIndex -eq $InputObjectPropertyNameListUpperBound)}
|
||||
{
|
||||
$Null = $InputObjectMessageBuilder.Append('and ')
|
||||
}
|
||||
|
||||
{($InputObjectPropertyValue -eq 1)}
|
||||
{
|
||||
$Null = $InputObjectMessageBuilder.Append("$($InputObjectPropertyValue) $($InputObjectPropertyName.TrimEnd('s').ToLower())")
|
||||
}
|
||||
|
||||
{($InputObjectPropertyValue -gt 1)}
|
||||
{
|
||||
$Null = $InputObjectMessageBuilder.Append("$($InputObjectPropertyValue) $($InputObjectPropertyName.ToLower())")
|
||||
}
|
||||
|
||||
{($InputObjectPropertyNameList.Count -gt 1) -and ($InputObjectPropertyNameListIndex -ne $InputObjectPropertyNameListUpperBound)}
|
||||
{
|
||||
$Null = $InputObjectMessageBuilder.Append(', ')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$OutputObject = $InputObjectMessageBuilder.ToString()
|
||||
|
||||
Switch ($InputObjectMessageBuilder.Length -gt 0)
|
||||
Switch ($Null -ine $InputObject)
|
||||
{
|
||||
{($_ -eq $True)}
|
||||
{
|
||||
{
|
||||
$InputObjectMessageBuilder = New-Object -TypeName 'System.Text.StringBuilder'
|
||||
|
||||
$InputObjectProperties = $InputObject | Select-Object -Property @('Days', 'Hours', 'Minutes', 'Seconds', 'Milliseconds')
|
||||
|
||||
$InputObjectPropertyNameList = New-Object -TypeName 'System.Collections.Generic.List[System.String]'
|
||||
|
||||
($InputObjectProperties.PSObject.Properties | Where-Object {($_.Value -gt 0)}).Name | ForEach-Object {($InputObjectPropertyNameList.Add($_))}
|
||||
|
||||
$InputObjectPropertyNameListUpperBound = $InputObjectPropertyNameList.ToArray().GetUpperBound(0)
|
||||
|
||||
For ($InputObjectPropertyNameListIndex = 0; $InputObjectPropertyNameListIndex -lt $InputObjectPropertyNameList.Count; $InputObjectPropertyNameListIndex++)
|
||||
{
|
||||
$InputObjectPropertyName = $InputObjectPropertyNameList[$InputObjectPropertyNameListIndex]
|
||||
|
||||
$InputObjectPropertyValue = $InputObject.$($InputObjectPropertyName)
|
||||
|
||||
Switch ($True)
|
||||
{
|
||||
{($InputObjectPropertyNameList.Count -gt 1) -and ($InputObjectPropertyNameListIndex -eq $InputObjectPropertyNameListUpperBound)}
|
||||
{
|
||||
$Null = $InputObjectMessageBuilder.Append('and ')
|
||||
}
|
||||
|
||||
{($InputObjectPropertyValue -eq 1)}
|
||||
{
|
||||
$Null = $InputObjectMessageBuilder.Append("$($InputObjectPropertyValue) $($InputObjectPropertyName.TrimEnd('s').ToLower())")
|
||||
}
|
||||
|
||||
{($InputObjectPropertyValue -gt 1)}
|
||||
{
|
||||
$Null = $InputObjectMessageBuilder.Append("$($InputObjectPropertyValue) $($InputObjectPropertyName.ToLower())")
|
||||
}
|
||||
|
||||
{($InputObjectPropertyNameList.Count -gt 1) -and ($InputObjectPropertyNameListIndex -ne $InputObjectPropertyNameListUpperBound)}
|
||||
{
|
||||
$Null = $InputObjectMessageBuilder.Append(', ')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$OutputObject = $InputObjectMessageBuilder.ToString()
|
||||
|
||||
Switch ($InputObjectMessageBuilder.Length -gt 0)
|
||||
{
|
||||
{($_ -eq $True)}
|
||||
{
|
||||
$OutputObject = $InputObjectMessageBuilder.ToString()
|
||||
}
|
||||
|
||||
Default
|
||||
{
|
||||
$OutputObject = 'N/A'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Default
|
||||
@@ -295,8 +306,8 @@ Function Start-ProcessWithOutput
|
||||
$OutputObject = 'N/A'
|
||||
}
|
||||
}
|
||||
|
||||
Write-Output -InputObject ($OutputObject)
|
||||
|
||||
Write-Output -InputObject ($OutputObject)
|
||||
}
|
||||
|
||||
[ScriptBlock]$WriteStandardOutputStream = {
|
||||
|
||||
Reference in New Issue
Block a user