Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PSMultiPass/PSMultiPass.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PSMultiPass.psm1'

# Version number of this module.
ModuleVersion = '0.0.5'
ModuleVersion = '0.0.6'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
18 changes: 4 additions & 14 deletions PSMultiPass/functions/public/Invoke-MultiSessionCommand.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ function Invoke-MultiSessionCommand {
[System.Management.Automation.Remoting.PSSessionOption]
$SessionOption = $null,

[string[]]
$SessionName,

[int]
$SessionThrottleLimit = 32,

Expand All @@ -37,25 +34,18 @@ function Invoke-MultiSessionCommand {
$sessionParameters = @{
ComputerName = $ComputerName
Credential = $Credential
ThrottleLimit = $SessionThrottleLimit
SessionThrottleLimit = $SessionThrottleLimit
ErrorVariable = 'sessionError'
ErrorAction = 'SilentlyContinue'
}

if ($SessionOption) { $sessionParameters.Add('SessionOption', $SessionOption)}
if ($SessionName) { $sessionParameters.Add('Name', $SessionName)}

Write-Verbose "Creating sessions for the following computer names: $($ComputerName -join ', ') with throttle limit of $SessionThrottleLimit..."
$sessions = New-PSSession @sessionParameters

$connectionErrorInfo = $sessionError.TargetObject

if ($sessionError) {
Write-Warning "One or more sessions were not created successfully. Please check the ConnectionErrorInfo property."
}
$sessionResults = Invoke-PSSessionProxy @sessionParameters

$sessions = $sessionResults.Sessions
$sessionCount = $sessions.Count
Write-Verbose "Successfully created $sessionCount sessions."
$connectionErrorInfo = $sessionResults.ConnectionErrorInfo

}

Expand Down
60 changes: 60 additions & 0 deletions PSMultiPass/functions/public/Invoke-PSSessionProxy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

### Possibly change functionality to include just creating sessions using error checking on
### failed sessions and returning sessions as an output.


function Invoke-PSSessionProxy {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true)]
[string[]]
$ComputerName,

[Parameter(Mandatory = $true)]
[pscredential]
$Credential,

[System.Management.Automation.Remoting.PSSessionOption]
$SessionOption = $null,

[int]
$SessionThrottleLimit = 32

)

Begin {
$sessionParameters = @{
ComputerName = $ComputerName
Credential = $Credential
ThrottleLimit = $SessionThrottleLimit
ErrorVariable = 'sessionError'
ErrorAction = 'SilentlyContinue'
}

if ($SessionOption) { $sessionParameters.Add('SessionOption', $SessionOption)}

Write-Verbose "Creating sessions for the following computer names: $($ComputerName -join ', ') with throttle limit of $SessionThrottleLimit..."
$sessions = New-PSSession @sessionParameters

$connectionErrorInfo = $sessionError.TargetObject

if ($sessionError) {
Write-Warning "One or more sessions were not created successfully. Please check the ConnectionErrorInfo property."
}

$sessionCount = $sessions.Count
Write-Verbose "Successfully created $sessionCount sessions."

}

End {

$output = [PSCustomObject]@{
Sessions = $sessions
ConnectionErrorInfo = $connectionErrorInfo
}

Write-Output $output

}
}
Loading