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 random cat fact from API | |
$catFact = Invoke-RestMethod -Uri "https://catfact.ninja/fact" -Method Get | |
# Print cat fact | |
Write-Host $catFact.fact | |
# Setup speech synthesizer | |
Add-Type -AssemblyName System.Speech | |
$speech = New-Object System.Speech.Synthesis.SpeechSynthesizer |
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
<# | |
.SYNOPSIS | |
Script to find subfolders without matching Active Directory (AD) users and optionally move them to a destination folder. | |
.DESCRIPTION | |
This PowerShell script imports the Active Directory module and defines a function named Find-NonMatchingADUserFolders. The function takes two parameters: folderPath (mandatory) and destinationFolder (optional). It retrieves all subfolders in the specified folder and all existing AD users. It then iterates through each subfolder, checks if the subfolder name matches an existing AD user, and performs the specified action (move or list) based on the presence or absence of a matching user. | |
.EXAMPLE | |
Find-NonMatchingADUserFolders -folderPath "C:\Path\To\Folder" -destinationFolder "D:\Temp\OldUserFolders" | |
Moves the subfolders without matching AD users to the specified destination folder. |
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
<# | |
.SYNOPSIS | |
Retrieves users whose home directory paths do not contain their SamAccountName. | |
.DESCRIPTION | |
The Get-UsersWithMismatchedHomeDirectory function retrieves users from Active Directory whose home directory paths do not contain their SamAccountName. By default, it excludes users with empty home directories. Users can be optionally included by specifying the -IncludeEmptyHomeDirs switch parameter. | |
.PARAMETER IncludeEmptyHomeDirs | |
Switch parameter to include users with empty home directories in the results. |
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
#Requires -Version 5.0 | |
#Requires -Modules SharePointPnPPowerShellOnline | |
<# | |
.SYNOPSIS | |
Script to move folders and files from a source team's site to a destination team's site in SharePoint Online. | |
.DESCRIPTION | |
This PowerShell script requires PowerShell version 5.0 and the SharePointPnPPowerShellOnline module. It connects to SharePoint Online and retrieves the source team's site and the destination team's site based on the provided team names. It then retrieves all folders and files in the source team's site and moves each item to the destination team's site. | |
.PARAMETER SrcTeam |
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
$isPortable = $false | |
$chassisType = (Get-CimInstance -Query "Select * from Win32_SystemEnclosure").ChassisTypes[0] | |
switch ($chassisType) { | |
# Case 8 "Portable" | |
# Case 9 "Laptop" | |
# Case 10 "Notebook" | |
# Case 11 "Handheld" | |
# Case 14 "Sub-Notebook" | |
{$_ -in 8, 9, 10, 11, 14} { $isPortable = $true } |
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
<# | |
Configures Hyper-V replication between a set of host servers. | |
v1.0 - DPO - Aug. 2022 | |
#> | |
#Requires -RunAsAdministrator | |
#Requires -Version 5.1 | |
param ( | |
[string]$HostReplicaFolderPath = 'D:\ReplicaVMs', | |
[switch]$LeaveExistingAllowedServers | |
) |
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
$subject = 'automationname.domain.ca' | |
$certFileName = $subject -replace '\.','_' | |
$certPass = ConvertTo-SecureString 'AutomationCertificate!1' -AsPlainText -Force | |
# Create a self-signed certificate in the local machine personal certificate store and store the result in the $cert variable. | |
$cert = New-SelfSignedCertificate -Subject $subject | |
# Display the new certificate properties | |
$cert | Format-List -Property * | |
# Save the certificate (with private key) into a PFX file, and just the public key into a CRT file. |
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
<# | |
Foxit PhantomPDF Remover/Cleaner | |
V1.5 - DPO - Apr. 2022 | |
#> | |
param ( | |
[switch]$LeaveUUID | |
) | |
Write-Host 'Looking for Foxit PhantomPDF installs...' | |
$foxitPhantom = Get-Package 'Foxit Phan*' -AllVersions -ErrorAction SilentlyContinue |
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
<# | |
Create self-deleting task that reboots the computer at midnight. | |
#> | |
$midnight = (Get-date -Hour 0 -Minute 0 -Second 0).AddDays(1) | |
$taskname = 'Reboot at midnight' | |
$taskdescription = 'Reboots computer at midnight.' | |
if (Get-ScheduledTask -TaskName $taskname -ErrorAction SilentlyContinue) { | |
Unregister-ScheduledTask -TaskName $taskname -Confirm:$false |
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
param ( | |
[string]$CsvPath = (Join-Path $PSScriptRoot 'AllowList.csv'), | |
[string]$MS365User = 'coolguy@coolcompany.com', | |
[string]$BarracudaQuarantineEmail = 'quarantine@ess.ca.barracudanetworks.com', | |
[switch]$IncludeBlockLists | |
) | |
$getSessions = Get-PSSession | Select-Object -Property State, Name | |
$isConnected = [bool](@($getSessions) -like '@{State=Opened; Name=ExchangeOnlineInternalSession*').Count -gt 0 | |
If (!$isConnected) { |
NewerOlder