Category: Codes

How to Convert Windows Application to Run as a Service

Pre-requisites: srvany.exe (from rktools) instsrv.exe Copy srvany.exe and instsrv.exe from to c:\windows\system32 >> Run: CMD…

Sync AD OU Containers with Group Memberships

Script to Add Group Membership:for /f "tokens=*" %A IN ('dsquery user %PATH_TO_OU%') DO dsmod user…

PowerShell Commands to Install the NTFSSecurity Module

Background information:- NTFS code is hosted on Github: https://codeload.github.com/raandree/NTFSSecurity/zip/refs/heads/master- Find module path with this command:…

FTP On Upload Email

# Connection details# If your SMTP server does not support SSL, remove the -UseSSL parameter…

Manual Sync for Office 365 Azure-AD Integration

1. Perform Prerequisites:* a. Install Dot Net Framework 4.5 )* b. Install Windows Management Framework…

Script to Push Files to Remote SFTP Server

# 1. Install WINSCP and include it in the %PATH% environmental variables# 2. Run this…

PowerShell Script to Clean Up Files Older than X Days

$purgePeriod = 30;$folders = '\\FILSERVER01\ORDERS\BACKUP','C:\SFTP_BACKUP';Get-ChildItem -path $folders | where {$_.Lastwritetime -lt (date).adddays(-$purgePeriod)} | remove-item;

PowerShell Script to Read/Parse XML Files in a Directory

# This script is to be set on the FTP server or $folder = '\\FTPSERVER05\SFTP\EDI\INCOMING';$files…

ARP MAC to IP Resolution

If entry already exists on the ARP table:arp -a | find "XX-XX-XX-XX-XX-XX"If entry does not…

PowerShell Script to Send Email

Use this newer method: https://blog.kimconnect.com/powershell-script-to-send-emails/ ### Variables section ###$fromaddress = "[email protected]"$toaddress = "[email protected]"$bccaddress = ""$CCaddress…

Windows Active Directory Snapshots

Set scheduled task to run daily and call this maintainSnapshots.bat file:------------------------------@echo offREM Logs Location (Used…

User Account Group Membership Copy

This is the quick snippet to be executed in the context of a Domain Administrator:…

One-Liner: Capture Report of Logons in AD

echo %date%,%time%,%username%,logon,%computername% >> \\FILESERVER01\IT\scripts\logons.csv

Show Users Logons per Computer Names

# This script is to obtain log on information from a set of target computernames…

Exchange: New-MoveRequest

New-MoveRequest -Identity '[email protected]' -TargetDatabase "DB01" -WhatIfNew-MoveRequest -Identity '[email protected]' -TargetDatabase "DB01"Get-Mailbox -Database DB01 | New-MoveRequest -TargetDatabase…

Discover FSMO roles

Option ExplicitDim WSHNetwork, objArgs, ADOconnObj, bstrADOQueryString, RootDom, RSObjDim FSMOobj,CompNTDS, Computer, Path, HelpTextSet WSHNetwork = CreateObject("WScript.Network")Set…

Find Hostnames per UserID in Event Logs on Domain Controllers

$targetAccounts=Get-Content "C:\Users\kimconnect\Desktop\targetAccounts.txt"function Get-UserComputerName { <#.SYNOPSIS Searches a specified Domain Controller for the computername of a…

Query Print Spooler of SERVER1

function getStatus($server, $service){    Get-WmiObject Win32_Service -Filter "Name Like 'spooler'" -computer SERVER1 -credential $cred | select…

Quick 1-Liner to List Domain Controllers and ReadOnly Statuses

PS C:\WINDOWS> Get-ADDomainController -Filter * | select Name,IsReadOnlyName       IsReadOnly----       ----------MONKEY       FalseBABOON       FalseGIRAFFE      FalseLION   FALSEKIMCONNECT   TrueKIMDISCONNECT TrueWHAT        TrueNOWAY        TrueWEBDC01      TrueWEBDC02      TrueSSO01        True

Function to list Domain Controllers

Wuick Script: # This function runs faster than the "Get-ADDomainController -Filter *" methodfunction listControllers{$domain =…