Category: Automation

Microsoft Windows Server 2012 R2 – Verify Service Status

You may use the Microsoft Windows PowerShell script below to verify the status of the service you specify, remotely.

<#
.SYNOPSIS
This script will provide the status of a service on the specified computer.
.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.
#>

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

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

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

#End of script


Microsoft Windows Server 2012 R2 – Verify Network Interface Card Status

You may use the Microsoft Windows PowerShell script below to verify the network interface card (NIC) status on servers running the Microsoft Windows Server 2012 R2 operating system. Additionally, the output of the script will be displayed in a graphical user interface (GUI).

<#
.SYNOPSIS
This script will verify the network interface card status of the selected servers.
.DESCRIPTION
This script will automate the process of verifying the network interface card status of the selected servers.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Thursday, August 05, 2016.
#>

#Verify the network adapter status of the branch servers
Get-NetAdapter -CimSession (Get-Content “C:\Scripts\Branch Servers.txt”) -Name NIC1, NIC2 | select SystemName, Status, MediaConnectionState | Out-GridView -Title “Network Adapters”

#End of script

 


Microsoft Windows Server 2012 R2 – Configure Hard Disks

The Microsoft Windows PowerShell script below may be used to automate the process of configuring hard disks in Microsoft Windows Server 2012 R2.

<#
.SYNOPSIS
This script will configure hard disks.
.DESCRIPTION
This script will automate the process of configuring hard disks.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Thursday, October 13, 2016.
#>

#Request the disk number
$Disk_Number = Read-Host “What is the disk number?”

#Request the disk letter
$Disk_Letter = Read-Host “What is the drive letter?”

#Request the disk size
$Disk_Size = Read-Host “What is the drive size?”
$Disk_Size = $Disk_Size -as [int]
$Disk_Size = $Disk_Size * “1GB”

#Initialize the disk
Initialize-Disk -Number $Disk_Number

#Pause for (5) seconds
Start-Sleep 5

#Configure the disk
New-Partition -DiskNumber $Disk_Number -DriveLetter $Disk_Letter -Size $Disk_Size
Format-Volume -DriveLetter $Disk_Letter -FileSystem NTFS -Confirm:$False
&”.\configure_disk_settings.ps1″

#End of script

 


Dell Compellent – Verify the Enterprise Manager and Enterprise Services Agent Service Status

You may use the Microsoft Windows PowerShell script below to remotely verify the Enterprise Manager and Enterprise Services Agent Service status. These services are essential to a healthy Enterprise Manager infrastructure.

<#
.SYNOPSIS
This script will provide the status of the Enterprise Manager service on EM01. Additionally, it will provide the status of the Enterprise Services Agent Service on servers utilizing the Enterprise Manager Server Agent.
.DESCRIPTION
This script will automate the process of providing the status of the Enterprise Manager service on EM01. Additionally, it will automate the the process of providing the status of the Enterprise Services Agent Service on servers utilizing the Enterprise Manager Server Agent.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Friday, September 30, 2016.
#>

#Query the status of the Enterprise Manager service on EM01
Get-Service -ComputerName EM01 | Where-Object {$_.name -eq “EnterpriseManagerDataCollector”}

#Query the status of the Enterprise Services Agent Service on servers utilizing the Enterprise Manager Server Agent
Get-Service -ComputerName SERVER01 | Where-Object {$_.name -eq “CompellentEMServerAgent”}
Get-Service -ComputerName SERVER02 | Where-Object {$_.name -eq “CompellentEMServerAgent”}
Get-Service -ComputerName SERVER03 | Where-Object {$_.name -eq “CompellentEMServerAgent”}

#End of script


Microsoft Windows Server 2012 R2 – Remote Server Reboot

You may use the Microsoft Windows PowerShell script below to remotely reboot a Microsoft Windows Server 2012 R2 host.

<#
.SYNOPSIS
This script will request the hostname of a remote server then forcefully restart the server.
.DESCRIPTION
This script will automate the process of forcefully restarting a remote server.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Monday, August 08, 2016.
#>

#Request the hostname of the remote server
$SERVER = Read-Host “What is the hostname of the server?”

#Force the restart of the remote server
Restart-Computer $SERVER -Force

#End of script


Microsoft Windows Server 2012 R2 – Install Server Roles

You may use the script below to install the File, Print, DFS, and Windows Server Backup roles on a Microsoft Windows Server 2012 R2 operating system.

<#
.SYNOPSIS
Install File, Print, DFS and Windows Server Backup roles and features.
.DESCRIPTION
Automate the install of the File, Print, DFS and Windows Server Backup roles and features.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Monday, November 16, 2015.
#>

