Category: Microsoft Windows PowerShell

Telnet – Testing Network Ports

You may use the command below, in the Windows command prompt or Windows PowerShell, to verify network ports are open on a specific host in your network. The example below is verifying that port Transmission Control Protocol (TCP) port 80 is open on Internet Protocol (IP) address 192.168.1.1.

Syntax: telnet <<<HOST>>> <<<PORT>>>
Example: telnet 192.168.1.1 80


Microsoft Windows PowerShell – Scheduling a Microsoft Windows PowerShell Script

You may use the following settings to configure a Microsoft Windows PowerShell script to run as an automated task in Task Scheduler. This is a very helpful feature for running scripts during the evening.

  • General
    • When running the task, use the following user account: DOMAIN\– USERNAME
    • Run whether user is logged on or not
  • Actions
    • Start a program
    • powershell.exe -file “<<<INSERT PATH TO SCRIPT>>>”
  • Settings
    • Allow task to be run on demand
    • run task as soon as possible after a scheduled start is missed
    • Stop the task if it runs longer than: 3 days
    • If the running task does not end when requested, force it to stop

Integrated Dell Remote Access Controller 8 – Command Line Reset

You may use the following (2) commands from a Microsoft Windows Server command prompt or Microsoft Windows PowerShell to remotely  reset an Integrated Dell Remote Access Controller 8 (iDRAC8).

racadm racreset soft
racadm racreset hard –f

 


Dell – Get Service Tag

You may use the command below, from Microsoft Windows Powershell or command prompt, to retrieve the service tag of a Dell device.

wmic bios get serialnumber


Microsoft Active Directory – Export Group Membership

You may use the following Microsoft Windows PowerShell script to export the users in a Microsoft Active Directory group to a notepad (.txt) file. Additionally, please edit the out-file -filepath portion of this script to a network location of your choice.

<#
.SYNOPSIS
This script will provide the members of a Microsoft Active Directory group and export them to a notepad (.txt) file.
.DESCRIPTION
This script automates the process of exporting the users in a Microsoft Active Directory group.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Thursday, March 17, 2016.
#>

#Import the Microsoft Active Directory module
Import-Module ActiveDirectory

#Request the name of the Microsoft Active Directory group
$GROUP = Read-Host “What is the name of the Microsoft Active Directory group?”

#Export the members of the Microsoft Active Directory group and export them.
Get-ADGroupMember -identity $GROUP | Select Name, SamAccountName | out-file -filepath “C:\Users\User01\Desktop\$GROUP.txt”


Microsoft Windows Server 2012 R2 – Dynamic Host Configuration Protocol (DHCP) Export and Import

You may use the following commands to export and import a Dynamic Host Configuration Protocol (DHCP) configuration for a server utilizing Microsoft Windows Server 2012 R2.

netsh dhcp server dump > dhcpconfig.dmp
netsh exec dhcpconfig.dmp

Enjoy!

 


Microsoft Windows Server 2012 R2 – Map a Network Drive

You may use the following command to map a network drive using the Microsoft Command Prompt or Microsoft Windows PowerShell. Additionally, replace the <HOSTNAME> and <SHARE> variables with the appropriate server and share name.

NET — USE Z: \\<HOSTNAME>\<SHARE>

Enjoy!


Microsoft Windows PowerShell – Get Service Status and Start Service

The Microsoft Windows PowerShell script below will provide the status of a service on the specified server, start the service, then provide the status of the service, again.

<#
.SYNOPSIS
This script will a service on the specified server.
.DESCRIPTION
This script automates the process of starting a service.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Thursday, March 03, 2016.
#>

#Request the hostname of the server and the name of the service
$SERVER = Read-Host “What is the hostname of the server?”
$SERVICE = Read-Host “What is the name of the service?”

#Request the status of the service
get-service -computername $SERVER | where-object {$_.name -eq “$SERVICE”}

#Pause for (5) seconds
Start-Sleep 5

#Start the service
get-service -name $SERVICE -computername $SERVER | set-service -status running

#Pause for (5) seconds
Start-Sleep 5

#Request the status of the service
get-service -computername $SERVER | where-object {$_.name -eq “$SERVICE”}


Microsoft Windows PowerShell – Get Service Status

The Microsoft Windows PowerShell script below will provide the status of a service on the specified server.

<#
.SYNOPSIS
This script will provide the status of a service on the specified server.
.DESCRIPTION
This script automates the process for verifying the status of a service.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Tuesday, November 24, 2015.
#>
$SERVER = Read-Host “What is the hostname of the server?”
$SERVICE = Read-Host “What is the name of the service?”
get-service -computername $SERVER | where-object {$_.name -eq “$SERVICE”}


Microsoft Windows Server 2012 R2 – Resynchronize Network Time Protocol Client

You may use the following Windows PowerShell command to resynchronize the Network Time Protocol (NTP) client, in Microsoft Windows Server 2012 R2, with it’s NTP server.

w32tm /resync /nowait

Enjoy!