This file contains hidden or 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 | |
This script retrieves scheduled tasks from the Task Scheduler and checks whether "Synchronize across time zones" is enabled for tasks in the root task path (\). | |
.DESCRIPTION | |
The script iterates through all scheduled tasks, but only those in the root task path (\) are processed. | |
It exports each task's XML definition, searches for the <StartBoundary> element, and checks if the value ends with a timezone offset (e.g., -04:00, +02:00). | |
If a task has "Synchronize across time zones" enabled (indicated by the timezone offset), the script includes the task in the results. | |
.PARAMETER None |
This file contains hidden or 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
# Define the GPO name and the domains | |
$gpoName = "GPO To Go" | |
$domains = @("domain1.local", "domain2.local", "anotherDomain.com") | |
foreach ($domain in $domains) { | |
# Get the GPO | |
$gpo = Get-GPO -Name $gpoName -Domain $domain -ErrorAction SilentlyContinue | |
if ($gpo) { | |
# Get all OUs in the domain |
This file contains hidden or 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
function Write-Slow { | |
[Alias("WS", "WOPR", "WOPRType")] | |
param ( | |
[string]$Message, | |
[int]$DelayMilliseconds = 50, | |
[ConsoleColor]$ForegroundColor = $Host.UI.RawUI.ForegroundColor, | |
[ConsoleColor]$BackgroundColor = $Host.UI.RawUI.BackgroundColor | |
) | |
# Delay multipliers for punctuation and sentence-ending marks |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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. |
NewerOlder