Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Eventual time out of session (suspected)

$
0
0

Hi All

While running a script I do a connection to SkypeOnline so I can set some policies on potentially thousands of students in a tenant:

Import-Module SkypeOnlineConnector
    $SfBsession = New-CsOnlineSession -Credential $cred -Verbose -OverrideAdminDomain $MSDomain
    Import-PSSession -Session $SfBsession

After a while of running the loop successfully setting policies, it starts throwing this:

Grant-CsTeamsMeetingPolicy -PolicyName Tag:Education_Student -Identity  REDACTED@REDACTED.COM
Starting a command on the remote server failed with the following error message : The WinRM client cannot process the
request. The authentication mechanism requested by the client is not supported by the server or unencrypted traffic is
disabled in the service configuration. Verify the unencrypted traffic setting in the service configuration or specify
one of the authentication mechanisms supported by the server.  To use Kerberos, specify the computer name as the
remote destination. Also verify that the client computer and the destination computer are joined to a domain. To use
Basic, specify the computer name as the remote destination, specify Basic authentication and provide user name and
password. Possible authentication mechanisms reported by server: For more information, see the
about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OperationStopped: (admined2.online.lync.com:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : JobFailure
    + PSComputerName        : admined2.online.lync.com

The fact that if you kick it off again it runs for ages says to me it is timing out of the imported PS Session so how do I work around this?  Can I check for session expiry or can I just re-authenticate every 10 minutes, pull in another session and then continue the user list?

The loop is just this:

$ALLUsers = Get-MsolUser -All | ?{ $_.isLicensed -eq "TRUE" }
$ALLUsersApply = $ALLUsers | ?{ ($_.Licenses | ?{ $_.AccountSkuId -eq $LicenseSelection}).Length -gt 0} | select SignInName
foreach ($User in $ALLUsersApply) {
    write-host "Grant-CsTeamsMessagingPolicy -PolicyName $PolicySelection -Identity " $User.SignInName
    Grant-CsTeamsMessagingPolicy -PolicyName $PolicySelection -Identity $User.SignInName
    write-host "Grant-CsTeamsMeetingPolicy -PolicyName $PolicySelection -Identity " $User.SignInName
    Grant-CsTeamsMeetingPolicy -PolicyName $PolicySelection -Identity $User.SignInName
       }

Thanks.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>