spjeff / sppatchify

SharePoint Patchify - centralized tool to apply CU patch to entire farm from one console
MIT License
1 stars 0 forks source link

Creating remote session on servers fails #14

Closed zenaidura closed 5 years ago

zenaidura commented 6 years ago

capture

While doing the pre-flight check and make sure the remoting in to server is enabled..

function PreflightCheck() {
    try {
        Write-Host "Starting preflight check " -Fore Green
        # Start Jobs
        foreach ($server in $global:servers) {
            $addr = $server.Address
            if ($addr -ne $env:computername) {
                **$s = New-PSSession -ComputerName $env:computername -Credential $global:cred -Authentication CredSSP**
            }
        }

The line which is bold above needs to be modified to: **$s = New-PSSession -ComputerName $addr -Credential $global:cred -Authentication CredSSP**

I cannot believe that this was not caught while testing your script to connect to servers.

SparkDustJoe commented 5 years ago

This code appears to have been updated, does this issue still need to remain open?

function PreflightCheck() {
    try {
        Write-Host "Check Remote PowerShell " -Fore Green
        # Start Jobs
        foreach ($server in $global:servers) {
            $addr = $server.Address
            if ($addr -ne $env:computername) {
        # Dynamic open PSSession
                if ($remoteSessionPort -and $remoteSessionSSL) {
                    $remote = New-PSSession -ComputerName $addr -Credential $global:cred -Authentication Credssp -Port $remoteSessionPort -UseSSL
                }
                elseif ($remoteSessionPort) {
                    $remote = New-PSSession -ComputerName $addr -Credential $global:cred -Authentication Credssp -Port $remoteSessionPort
                }
                elseif ($remoteSessionSSL) {
                    $remote = New-PSSession -ComputerName $addr -Credential $global:cred -Authentication Credssp -UseSSL
                }
                else {
                    $remote = New-PSSession -ComputerName $addr -Credential $global:cred -Authentication Credssp
                }
            }
        }
        Write-Host "Succeess" -Fore Green
        return $true
    }
    catch {
        throw 'Not able to connect to one or more computers in the farm. Please make sure you have run run Enable-PSRemoting and Enable-WSManCredSSP -Role Server'
    }
}
spjeff commented 5 years ago

Resolved with above code. Issue closed.