-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 📝 🚸 UPDATE Examples Changing URLs used in examples to attempt to make it clearer that it is an Identity Portal URL which should be specified. * UPDATE Module Scope Variables Improves the way module scope variables are used throughout the module by utilising a single module scope object which holds property values which can be reused across functions, and also returned to the local scope for information purposes. Updates all functions and tests to reference new module scope session object. Updates `Get-IDSession` to return the module scope session object. Updates `GetWebSession()` method of `New-IDSession` to reference module scope session object, avoiding a breaking change for ISPSS authentication in `psPAS`. Adds new private helper functions: - `Get-ParentFunction` - `Get-SessionClone` * UPDATE Get-IDSession.md Update help in-line with command and module changes. * Update README.md * Update CHANGELOG.md * Update appveyor.yml
- Loading branch information
Showing
62 changed files
with
868 additions
and
136 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
|
||
## [unreleased] - 2023-10-08 | ||
## [unreleased] - ####-##-## | ||
|
||
### Added | ||
- N/A | ||
|
@@ -12,6 +12,50 @@ All notable changes to this project will be documented in this file. | |
### Fixed | ||
- N/A | ||
|
||
## [0.2] - 2024-02-13 | ||
|
||
Updates the `Get-IDSession` command, which can be used to return data from the module scope: | ||
|
||
```powershell | ||
PS C:\> Get-IDSession | ||
Name Value | ||
---- ----- | ||
tenant_url https://abc1234.id.cyberark.cloud | ||
User [email protected] | ||
TenantId ABC1234 | ||
SessionId 1337CbGbPunk3Sm1ff5ess510nD3tai75 | ||
WebSession Microsoft.PowerShell.Commands.WebRequestSession | ||
StartTime 12/02/2024 22:58:13 | ||
ElapsedTime 00:25:30 | ||
LastCommand System.Management.Automation.InvocationInfo | ||
LastCommandTime 12/02/2024 23:23:07 | ||
LastCommandResults {"success":true,"Result":{"SomeResult"}} | ||
``` | ||
|
||
Executing this command exports variables like the URL, Username & WebSession object for the authenticated session from IdentityCommand into your local scope, either for use in other requests outside of the module scope, or for informational purposes. | ||
|
||
Return data also includes details such as session start time, elapsed time, last command time, as well as data for the last invoked command and the results of the previous command useful for debugging & development purposes. | ||
|
||
### Added | ||
- Private Function `Get-ParentFunction` | ||
- Helper function to get command invocation data from different scopes | ||
- Private Function `Get-SessionClone` | ||
- Helper function to create unreferenced copy of IdentityCommand session hashtable object | ||
|
||
### Changed | ||
- `Get-IDSession` | ||
- Returns the module scoped `$ISPSSSession` variable (which includes the WebSession object), instead of just the WebSession object. | ||
- `New-IDSession` | ||
- Sets values in the script scope `$ISPSSSession` object instead of individual script scope variables. | ||
- `Close-IDSession` | ||
- Sets null values in the script scope `$ISPSSSession` object instead of removing individual script scope variables. | ||
- All other functions | ||
- Updated entire codebase to reference `$ISPSSSession` object instead of individual script scope variables. | ||
|
||
### Fixed | ||
- N/A | ||
|
||
## [0.1 - Update 3] - 2023-10-08 | ||
|
||
### Added | ||
|
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
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
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
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,58 @@ | ||
Function Get-ParentFunction { | ||
<# | ||
.SYNOPSIS | ||
Returns details of the calling function from a variable scope | ||
.DESCRIPTION | ||
Returns the FunctionName and the ParameterSetName which was used to invoke another function | ||
.PARAMETER Scope | ||
The Scope number from which to return the calling functions details. | ||
.EXAMPLE | ||
Function Test-Parent {Test-Child} | ||
Function Test-Child {Get-ParentFunction} | ||
$example = Test-Parent | ||
$example.FunctionName #Returns Test-Parent | ||
.EXAMPLE | ||
Function Test-Example { | ||
[CmdletBinding()] | ||
param([parameter(ParameterSetName = "ExampleParamSet")][string]$Name) | ||
Test-Parent | ||
} | ||
Function Test-Parent {Test-Child} | ||
Function Test-Child {Get-ParentFunction -Scope 3} | ||
$example = Test-Example -Name "test" | ||
$example.Function #Returns "Test-Example" | ||
$example.ParameterSetName #Returns "ExampleParamSet" | ||
.NOTES | ||
#> | ||
[CmdletBinding()] | ||
Param( | ||
# The scope number from which to retrieve the parent function name | ||
[Parameter( | ||
Mandatory = $false, | ||
ValueFromPipelineByPropertyName = $true | ||
)] | ||
[Int] | ||
$Scope = 2 | ||
) | ||
|
||
Process { | ||
|
||
#Get MyInvocation details from required scope | ||
$CommandData = (Get-Variable MyInvocation -Scope $Scope).Value | ||
[PSCustomObject]@{ | ||
CommandData = $CommandData | ||
FunctionName = $CommandData.MyCommand.Name | ||
ParameterSetName = (Get-Variable PSCmdlet -Scope $Scope -ErrorAction SilentlyContinue).Value.ParameterSetName | ||
} | ||
|
||
} | ||
|
||
} |
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,46 @@ | ||
function Get-SessionClone { | ||
<# | ||
.SYNOPSIS | ||
Deep copy a hashtable | ||
.DESCRIPTION | ||
Deep copy a hashtable or ordered dictionary, and return an ordered dictionary | ||
.PARAMETER InputObject | ||
A hashtable or OrderedDictionary to clone | ||
.EXAMPLE | ||
Get-SessionClone -InputObject $Hashtable | ||
Returns a new ordered hashtable, which is a deep copy of $Hashtable | ||
.OUTPUTS | ||
System.Collections.Specialized.OrderedDictionary | ||
#> | ||
[cmdletbinding()] | ||
[OutputType('System.Collections.Specialized.OrderedDictionary')] | ||
param( | ||
[parameter( | ||
Mandatory = $true, | ||
ValueFromPipeline = $true | ||
)] | ||
$InputObject | ||
) | ||
process { | ||
if (($InputObject -is [hashtable]) -or ($InputObject -is [System.Collections.Specialized.OrderedDictionary])) { | ||
$clone = [ordered]@{} | ||
foreach ($key in $InputObject.keys) { | ||
if ($null -ne $InputObject[$key]) { | ||
$clone[$key] = Get-SessionClone $InputObject[$key] | ||
} else { | ||
$clone[$key] = $null | ||
} | ||
} | ||
return $clone | ||
} else { | ||
|
||
return $InputObject | ||
|
||
} | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.