Skip to content

Instantly share code, notes, and snippets.

function Copy-File {
param(
#Path to the source file
[Parameter(
Mandatory = $True,
Position = 0
)]
[String]$SourceFilePath,
param (
[string]$TextQualifier = $null
#[string]$TextQualifier = 'None'
#[string]$TextQualifier = (0xFE -as [char]) #TEMPORARY HARD-CODED BS. REMOVE LATER
)
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
Do {
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
#$OpenFileDialog.Filter = "DAT (*.dat)| *.dat"
<#
First, use Outlook to create an email template.
Save it as a .msg file in the same folder as this script.
Include placeholder text to find and replace if you want to dynamically use code to update the email.
Then, this function will extract the Html and the attachments from the template .msg file
#>
param (
# Placeholder text and replacement text to insert into the template.
# Requires -Module virtualmachinemanager
using namespace Windows.Storage
using namespace Windows.Graphics.Imaging
using namespace System.Runtime.WindowsRuntime
param (
[string]$VMMServer,
[string]$OutputDir = 'C:\ProgramData\Get-SCVMConsoleOCR'
)
declare @COLLID AS nvarchar(8) = 'ABC12345'
declare @Today DateTime = GetDate()
declare @30DaysBeforeToday DateTime = DateAdd("d",-30,GetDate())
declare @31DaysBeforeToday DateTime = DateAdd("d",-31,GetDate())
declare @60DaysBeforeToday DateTime = DateAdd("d",-60,GetDate())
declare @61DaysBeforeToday DateTime = DateAdd("d",-61,GetDate())
declare @90DaysBeforeToday DateTime = DateAdd("d",-90,GetDate())
declare @91DaysBeforeToday DateTime = DateAdd("d",-91,GetDate())
declare @10YearsAgo DateTime = DateAdd("d",-3650,GetDate())
<#
.SYNOPSIS
Identify computer certificates on a Windows computer that will expire within the next 30 days.
.DESCRIPTION
Functions as a Custom EXE sensor for PRTG to monitor certificate expiration.
#>
param(
# Name of the computer to search for expiring certificates
param (
# Name of the group whose members to retrieve
[string]$GroupName
)
function Search-Directory {
# Uses the .NET System.DirectoryServices Namespace to perform an LDAP search
param (
On Error Resume Next
strOldHostname = InputBox ("Enter the hostname to be removed from DNS. Just the hostname, please; not the FQDN.","Enter the host name to be removed","")
'Track when the script began
StartTime = Now
'Begin the log file
Set objShell = CreateObject("WScript.Shell")
strLocalAppDataPath = objShell.ExpandEnvironmentStrings("%LocalAppData%")
@IMJLA
IMJLA / Read-FolderBrowserDialog.ps1
Last active January 14, 2024 05:43
A folder browser dialog with an address bar in native PowerShell
$AssemblyFullName = 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
$Assembly = [System.Reflection.Assembly]::Load($AssemblyFullName)
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.AddExtension = $false
$OpenFileDialog.CheckFileExists = $false
$OpenFileDialog.DereferenceLinks = $true
$OpenFileDialog.Filter = "Folders|`n"
$OpenFileDialog.Multiselect = $false
$OpenFileDialog.Title = "Select folder"
$OpenFileDialogType = $OpenFileDialog.GetType()
function Copy-File {
param(
#Path to the source file
[Parameter(
Mandatory = $True,
Position = 0
)]
[String]$SourceFilePath,