Skip to content

Instantly share code, notes, and snippets.

View dpo007's full-sized avatar

Dev dpo007

  • Ontario, Canada
View GitHub Profile
@dpo007
dpo007 / FoxitPhantomPDFScrubber.ps1
Last active April 29, 2022 17:33
PowerShell :: Scrubs Foxit's PhantomPDF editor off a machine. Created to help make way for upgrade to "Foxit PDF Editor".
<#
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
@dpo007
dpo007 / Create-RebootAtMidnightTask.ps1
Last active March 10, 2022 21:07
PowerShell :: Creates a self-deleting task that reboots Windows at midnight.
<#
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
@dpo007
dpo007 / Import-BarracudaCSVToMS365.ps1
Last active February 3, 2022 20:02
PowerShell :: Import Barracuda Sender Policy CSV into MS365 Anti-Spam Allow//Block Lists
param (
[string]$CsvPath = (Join-Path $PSScriptRoot 'AllowList.csv'),
[string]$MS365User = '[email protected]',
[string]$BarracudaQuarantineEmail = '[email protected]',
[switch]$IncludeBlockLists
)
$getSessions = Get-PSSession | Select-Object -Property State, Name
$isConnected = [bool](@($getSessions) -like '@{State=Opened; Name=ExchangeOnlineInternalSession*').Count -gt 0
If (!$isConnected) {
@dpo007
dpo007 / Test-ForPort.ps1
Last active January 27, 2022 21:32
PowerShell :: Test-ForPort function - Tests network port for X retires, or until it answers.
function Test-ForPort {
param (
[Parameter(Mandatory)]
[string]$Server,
[Parameter(Mandatory)]
[int]$Port,
[int]$RetryCount = 3,
[switch]$Quiet
)
@dpo007
dpo007 / Get-ADUserNestedMemberships.PS1
Last active October 12, 2021 15:49
PowerShell :: Get-ADUserNestedMemberships
function Get-ADUserNestedMemberships {
param (
[string]$SAMAccountName = $env:USERNAME
)
$userNestedMembership = @()
$domainConnection = New-Object DirectoryServices.DirectoryEntry
$domainConnection.AuthenticationType = [System.DirectoryServices.AuthenticationTypes]::Secure
@dpo007
dpo007 / UninstallUserLevelChrome.ps1
Created May 18, 2021 15:52
PowerShell :: Uninstall User-level Chrome install (ie: log on script)
$chromeFolder = Join-Path $env:LOCALAPPDATA '\Google\Chrome'
$setupPath = Join-Path $chromeFolder '\Application\*.*\Installer\setup.exe'
# Use setup.exe from most recent version folder found.
if ((gci $setupPath).Count -gt 1) {
$setupPath = gci $setupPath | sort -Descending
$setupPath = $setupPath[0]
}
$argList = '--uninstall --multi-install --chrome --force-uninstall'
@dpo007
dpo007 / ListAllTeamsAppsInUse.ps1
Created January 21, 2021 22:36
PowerShell :: Create CSV of all Apps being used in all Teams.
Connect-MicrosoftTeams
$teams = Get-Team
foreach ($team in $teams) {
$teamApps = Get-TeamsAppInstallation -TeamId $team.GroupId
foreach ($app in $teamApps) {
Write-Output ('{0},{1},{2}' -f $team.DisplayName, $app.DisplayName, $app.TeamsAppId) >> c:\temp\TeamApps.csv
}
}
@dpo007
dpo007 / FindManagerReports.ps1
Last active January 20, 2021 16:11
PowerShell :: Create simple CSV of AD users with reports (aka Managers)
$users = Get-ADUser -Server $DomainController -Filter * -Properties Name, DirectReports
foreach ($user in $users) {
$name = $user.Name
foreach ($report in $user.DirectReports) {
write-output (("$name, $report").Replace("CN=","") -replace ",OU=.*", "") >> c:\temp\ReportsByUser.csv
}
}
@dpo007
dpo007 / UploadToS3Bucket.ps1
Created October 23, 2020 17:18
PowerShell :: Upload folder of files to S3 bucket
Install-Module -Name AWS.Tools.Installer
Install-AWSToolsModule AWS.Tools.S3 -CleanUp
$bucket = 'some-s3-bucket'
Set-AWSCredential `
-AccessKey '<Get Your Own>' `
-SecretKey '<Get Your Own>'
# Gather files to upload
@dpo007
dpo007 / GetPickListChoice.ps1
Created September 14, 2020 21:46
PowerShell :: Console input with search list by typed letters, tab cycling, etc.
function GetPickListChoice {
param (
[Parameter(Mandatory=$true)]
[string[]]$PickList,
[string]$Prompt = 'Type to search, Tab to cycle matches, Backspace to reset, ''?'' for a list: ',
[switch]$PromptNoNewLine
)
function ClearCurrentChoice {
for ($i = $origCursorPos.X; $i -lt $endPos; $i++) {