Month: July 2019

PowerShell: Perform DISM Restore Health on Remote Servers

# This script will use a Windows ISO image to Repair Remote Computers$isoPath="\\FILESHERVER007\F$\Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO"$remoteComputers="TESTKOMPUTER","TESTKOMPUTER2"function restoreServerHealth($iso){ #…

Domain Controller Error: Broken DFS Replication

Error message: The DFS Replication service detected that the local path of a replicated folder…

Enable WinRM Remotely

Usage:enableWinRm 'RemoteServer' get-credential $remoteComputer='REMOTESERVER' $winRmPort=5985 $adminCredential=get-credential function enableWinRm($remoteComputer,$winRmPort=5985,$adminCredential){ function Check-NetConnection($computername,$port,$timeout=200,$verbose=$false) { $tcp = New-Object System.Net.Sockets.TcpClient;…

Weird RDP Error

[Window Title]Remote Desktop Connection[Content]The remote computer that you are trying to connect to requires Network…

PowerShell: Install and Uninstall App on Remote Machines

# Trigger uninstall of an MSI file$computername="SERVER007"$keywordSearch="Polycom*"$installFile="\\FILESHERVER\Software\Polycom\Polycom_BToE_Connector_4.0.0.0 (new for 2019-07-19)\Polycom_BToE_Connector_4.0.0.0.msi"# Trigger silent install of an…

PowerShell: Use Regex to Select IPv4 Patterns

# This example shows how to obtain ip address of the $env:logonserver$logonServerIP=nltest /DSGETDC:$regexIP = [regex]…

PowerShell: Replicate All Domain Controllers Immediately

<#Author: KimConnect.comVersion: 0.1Purpose:- After a change has been issued against a "logon server", that domain…

Script to Deploy Executables

set InstallRevision=1.0set TargetDir="%ProgramFiles%\Program Name"REM Check to see if the software has been installed. Check for…

PowerShell: Send Private Message to Another Computer

$name = read-host "Enter remote computer name "$messageInput = read-host "Enter your message to send…

Deploy MSI Using Group Policy

0. If the deployment package is in an .EXE format, it's recommended that such file…

PowerShell: Connect to Azure CLI

# Set PSGallery as trusted to bypass promptsSet-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted -WarningAction SilentlyContinue #…

PowerShell: Exchange Servers Discovery

List Exchange Servers from a non-exchange computer # Obtain a list of all on premise…

PowerShell: Reset Active Directory Server

Step 0: # Ensure that AD management module is available for PS Sessionif (!(get-module -name…

PowerShell: check whether the current user is a member of Domain Admins

# short snippet to check whether the currently login user is a domain admin$CurrentUser =…

Office 365 Active Directory Hybrid Accounts Administration

Intro This scenario assumes that Azure AD Sync has been used to synchronize on premise…

PowerShell: Script to Stop, Start, Disable, and Enable Exchange Server

<#This script contains a set of functions to administer Exchange 2010, 2013, 2016, and 3000.…

PowerShell: Add Office365 Records on DNS Servers

Make Changes to Internal DNS A. Delete Old CNAMES and MX Records Sample commands from…

Linux: Reclaim Disk Space by Performing System Cleanups

All systems: Check disk space usage # check /var directorydu -a /var | sort -nr…

PowerShell: Raise Domain Forest Functional Level

# Raise Forest Functional Level$forest=Get-ADForest# 2012R2 LevelSet-ADForestMode -Identity $forest -Server $forest.SchemaMaster -ForestMode Windows2012R2Forest -Force# 2016…

PowerShell: Demote Domain Controllers

$computername=$env:computername $localAdminPassword='PASSWORD' function demoteDc($computername=$env:computername,$localAdminPassword){ $erroractionpreference=stop $encryptedPass=convertto-securestring $localAdminPassword -asplaintext -force Import-Module ActiveDirectory $thisComputer=$env:computername $fsmoRoles=Get-ADDomainController -Filter *|Select-Object…