-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get-TssDistributedEngineServerCapabilities - new command to pull the …
…OS details of a DE
- Loading branch information
Showing
6 changed files
with
278 additions
and
0 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
docs/commands/distributed-engines/Get-TssDistributedEngineServerCapabilities.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Get-TssDistributedEngineServerCapabilities | ||
|
||
## SYNOPSIS | ||
Get the server capabilities for a Distributed Engine | ||
|
||
## SYNTAX | ||
|
||
``` | ||
Get-TssDistributedEngineServerCapabilities [-TssSession] <Session> -Id <Int32[]> [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
Get the server capabilities for a Distributed Engine | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
``` | ||
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred | ||
Get-TssDistributedEngineServerCapabilities -TssSession $session -Id 5 | ||
``` | ||
|
||
Return server capabilities for Distributed Engine Id 5 | ||
|
||
## PARAMETERS | ||
|
||
### -TssSession | ||
TssSession object created by New-TssSession for authentication | ||
|
||
```yaml | ||
Type: Session | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: True | ||
Position: 1 | ||
Default value: None | ||
Accept pipeline input: True (ByValue) | ||
Accept wildcard characters: False | ||
``` | ||
### -Id | ||
Short description for parameter | ||
```yaml | ||
Type: Int32[] | ||
Parameter Sets: (All) | ||
Aliases: EngineId | ||
|
||
Required: True | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: True (ByPropertyName) | ||
Accept wildcard characters: False | ||
``` | ||
### CommonParameters | ||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). | ||
## INPUTS | ||
## OUTPUTS | ||
### Thycotic.PowerShell.DistributedEngine.ServerCapabilities | ||
## NOTES | ||
Requires TssSession object returned by New-TssSession | ||
## RELATED LINKS | ||
[https://thycotic-ps.github.io/thycotic.secretserver/commands/distributed-engines/Get-TssDistributedEngineServerCapabilities](https://thycotic-ps.github.io/thycotic.secretserver/commands/distributed-engines/Get-TssDistributedEngineServerCapabilities) | ||
[https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/distributed-engines/Get-TssDistributedEngineServerCapabilities.ps1](https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/distributed-engines/Get-TssDistributedEngineServerCapabilities.ps1) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Thycotic.SecretServer/classes/distributed-engines/ServerCapabilities.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using System.Management.Automation; | ||
using System.Management.Automation.Runspaces; | ||
|
||
namespace Thycotic.PowerShell.DistributedEngines | ||
{ | ||
public class ServerCapabilities | ||
{ | ||
public int DotNetRelease { get; set; } | ||
public string DotNetVersion { get; set; } | ||
public string OperatingSystemVersion { get; set; } | ||
public string OperatingSystemPlatform { get; set; } | ||
public string OperatingSystemServicePack { get; set; } | ||
public string Architecture { get; set; } | ||
public string InstallationPath { get; set; } | ||
public string ComputerName { get; set; } | ||
public int ProcessorCount { get; set; } | ||
public string PowerShellVersion { get; set; } | ||
public string SystemDirectory { get; set; } | ||
public string ServiceAccountName { get; set; } | ||
public bool ServiceAccountCanRestartService { get; set; } | ||
public DateTime? LastModifiedDate { get; set; } | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/functions/distributed-engines/Get-TssDistributedEngineServerCapabilities.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
function Get-TssDistributedEngineServerCapabilities { | ||
<# | ||
.SYNOPSIS | ||
Get the server capabilities for a Distributed Engine | ||
.DESCRIPTION | ||
Get the server capabilities for a Distributed Engine | ||
.EXAMPLE | ||
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred | ||
Get-TssDistributedEngineServerCapabilities -TssSession $session -Id 5 | ||
Return server capabilities for Distributed Engine Id 5 | ||
.LINK | ||
https://thycotic-ps.github.io/thycotic.secretserver/commands/distributed-engines/Get-TssDistributedEngineServerCapabilities | ||
.LINK | ||
https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/distributed-engines/Get-TssDistributedEngineServerCapabilities.ps1 | ||
.NOTES | ||
Requires TssSession object returned by New-TssSession | ||
#> | ||
[CmdletBinding()] | ||
[OutputType('Thycotic.PowerShell.DistributedEngine.ServerCapabilities')] | ||
param ( | ||
# TssSession object created by New-TssSession for authentication | ||
[Parameter(Mandatory,ValueFromPipeline,Position = 0)] | ||
[Thycotic.PowerShell.Authentication.Session] | ||
$TssSession, | ||
|
||
# Short description for parameter | ||
[Parameter(Mandatory,ValueFromPipelineByPropertyName)] | ||
[Alias("EngineId")] | ||
[int[]] | ||
$Id | ||
) | ||
begin { | ||
$tssParams = $PSBoundParameters | ||
$invokeParams = . $GetInvokeApiParams $TssSession | ||
} | ||
process { | ||
Get-TssInvocation $PSCmdlet.MyInvocation | ||
if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { | ||
Compare-TssVersion $TssSession '10.9.000064' $PSCmdlet.MyInvocation | ||
foreach ($engine in $Id) { | ||
$uri = $TssSession.ApiUrl, 'distributed-engine', $engine, 'server-capabilities' -join '/' | ||
$invokeParams.Uri = $uri | ||
$invokeParams.Method = 'GET' | ||
|
||
Write-Verbose "Performing the operation $($invokeParams.Method) $($invokeParams.Uri)" | ||
try { | ||
$apiResponse = Invoke-TssApi @invokeParams | ||
$restResponse = . $ProcessResponse $apiResponse | ||
} catch { | ||
Write-Warning "Issue getting server capabilities for Distributed Engine [$engine]" | ||
$err = $_ | ||
. $ErrorHandling $err | ||
} | ||
|
||
if ($restResponse) { | ||
. $GetServerCapabilities $restResponse | ||
} | ||
} | ||
} else { | ||
Write-Warning "No valid session found" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
param( | ||
[Parameter(Position = 0)] | ||
[PSCustomObject]$Object | ||
) | ||
|
||
<# determine .NET Version #> | ||
$dotnetversionNum = $Object.Where({ $_.Name -eq 'DotNetVersion' }).Value | ||
$dotnetversionString = switch ($dotnetversionNum) { | ||
378389 { '.Net Framework 4.5' } | ||
{ $_ -in 378675,378758 } { '.Net Framework 4.5.1' } | ||
379893 { '.Net Framework 4.5.2' } | ||
{ $_ -in 393295,393297 } { '.Net Framework 4.6' } | ||
{ $_ -in 394254,394271 } { '.Net Framework 4.6.1' } | ||
{ $_ -in 394802,394806 } { '.Net Framework 4.6.2' } | ||
{ $_ -in 460798,460805 } { '.Net Framework 4.7' } | ||
{ $_ -in 461308,461310 } { '.Net Framework 4.7.1' } | ||
{ $_ -in 461808,461814 } { '.Net Framework 4.7.2' } | ||
{ $_ -in 528040,528372,528049 } { '.Net Framework 4.8' } | ||
default { 'Unknown' } | ||
} | ||
|
||
[Thycotic.PowerShell.DistributedEngines.ServerCapabilities]@{ | ||
DotNetRelease = $Object.Where({ $_.Name -eq 'DotNetVersion' }).value | ||
DotNetVersion = $dotnetversionString | ||
OperatingSystemVersion = $Object.Where({ $_.Name -eq 'OperatingSystemVersion' }).value | ||
OperatingSystemPlatform = $Object.Where({ $_.Name -eq 'OperationSystemPlatform' }).value | ||
OperatingSystemServicePack = $Object.Where({ $_.Name -eq 'OperatingSystemServicePack' }).value | ||
Architecture = $Object.Where({ $_.Name -eq 'Architecture' }).value | ||
InstallationPath = $Object.Where({ $_.Name -eq 'Directory' }).value | ||
ComputerName = $Object.Where({ $_.Name -eq 'ComputerName' }).value | ||
ProcessorCount = $Object.Where({ $_.Name -eq 'NumberOfProcessors' }).value | ||
PowerShellVersion = $Object.Where({ $_.Name -eq 'PowerShell3Version' }).value | ||
SystemDirectory = $Object.Where({ $_.Name -eq 'SystemDirectory' }).value | ||
ServiceAccountName = $Object.Where({ $_.Name -eq 'EngineServiceAccount_Name' }).value | ||
ServiceAccountCanRestartService = $Object.Where({ $_.Name -eq 'EngineServiceAccount_HasRightToStartService' }).value | ||
LastModifiedDate = $Object[0].lastModifiedDate | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/distributed-engines/Get-TssDistributedEngineServerCapabilities.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
BeforeDiscovery { | ||
$commandName = Split-Path ($PSCommandPath.Replace('.Tests.ps1','')) -Leaf | ||
} | ||
Describe "$commandName verify parameters" { | ||
BeforeDiscovery { | ||
[object[]]$knownParameters = 'TssSession', 'Id' | ||
[object[]]$currentParams = ([Management.Automation.CommandMetaData]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName,'Function')).Parameters.Keys | ||
[object[]]$commandDetails = [System.Management.Automation.CommandInfo]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName,'Function') | ||
$unknownParameters = Compare-Object -ReferenceObject $knownParameters -DifferenceObject $currentParams -PassThru | ||
} | ||
Context "Verify parameters" -Foreach @{currentParams = $currentParams } { | ||
It "$commandName should contain <_> parameter" -TestCases $knownParameters { | ||
$_ -in $currentParams | Should -Be $true | ||
} | ||
It "$commandName should not contain parameter: <_>" -TestCases $unknownParameters { | ||
$_ | Should -BeNullOrEmpty | ||
} | ||
} | ||
Context "Command specific details" { | ||
It "$commandName should set OutputType to Thycotic.PowerShell.DistributedEngines.ServerCapabilities" -TestCases $commandDetails { | ||
$_.OutputType.Name | Should -Be 'Thycotic.PowerShell.DistributedEngines.ServerCapabilities' | ||
} | ||
} | ||
} |