Month: September 2020

PowerShell: Process Watcher – Restart Stopped Services

# processWatcher.ps1 # User Input $computername=$env:computername $serviceName='remoteregistry' $desiredStatus='Running' $action={ param($serviceName) $erroractionpreference='stop' try{ start-service $serviceName return…

Automating Scheduled Task Creation on Remote Computers

# createTaskScheduler.ps1 # What this script does: # 1. Ask user for valid Domain Admin…

Quick Script to Mount Remote UNC Paths as Local Drive Letters

Simple Mount: # Mapping a drive $username='domain\testAdmin' $password='PASSWORD' $remotePath='\\UNCSERVER\SHAREPATH\Backup' $unavailableDriveLetters=(Get-Volume).DriveLetter|sort $availableDriveLetters=.{(65..90|%{[char]$_})|?{$_ -notin $unavailableDriveLetters}} [char]$firstAvailableDriveLetter=$availableDriveLetters[0] $command="net…

PowerShell: Process Watcher

# processWatcher.ps1 # User Input $serviceName='MSCRMAsyncService$maintenance' # Semi-autogen variables $desiredStatus='Running' $environment=($env:computername).substring(0,$env:computername.IndexOf('-')) $reportServer="$environment-SQL01" function checkService($computername=$env:computername,$serviceName,$status='Running'){ #…

Resolving CRM Error Upon Login

Symptom: Error Message when trying to login to CRM [caption id="attachment_7481" align="alignnone" width="237"] INVALID ACTION[/caption]…

Hyper-V Virtual Machines Won’t Start on Restore or Live Migration

Symptom: Cluster resource of type 'Virtual Machine' in clustered role failed. The error code was…

Microsoft Management Console Snap-in Shortcuts

Admin Snap-in Command Quality of Service Control Management ACSsnap.msc ADSI Edit ADSIedit.msc Authorization manager AZman.msc…

Active Directory Domain Controller Certificates Installation Guide

Overview This article deals with Domain Controllers, rather than member servers. Thus, Active Directory or…

PowerShell: Get OU of a User & Get All Users In an OU

function getUserOu($username){ if(!(get-module activedirectory -ea SilentlyContinue)){ $osType=switch ((Get-CimInstance -ClassName Win32_OperatingSystem).ProductType){ 1 {'client'} 2 {'domaincontroller'} 3…

PowerShell: Test Domain Username & Password Credential

Version 2: function testCredential($username,$password){ # Get current domain using logged-on user's credentials $isDomainJoined=$env:USERDOMAIN -ne $env:COMPUTERNAME…

How to Add Domain Admins to SQL Server

Step 1: Right-click Start > Search > type in 'ssms.exe' > right-click Microsoft SQL Server…

SQL: Creating a Storage Report of Databases Residing within Server

Method 1: -- Get sizes of all databases from system (not real-time) WITH fs AS…

SQL: Backup Database and Purge It From SQL Server

/* Make a Final Backup of Database, Purge Its Backup and Restore History, and Remove…

PowerShell: Windows 10 Cleanup

Update: there's a new script to cleanup windows here. function cleanWindows{ write-host 'Disabling Windows Media…

Set Windows Remote Desktop To Allow Blank Passwords

By default, Windows restricts RDP access for account without passwords. Of course, this is a…

PowerShell: Check Registry Path, Key, and Dword Value

$path='HKLM:\Software\Intel' $keyName='GMM' $dwordName='DedicatedSegmentSize' $dwordValue=512 Function CheckRegistryKey { param( [Parameter(Position = 0, Mandatory = $true)][String]$path, [Parameter(Position…

Linux: Enable PowerShell Remoting WinRM Client on Ubuntu 20.04

This note is a work-in-progress as the NTLM authentication support module by Microsoft for Ubuntu…

PowerShell: Purge, Destroy, or Empty a Directory!

# WARNING: THIS IS A VERY DESTRUCTIVE FUNCTION. IF EXECUTED AT THE WRONG DIRECTORY WHERE…

Tasks to Perform After Windows 10 Upgrade

Target for Windows upgrade cleanup: C:\$Windows.~BT\* C:\$Windows.~LS\* C:\$Windows.~WS\* C:\ESD\Download\* C:\ESD\Windows\* C:\$WINDOWS.~Q\* C:\$INPLACE.~TR\* C:\Windows.old\* C:\Windows\Panther Please…

PowerShell: Graceful Shutdown of MS SQL Server

import-module sqlps CD SQLSERVER:\SQL\$env:computername $sql = (get-item .).ManagedComputer # This command stops MSSQL$instanceName, SQLSERVERAGENT, SQLAGENT$instanceName,…