From 4545fcd94229826fd4e9a506c75c12a663c5b2ec Mon Sep 17 00:00:00 2001 From: dyoder Date: Thu, 17 Sep 2020 15:57:43 -0400 Subject: [PATCH] disable hibernation --- Cleanup-SystemTempFiles.ps1 | 8 ++++++++ Connect-MSO365.ps1 | 26 +++++++++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Cleanup-SystemTempFiles.ps1 b/Cleanup-SystemTempFiles.ps1 index f4da79b..4cef3af 100644 --- a/Cleanup-SystemTempFiles.ps1 +++ b/Cleanup-SystemTempFiles.ps1 @@ -42,6 +42,14 @@ If ( IsAdmin ) Write-Output "Deleting all temp files not modified in ${OlderThan} day(s) from ${SysTemp}" ForEach ( $OldTempFile in $OldTempFiles ) { Remove-Item $OldTempFile -Force -Recurse -ErrorAction SilentlyContinue } } + + ## Turn off system hibernation if it's in use + If ( Test-Path "${Env:SystemDrive}\hiberfil.sys" ) + { + Write-Output "Turning off system hibernation" + Try { Start-Process "powercfg" -ArgumentList "-h off" -Wait } + Catch { Write-Output $_.Exception.Message } + } } ## Only run this section if we don't have administrative privileges diff --git a/Connect-MSO365.ps1 b/Connect-MSO365.ps1 index 8351e24..f3d3a4e 100644 --- a/Connect-MSO365.ps1 +++ b/Connect-MSO365.ps1 @@ -5,7 +5,7 @@ param([string]$User) ## Install ExchangeOnlineManagement module if it doesn't already exist If ( !(Get-Module -ListAvailable -Name ExchangeOnlineManagement) ) { - Try { Install-Module -Name ExchangeOnlineManagement -RequiredVersion 1.0.1 } + Try { Install-Module -Name ExchangeOnlineManagement } Catch { Write-Output $_.Exception.Message ; Exit } } Import-Module ExchangeOnlineManagement @@ -13,18 +13,18 @@ Import-Module ExchangeOnlineManagement Connect-ExchangeOnline -UserPrincipalName $User -ShowProgress $true -$Groups = Get-UnifiedGroup -ResultSize Unlimited -$Groups | ForEach-Object { - $group = Get-UnifiedGroupLinks -Identity $_.Name -LinkType Members -ResultSize Unlimited - $group | ForEach-Object { - New-Object -TypeName PSObject -Property @{ - Group = $group.DisplayName - Member = $_.Name - EmailAddress = $_.PrimarySMTPAddress - RecipientType= $_.RecipientType - } - } -} | Export-CSV “${Env:UserProfile}\Desktop\group-export.csv" -NoTypeInformation -Encoding UTF8 +#$Groups = Get-UnifiedGroup -ResultSize Unlimited +#$Groups | ForEach-Object { +# $group = Get-UnifiedGroupLinks -Identity $_.Name -LinkType Members -ResultSize Unlimited +# $group | ForEach-Object { +# New-Object -TypeName PSObject -Property @{ +# Group = $group.DisplayName +# Member = $_.Name +# EmailAddress = $_.PrimarySMTPAddress +# RecipientType= $_.RecipientType +# } +# } +#} | Export-CSV “${Env:UserProfile}\Desktop\group-export.csv" -NoTypeInformation -Encoding UTF8