aliyev's notes

  • About

Posts tagged: powershell

Automatically Log off Disconnected User Sessions on Windows

September 15, 2020, by admin No comments yet

Simple Powershell code that can be used to immidiately logoff a closed RDP session on a Windows server using windows task scheduler to trigger its run at sessions disconnects.

$sessions = ((quser | Where-Object {$_ -match ‘Disc’}))
foreach ($session in $sessions) {

$sessionid= ($session -split ‘ +’)[2]
logoff $sessionid
}

Sharepoint Online. Get storage use per site using powershell

June 8, 2020, by admin No comments yet
Connect-SPOService -Url https://xxxxx-admin.sharepoint.com

$ODFBSites = Get-SPOSite -Limit All | Select Owner, Title, URL, StorageQuota, StorageUsageCurrent | Sort StorageUsageCurrent -Desc
 $TotalODFBGBUsed = [Math]::Round(($ODFBSites.StorageUsageCurrent | Measure-Object -Sum).Sum /1024,2)

$Report = [System.Collections.Generic.List[Object]]::new()
 ForEach ($Site in $ODFBSites) {
 $ReportLine = [PSCustomObject]@{
 Owner = $Site.Title
 Email = $Site.Owner
 URL = $Site.URL
 QuotaGB = [Math]::Round($Site.StorageQuota/1024,2)
 UsedGB = [Math]::Round($Site.StorageUsageCurrent/1024,2)
 PercentUsed = [Math]::Round(($Site.StorageUsageCurrent/$Site.StorageQuota * 100),2) }
 $Report.Add($ReportLine) }
 $Report | Export-CSV -NoTypeInformation sporeport.CSV
 Write-Host "Current OneDrive for Business storage consumption is" $TotalODFBGBUsed "GB. Report is in sporeport.CSV"

Categories

  • FreePBX
  • IIS
  • Misc
  • Nokia
  • Photoshop
  • Server 2003
  • Server 2008
  • Ubuntu advices
  • Ubuntu troubles
  • Uncategorized
  • vim
  • Windows 2003
  • Wordpress

Recent blog posts

  • Automatically Log off Disconnected User Sessions on Windows admin, September 15, 2020
  • Event ID 20069 – AT_KEYEXCHANGE admin, September 15, 2020
  • SharePoint Online: Adding Term Store Administrators admin, June 10, 2020
  • Sharepoint Online. Get storage use per site using powershell admin, June 8, 2020
  • Extract IP addresses from PCAP admin, May 19, 2020

This is widgetised area:
Footer › Column 1

This is widgetised area:
Footer › Column 2

This is widgetised area:
Footer › Column 3

Copyright © 2020 aliyev. All Rights Reserved. Cookie policy | Privacy policy