Category: Codes

PowerShell: Move Computer Objects in Active Directory

Version 2 # MoveComputers.ps1 # Version 0.0.2 # Obtain credentials being passed by Jenkins #…

PowerShell: Use Win-SCP to Download Files from SFTP Server

Version 2: # downloadFilesViaSftp.ps1 # Version 0.0.2 # # Description: # This simple script is…

PowerShell: Invoke CRM Services Maintenance

Version 4: # invokeCrmServersMaintenance.ps1 # Version 0.0.4 # This script is a processes watcher on…

PowerShell: Update Local Windows Using COM Objects – Legacy Compatible

Although this function requires 'interactive' or console sessions, it can be trigged by Windows Scheduled…

PowerShell: Remove a Scheduled Task By Name

# removeScheduledTask.ps1 # Set CoomputerNames $computerNames='sherver0001','sherver1000' $scheduledTaskName='SomeTaskName' # Obtain credentials $username='Domain\Admin' $password='PASSWORD' $encryptedPassword=ConvertTo-SecureString $password -AsPlainText…

PowerShell: Get Ports to Process Connections / Associations

Current Iteration: Here is a quick snippet to enable Network Engineers and Systems dudes to…

PowerShell: Process Watcher – Perform CRM Async Services Maintenance

Update: this script is deprecated in favor of a better one here. Version 1: #…

PowerShell: Replacing Characters Inside Text Files

$textFilesDirectory="C:\Users\$env:computername\Desktop\test" $textFileExtensions='.txt' $regexNewlineOnly="(?<!\r)\n$" $replaceWith="`r`n" function updateFile{ param( $file="C:\Users\$env:username\Desktop\test.txt", $regexMatch="(?<!\r)\n$", $replaceWith="`r`n", $output ) $output=if($output){$output}else{$file} if($file -ne…

PowerShell: connectWinRM Function to Create New-PSSession

This reusable function may be included into PoSh scripts for better connection toward Windows machines…

PowerShell: Installing or Including an Application On a Computer or Scripting Session

Sample Usage: PS C:\WINDOWS\system32> includeapp -appName notepadplusplus -appExe notepad++notepadplusplus version 7.91.0.0 already exists.True function includeApp($appName,$appExe=$False,$version){…

PowerShell: Renaming a System File

System files are typically owned by the TrustedInstaller account and protected from deletion or changes.…

PowerShell: Replacing Notepad with Notepad Plus Plus

Update 12/04/2020: there's a simpler solution - install notepad2! choco install notepad2 -y The command…

How to Host Multiple Domains with SSL Using Microsoft Information Service (IIS)

Step 1: Add SSL Certs into the computer information store Here's a sample script to…

PowerShell: How to Replace a System File – For Experimentation Purposes

# When attempting to rename a system protected file such as notepad.exe $notepadExe='C:\Windows\system32\notepad.exe' $newNotePadExe='C:\Users\rambo\Desktop\notepad.exe' rename-item…

How to Set Default UTF-8 encoding for New Notepad Documents When Saving File

Part 1: Set Default UTF-8 encoding for New Notepad Documents When Saving File for Legacy…

PowerShell: Rebooting a List of Computers

Recommended Method to Process a List of Computers: $computernames='web01','web02','web03' restart-computer -computername $computernames -force -wait Get-WmiObject…

Random Notes about WSUS

#Install the PowerShell Windows Update module $checkModule=Get-Module -ListAvailable -Name PSWindowsUpdate if(!($checkModule)){ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 #…

How to Install Secured Shell SSH on Windows

# Windows 10 & Server 2019 # Install the OpenSSH Server Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0…

Linux: How to Display the SSL Certificate of a Remote Server URL

Command: server=test.kimconnect.comecho | openssl s_client -showcerts -servername $server -connect $server:443 2>/dev/null | openssl x509 -inform…

PowerShell: Test LDAPS Connection

Function testLdap { [CmdletBinding()] Param( [Parameter(Position=0,ValueFromPipeline=$true)]$dcs=$($ENV:LOGONSERVER -replace '\\',''), [Parameter(Position=1,ValueFromPipeline=$true)]$port='636' ) $ErrorActionPreference = "Stop" $results =…