Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is what I am doing: </p> <pre><code>$sessionOptionsTimeout=180000 $sessionOptionsTimeout=180000 $so = New-PSSessionOption -OperationTimeout $sessionOptionsTimeout -IdleTimeout $sessionOptionsTimeout -OpenTimeout $sessionOptionsTimeout $connectionUri="http://$fqdn/powershell?serializationLevel=Full;ExchClientVer=14.3.91.1" $s = New-PSSession -ConnectionURI "$connectionUri" -ConfigurationName Microsoft.Exchange -SessionOption $so $s | Enter-PSSession </code></pre> <p>PS>get-mailboxserver</p> <pre><code>EncryptionRequired AutoDatabaseMountDial DatabaseCopyAutoActivationPo licy ------------------ --------------------- ---------------------------- e GoodAvailability Unrestricted e GoodAvailability Unrestricted </code></pre> <p>Now, converting above to .net (c#) should be easy...</p> <p>Essentially an exerpt from: "C:\Program Files\Microsoft\Exchange Server\V14\Bin\ConnectFunctions.ps1"</p> <p>Please refer to the following function:</p> <pre><code>function _NewExchangeRunspace([String]$fqdn, [System.Management.Automation.PSCredential] $credential=$null, [bool]$UseWIA=$true, [bool]$SuppressError=$false, $ClientApplication=$null, $AllowRedirection=$false) { $hostFQDN = _GetHostFqdn if (($fqdn -ne $null) -and ($hostFQDN -ne $null) -and ($hostFQDN.ToLower() -eq $fqdn.ToLower())) { $ServicesRunning = _CheckServicesStarted if ($ServicesRunning -eq $false) { return } } Write-Verbose ($ConnectFunctions_LocalizedStrings.res_0005 -f $fqdn) $so = New-PSSessionOption -OperationTimeout $sessionOptionsTimeout -IdleTimeout $sessionOptionsTimeout -OpenTimeout $sessionOptionsTimeout; $setupRegistryEntry = get-itemproperty HKLM:\SOFTWARE\Microsoft\ExchangeServer\v14\Setup -erroraction:silentlycontinue if ( $setupRegistryEntry -ne $null) { $clientVersion = "{0}.{1}.{2}.{3}" -f $setupRegistryEntry.MsiProductMajor, $setupRegistryEntry.MsiProductMinor, $setupRegistryEntry.MsiBuildMajor, $setupRegistryEntry.MsiBuildMinor $connectionUri = "http://$fqdn/powershell?serializationLevel=Full;ExchClientVer=$clientVersion" } else { $connectionUri = "http://$fqdn/powershell?serializationLevel=Full" } if ($ClientApplication -ne $null) { $connectionUri = $connectionUri + ";clientApplication=$ClientApplication" } write-host -fore Yellow ("connectionUri: " + $connectionUri) $contents = 'New-PSSession -ConnectionURI "$connectionUri" -ConfigurationName Microsoft.Exchange -SessionOption $so' if (-not $UseWIA) { $contents = $contents + ' -Authentication Kerberos -Credential $credential' } if ($SuppressError) { $contents = $contents + ' -erroraction silentlycontinue' } if ($AllowRedirection) { $contents = $contents + ' -AllowRedirection' } write-host -fore Yellow ("contents: " + $contents) write-host -fore Yellow ("join n contents: " + [string]::join("`n", $contents)) [ScriptBlock] $command = $executioncontext.InvokeCommand.NewScriptBlock([string]::join("`n", $contents)) $session=invoke-command -Scriptblock $command if (!$?) { # ERROR_ACCESS_DENIED = 5 # ERROR_LOGON_FAILURE = 1326 if (!(5 -eq $error[0].exception.errorcode) -and !(1326 -eq $error[0].exception.errorcode)) { #Write-Verbose ($ConnectFunctions_LocalizedStrings.res_0006 -f $fqdn) return } else { # no retries if we get 5 (access denied) or 1326 (logon failure) #$REVIEW$ connectedFqdn is not set. Is it okay? break connectScope } } $session } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload