From d3b19f98ef37adbeaf9f4947f0a6a6de43c2b4f3 Mon Sep 17 00:00:00 2001 From: Shawn Melton <11204251+wsmelton@users.noreply.github.com> Date: Wed, 29 Sep 2021 14:44:50 -0500 Subject: [PATCH] module InternalEndpointUsed - converting to private binary command, Write-TssInternalNote --- .../private/WriteTssInternalNoteCmdlet.cs | 27 +++++++++++++++++++ .../rpc/Get-TssRpcAssociatedSecret.ps1 | 2 +- .../secrets/Get-TssSecretHeartbeatStatus.ps1 | 2 +- .../secrets/Get-TssSecretPasswordStatus.ps1 | 2 +- .../Invoke-TssSecretGeneratePassword.ps1 | 2 +- .../secrets/Set-TssSecretRpcPrivileged.ps1 | 2 +- .../secrets/Start-TssSecretChangePassword.ps1 | 2 +- .../Update-TssSecretRdpLauncherSetting.ps1 | 2 +- src/parts/InternalEndpointUsed.ps1 | 14 ---------- 9 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 src/Thycotic.SecretServer/cmdlets/private/WriteTssInternalNoteCmdlet.cs delete mode 100644 src/parts/InternalEndpointUsed.ps1 diff --git a/src/Thycotic.SecretServer/cmdlets/private/WriteTssInternalNoteCmdlet.cs b/src/Thycotic.SecretServer/cmdlets/private/WriteTssInternalNoteCmdlet.cs new file mode 100644 index 00000000..0cffc1d0 --- /dev/null +++ b/src/Thycotic.SecretServer/cmdlets/private/WriteTssInternalNoteCmdlet.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Management.Automation; +using System.Management.Automation.Runspaces; + +namespace Thycotic.SecretServer.Cmdlets +{ + /// + /// Outputs verbose statement for commands using internal endpoints + /// Outputs verbose statement for commands using internal endpoints + /// + [Cmdlet(VerbsCommunications.Write, "TssInternalNote")] + public class WriteInternalNote : PSCmdlet + { + /// + ///MyInvocation object from the calling command + /// + [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)] + public InvocationInfo Invocation {get; set;} + + protected override void ProcessRecord() + { + var cmdName = Invocation.MyCommand; + WriteVerbose("[" + cmdName + "] calling an internal endpoint."); + } + } +} \ No newline at end of file diff --git a/src/functions/rpc/Get-TssRpcAssociatedSecret.ps1 b/src/functions/rpc/Get-TssRpcAssociatedSecret.ps1 index ea801f23..1fa5bd45 100644 --- a/src/functions/rpc/Get-TssRpcAssociatedSecret.ps1 +++ b/src/functions/rpc/Get-TssRpcAssociatedSecret.ps1 @@ -41,7 +41,7 @@ function Get-TssRpcAssociatedSecret { } process { - . $InternalEndpointUsed $PSCmdlet.MyInvocation + Write-TssInternalNote $PSCmdlet.MyInvocation Get-TssInvocation $PSCmdlet.MyInvocation if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { Compare-TssVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation diff --git a/src/functions/secrets/Get-TssSecretHeartbeatStatus.ps1 b/src/functions/secrets/Get-TssSecretHeartbeatStatus.ps1 index 132039d2..76b6a085 100644 --- a/src/functions/secrets/Get-TssSecretHeartbeatStatus.ps1 +++ b/src/functions/secrets/Get-TssSecretHeartbeatStatus.ps1 @@ -40,7 +40,7 @@ function Get-TssSecretHeartbeatStatus { $invokeParams = . $GetInvokeApiParams $TssSession } process { - . $InternalEndpointUsed $PSCmdlet.MyInvocation + Write-TssInternalNote $PSCmdlet.MyInvocation Get-TssInvocation $PSCmdlet.MyInvocation if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { Compare-TssVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation diff --git a/src/functions/secrets/Get-TssSecretPasswordStatus.ps1 b/src/functions/secrets/Get-TssSecretPasswordStatus.ps1 index 5265a1ee..f5505a9f 100644 --- a/src/functions/secrets/Get-TssSecretPasswordStatus.ps1 +++ b/src/functions/secrets/Get-TssSecretPasswordStatus.ps1 @@ -41,7 +41,7 @@ function Get-TssSecretPasswordStatus { } process { - . $InternalEndpointUsed $PSCmdlet.MyInvocation + Write-TssInternalNote $PSCmdlet.MyInvocation Get-TssInvocation $PSCmdlet.MyInvocation if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { Compare-TssVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation diff --git a/src/functions/secrets/Invoke-TssSecretGeneratePassword.ps1 b/src/functions/secrets/Invoke-TssSecretGeneratePassword.ps1 index 083fac76..a05fd074 100644 --- a/src/functions/secrets/Invoke-TssSecretGeneratePassword.ps1 +++ b/src/functions/secrets/Invoke-TssSecretGeneratePassword.ps1 @@ -47,7 +47,7 @@ function Invoke-TssSecretGeneratePassword { $invokeValidateParams = . $GetInvokeApiParams $TssSession } process { - . $InternalEndpointUsed $PSCmdlet.MyInvocation + Write-TssInternalNote $PSCmdlet.MyInvocation Get-TssInvocation $PSCmdlet.MyInvocation if ($PSBoundParameters.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { Compare-TssVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation diff --git a/src/functions/secrets/Set-TssSecretRpcPrivileged.ps1 b/src/functions/secrets/Set-TssSecretRpcPrivileged.ps1 index 49ede48c..acb8532a 100644 --- a/src/functions/secrets/Set-TssSecretRpcPrivileged.ps1 +++ b/src/functions/secrets/Set-TssSecretRpcPrivileged.ps1 @@ -56,7 +56,7 @@ function Set-TssSecretRpcPrivileged { $invokeParams = . $GetInvokeApiParams $TssSession } process { - . $InternalEndpointUsed $PSCmdlet.MyInvocation + Write-TssInternalNote $PSCmdlet.MyInvocation Get-TssInvocation $PSCmdlet.MyInvocation if ($setParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { Compare-TssVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation diff --git a/src/functions/secrets/Start-TssSecretChangePassword.ps1 b/src/functions/secrets/Start-TssSecretChangePassword.ps1 index ad1b358f..ca0bdc29 100644 --- a/src/functions/secrets/Start-TssSecretChangePassword.ps1 +++ b/src/functions/secrets/Start-TssSecretChangePassword.ps1 @@ -50,7 +50,7 @@ function Start-TssSecretChangePassword { } process { - . $InternalEndpointUsed $PSCmdlet.MyInvocation + Write-TssInternalNote $PSCmdlet.MyInvocation Get-TssInvocation $PSCmdlet.MyInvocation if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { Compare-TssVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation diff --git a/src/functions/secrets/Update-TssSecretRdpLauncherSetting.ps1 b/src/functions/secrets/Update-TssSecretRdpLauncherSetting.ps1 index f07408ea..cb484c3c 100644 --- a/src/functions/secrets/Update-TssSecretRdpLauncherSetting.ps1 +++ b/src/functions/secrets/Update-TssSecretRdpLauncherSetting.ps1 @@ -75,7 +75,7 @@ function Update-TssSecretRdpLauncherSetting { $invokeParams = . $GetInvokeApiParams $TssSession } process { - . $InternalEndpointUsed $PSCmdlet.MyInvocation + Write-TssInternalNote $PSCmdlet.MyInvocation Get-TssInvocation $PSCmdlet.MyInvocation if ($updateLaunchParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { Compare-TssVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation diff --git a/src/parts/InternalEndpointUsed.ps1 b/src/parts/InternalEndpointUsed.ps1 deleted file mode 100644 index d8812cee..00000000 --- a/src/parts/InternalEndpointUsed.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -<# - .Synopsis - To centralize the code around verbose/warning output when an internal endpoint is utilized -#> -[cmdletbinding()] -param ( - [Parameter(Mandatory,Position = 2)] - [System.Management.Automation.InvocationInfo] - $Invocation -) -process { - $source = $Invocation.MyCommand - Write-Verbose "[Important]: $source utilizes an internal endpoint that is not formally supported by Thycotic" -} \ No newline at end of file