IdentityCommand.SIA.psm1
|
<# .SYNOPSIS .DESCRIPTION .EXAMPLE .INPUTS .OUTPUTS #> [CmdletBinding()] param( [bool]$DotSourceModule = $false ) #Load IdentityCommand's private helpers first: this module's own files call them, and the #argument completer registrations do so at import time. #Resolve a single IdentityCommand module: with more than one version loaded, Get-Module returns #an array and the Private folder of each would be loaded, last one winning. $Module = Get-Module -Name IdentityCommand | Sort-Object Version -Descending | Select-Object -First 1 if ($null -eq $Module) { throw 'The IdentityCommand module is not loaded. Import IdentityCommand and try again.' } Get-ChildItem (Join-Path $(Split-Path $Module.path) Private) | ForEach-Object { if ($DotSourceModule) { . $_.FullName } else { $ExecutionContext.InvokeCommand.InvokeScript( $false, ( [scriptblock]::Create( [io.file]::ReadAllText( $_.FullName, [Text.Encoding]::UTF8 ) ) ), $null, $null ) } } #Get function files Get-ChildItem $PSScriptRoot\ -Recurse -Include '*.ps1' -Exclude '*.ps1xml' | ForEach-Object { if ($DotSourceModule) { . $_.FullName } else { $ExecutionContext.InvokeCommand.InvokeScript( $false, ( [scriptblock]::Create( [io.file]::ReadAllText( $_.FullName, [Text.Encoding]::UTF8 ) ) ), $null, $null ) } } # Script scope session object for session data $ISPSSSession = [ordered]@{ tenant_url = $null User = $null TenantId = $null SessionId = $null WebSession = $null StartTime = $null ElapsedTime = $null LastCommand = $null LastCommandTime = $null LastCommandResults = $null LastError = $null LastErrorTime = $null } | Add-CustomType -Type IdCmd.Session New-Variable -Name ISPSSSession -Value $ISPSSSession -Scope Script -Force |