This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Connect and choose subscription | |
# connect-AzAccounts | |
# Initialize azusers as an array | |
$azusers = @() | |
# Get all resource groups | |
$resourceGroups = Get-AzResourceGroup | |
# Get all resources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check if running as administrator | |
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { | |
$response = Read-Host "This script requires elevated permissions. | |
Do you want to run this script as an Administrator? | |
(y/n)" | |
if ($response -eq 'y') { | |
Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$($MyInvocation.MyCommand.Path)`"" -Verb RunAs | |
exit | |
} else { | |
"Exiting script." | Out-Host |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ensuring TLS/SSL connection to our host | |
# WARNING: TrustAllCertsPolicy trusts all SSL certificates, including invalid ones. | |
# Use this only if connecting to a server with a self-signed or untrusted certificate. | |
# For servers with valid SSL certificates from a trusted CA, consider removing this section. | |
#add-type @" | |
# using System.Net; | |
# using System.Security.Cryptography.X509Certificates; | |
# public class TrustAllCertsPolicy : ICertificatePolicy { | |
# public bool CheckValidationResult( | |
# ServicePoint srvPoint, X509Certificate certificate, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import the ActiveDirectory module | |
Import-Module ActiveDirectory | |
# Define the names of your groups | |
$win10Group = "Windows 10 Computers" | |
$win11Group = "Windows 11 Computers" | |
# Define the OU from where you want to get computer objects. Replace OU=Computers,DC=YourDomain,DC=com with your OU | |
$ou = "OU=Computers,DC=YourDomain,DC=com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$userPath = $env:USERPROFILE | |
$pathExclusions = New-Object System.Collections.ArrayList | |
$processExclusions = New-Object System.Collections.ArrayList | |
$pathExclusions.Add('C:\Windows\Microsoft.NET') > $null | |
$pathExclusions.Add('C:\Windows\assembly') > $null | |
$pathExclusions.Add($userPath + '\Downloads\HeidiSQL_11.3_64_Portable') > $null | |
$pathExclusions.Add($userPath + '\.dotnet') > $null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Result=@() | |
#Get all user mailboxes | |
$mailboxes = Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox | |
$totalmbx = $mailboxes.Count | |
$i = 0 | |
$mailboxes | ForEach-Object { | |
$i++ | |
$mbx = $_ | |
$size = $null | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Mbx = Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited | |
$Report = @() | |
ForEach ($M in $Mbx) { | |
$LastProcessed = $Null | |
Write-Host "Processing" $M.DisplayName | |
$Log = Export-MailboxDiagnosticLogs -Identity $M.Alias -ExtendedProperties | |
$xml = [xml]($Log.MailboxLog) | |
$LastProcessed = ($xml.Properties.MailboxTable.Property | ? {$_.Name -like "*ELCLastSuccessTimestamp*"}).Value | |
$ItemsArchived = $xml.Properties.MailboxTable.Property | ? {$_.Name -like "*ElcLastRunArchivedFromRootItemCount*"} | |
If ($LastProcessed -eq $Null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module ExchangeOnlineManagement | |
Connect-ExchangeOnline -UserPrincipalName <replace brackets and contents with the upn you want to connect with> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get list of all room mailboxes | |
Get-Mailbox -RecipientTypeDetails RoomMailbox | Select Name | |
#Get list of specific mailbox calendar access rights English: | |
Get-MailboxFolderPermission -Identity insert name of room:\Calendar | |
#Get list of specific mailbox calendar access rights Danish: | |
Get-MailboxFolderPermission -Identity insert name of room:\Kalender | |
#Adding view access rights for calendar room mailbox Danish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Note that the language chosen upon first login decides the naming used for the mailbox calendar. | |
#Change default rights Danish calendar: | |
foreach($user in Get-Mailbox -RecipientTypeDetails UserMailbox) { | |
$cal = $user.alias+":\Kalender" | |
Set-MailboxFolderPermission -Identity $cal -User Default -AccessRights LimitedDetails | |
} | |
#Change default rights English calendar: | |
foreach($user in Get-Mailbox -RecipientTypeDetails UserMailbox) { |
NewerOlder