Wednesday, August 16, 2017

Remove-O365PSSession.ps1

Today's script does some basic house cleaning when closing Office 365 Sessions.

As script is simple now code break down unless I receive requests.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<#
.SYNOPSIS
    Remove open O365 PSSessions
.DESCRIPTION
    Remove open O365 PSSessions
.EXAMPLE
    Remove-O365PSSession.ps1
.NOTES
    Created by Chris Lee
    Date April 20, 2017
.LINK 
    GitHub: https://github.com/clee1107/Public/blob/master/O365/Remove-O365PSSession.ps1
    Blogger:http://www.myitresourcebook.com/2017/08/httpsgithubcomclee1107publicblobmastero.html
#>

#################################
## DO NOT EDIT BELOW THIS LINE ##
#################################

##Close open All O365 product Sessions
Write-Verbose -Message "Removing all PSSessions"
Get-PSSession | Remove-PSSession
Write-Verbose -Message "Disconnecting SharePoint Online"
$ExitPowershell = Read-Host -Prompt "Disconnect from O365 (Will close current Powershell Window) [Y]/N"
If ($ExitPowershell -eq "Y" -OR $ExitPowershell -eq $null -OR $ExitPowershell -eq "")
    {
        stop-process -Id $PID
    }


Full script can be accessed from following link:
https://github.com/clee1107/Public/blob/master/O365/Remove-O365PSSession.ps1
Further reference links for PowerShell cmdlets used can be found on following post:

Code Snippets created via: http://hilite.me/

2 comments:

  1. The Longines, replica watches saleLa Grande Classique series features a stainless steel 24mm case, with a fixed bezel, replica Longines Conquest watchesa blue dial and a scratch resistant sapphire crystal.This beautiful wristwatch, powered by a Longines Calibre 209, Swiss quartz movement, supporting: hour, minute functions.This watch has a water resistance of up to 100 feet/30 meters, suitable for short periods of recreational swimming.This stylish Swiss-made timepiece is sure to complete any man's collection.

    ReplyDelete
  2. Now designed by Mr McQueen’s long-time collaborator, replica boots Ms Sarah Burton, Alexander McQueen collections are characterised by replica alexander mcqueen immaculate tailoring and a dark, dramatic edge. Look out for sharp suiting and the label's signature skulls.

    ReplyDelete