Category: Scripting

VMware PowerCLI – Create a Snapshot

You may use the following VMware PowerCLI cmdlet to create a snapshot of a virtual machine (VM) in VMware. New-Snapshot -VM HOSTNAME -Name “<<>>” -Description “<<>>”


VMware PowerCLI – Exit VMware ESXi Host out of Maintenance Mode

You may use the following VMware PowerCLI script to exit a VMware ESXi host out of maintenance mode. <# .SYNOPSIS This script will exit a VMware ESXi host out of maintenance mode. .DESCRIPTION This script will exit a VMware ESXi host out of maintenance mode. .EXAMPLE Set-VMHost -VMhost HOST.DOMAIN.COM -State Connected. .AUTHOR Written by Noel…


VMware PowerCLI – Place VMware ESXi Host in Maintenance Mode

You may use the following VMware PowerCLI script to place a VMware ESXi host in maintenance mode. <# .SYNOPSIS This script will place a VMware ESXi host in maintenance mode. .DESCRIPTION This script will place a VMware ESXi host in maintenance mode. .EXAMPLE Set-VMHost -VMhost HOST.DOMAIN.COM -State Maintenance. .AUTHOR Written by Noel Enrique Alvarez on…


Microsoft Windows PowerShell – Query Users on Remote Server

You may use the following Microsoft Windows PowerShell script to query a remote server and display any logged on users. <# .SYNOPSIS This script will query a remote server and display user session information. .DESCRIPTION This script will query a remote server and display user session information. .EXAMPLE N/A. .AUTHOR Written by Noel Enrique Alvarez…


Microsoft Windows PowerShell – Reboot Multiple Servers

You may use the following Microsoft Windows PowerShell script to reboot multiple Microsoft Windows hosts on a network. <# .SYNOPSIS This script will query a list of hostnames then reboot each server. .DESCRIPTION This script will query a list of hostnames then reboot each server. .EXAMPLE Restart-Computer $SERVER .AUTHOR Written by Noel Enrique Alvarez on…


Microsoft Active Directory – Get Computer Object Organizational Unit

You may use the following Windows PowerShell cmdlet to query Microsoft Active Directory (AD) for the hostname and organizational unit (OU) of a computer object. Get-ADComputer -Filter ‘Name -EQ “HOSTNAME“‘ | Format-List -Property Name, DistinguishedName


Microsoft Active Directory – View a List of Servers

You may use the following Windows PowerShell cmdlet to get a list of all of the Windows Servers in your Microsoft Active Directory (AD) domain. In particular, it will provide the hostname of the server, operating system, and service pack then output the results to a CSV file. Get-ADComputer -Filter ‘OperatingSystem -like “Windows Server*”‘ -Properties…


Microsoft Windows PowerShell – DHCP Logs

You may use the following Microsoft Windows PowerShell cmdlet to view the last one hundred lines of a Microsoft Windows Server DHCP server log for a particular Internet Protocol (IP) address. This may be useful when you are troubleshooting DHCP errors in Microsoft Windows Server. Get-Content DhcpSrvLog-Mon.log | Select -Last 100 | Select-String -Pattern “X.X.X.X”…


Microsoft Windows PowerShell – Resolve-DnsName

You may use the Resolve-DnsName Microsoft Windows PowerShell cmdlet to perform Domain Name System (DNS) query resolution for the domain name(s) you specify. Below you will find a few examples of this cmdlet. To perform a standard query enter Resolve-DnsName domain.com. To perform a query without the use of a local hosts file or DNS cache enter Resolve-DnsName…


Microsoft Windows PowerShell – Remote Server Service Status

The Microsoft Windows PowerShell script below will request the hostname of a server as well as the service to be queried then provide the status of the service. <# .SYNOPSIS This script will request the hostname of a server, the name of the service, then provide it’s status. .DESCRIPTION This script will request the hostname…