#Install the File Server and File Server Resource Manager roles
Install-WindowsFeature -Name FS-FileServer -IncludeAllSubFeature -IncludeManagementTools
Install-WindowsFeature -Name FS-Resource-Manager -IncludeAllSubFeature -IncludeManagementTools

#Pause for (5) seconds
Start-Sleep 5

#Install the DFS Namespaces role
Install-WindowsFeature -Name FS-DFS-Namespace -IncludeAllSubFeature -IncludeManagementTools

#Pause for (5) seconds
Start-Sleep 5

#Install the Print Server role
Install-WindowsFeature -Name Print-Server -IncludeAllSubFeature -IncludeManagementTools

#Pause for (5) seconds
Start-Sleep 5

#Install the Windows Server Backup feature
Install-WindowsFeature -Name Windows-Server-Backup -IncludeAllSubFeature -IncludeManagementTools

#End of script

 


Microsoft Windows 7 – List Installed Appilcations

You may use the Microsoft Windows PowerShell script below to query a remote Microsoft Windows 7 computer, obtain a list of all installed applications, and write the content to a file and directory of your choice.

<#
.SYNOPSIS
This script will query a remote computer’s list of installed applications and provide the output in a text (.txt) file.
.DESCRIPTION
This script will automate the process of querying the list of installed applications on a remote computer.
.EXAMPLE
gwmi win32_product -ComputerName “PC01” | out-file -filepath “C:\Users\User01\Desktop\Applications.txt”.
.AUTHOR
Written by Noel Enrique Alvarez on Thursday, August 04, 2016.
#>

#Request the hostname of the computer
$hostname = Read-Host “What is the hostname of the computer?”

#Request the path and name of the output file
$file = Read-Host “Where would you like to store the file?”

#Query the remote computer, installed applications, and provide the output in a text file
gwmi win32_product -ComputerName $hostname | out-file -filepath $file


Microsoft Exchange Server 2013 – Disable Mailbox Script

You may use the script below, in the Exchange Management Shell, to disable a Microsoft Exchange Server 2013 mailbox using the Microsoft Active Directory display name.

<#
.SYNOPSIS
This script will disable the Microsoft Exchange Server 2013 mailbox of the specified user using their Microsoft Active Directory display name.
.DESCRIPTION
This script will automate the disabling of a Microsoft Exchange Server 2013 mailbox.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Wednesday, July 27, 2016.
#>

#Request the user’s Microsoft Active Directory display name
$User = Read-Host “What is the user’s Microsoft Active Directory display name?”

#Disable the Microsoft Exchange Server 2013 mailbox
Disable-Mailbox -Identity “$User”


Microsoft Exchange Server 2007 – Query Public Folder Primary Email Addresses

You may use the script below in the Exchange Management Shell to list all public folders and their primary email address in Microsoft Exchange Server 2007.

<#
.SYNOPSIS
Query all of the Microsoft Exchange Server 2007 public folders, provide their primary email address and write the output to a file.
.DESCRIPTION
Automate the output of the email addresses associated with the Microsoft Exchange Server 2007 public folders.
.EXAMPLE
Get-Mailpublicfolder | Format-List alias, emailaddresses | Out-File -filepath C:\Users\User01\Desktop\email.txt
.AUTHOR
Written by Noel Enrique Alvarez on Thursday, January 28, 2016.
#>

#Request the name of the file.
$File = Read-Host “What will be the name of the file?”

#Query the Microsoft Exchange Server 2007 public folders and provide the results in a text file
Get-Mailpublicfolder | Format-List alias, emailaddresses | Out-File -filepath <<<INSERT PATH>>>\$File


Microsoft Exchange Server 2007 – List Email Forwarding

You may use the script below in the Exchange Management Shell to list all mailboxes that are forwarding in Microsoft Exchange Server 2007.

<#
.SYNOPSIS
This script will provide a list of all Microsoft Exchange 2007 email addresses that are forwarding emails.
.DESCRIPTION
This script will automate the process of creating a list of all Microsoft Exchange 2007 email addresses that are forwarding emails.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Thursday, March 24, 2016.
#>

#Request the name of the output file
$File = Read-Host “What would you like to name the file?”

#Provide a list of all email addresses that are forwarding emails
Get-Mailbox | Where {$_.ForwardingAddress -ne $null} | Select Name, SamAccountName, PrimarySmtpAddress, ForwardingAddress, DeliverToMailboxAndForward | Out-File -filepath “<<<INSERT PATH>>>\$File.txt”