Month: August 2016

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”


Microsoft Exchange Server 2007 – List Email Addresses

You may use the script below in the Exchange Management Shell to list the primary email address of each mailbox in Microsoft Exchange Server 2007.

<#
.SYNOPSIS
This script will provide a list of all Microsoft Exchange users and their primary email address then provide the results in a text file.
.DESCRIPTION
This script will automate the process of providing a list of all Microsoft Exchange users and their primary email address then provide the results in a text file.
.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?”

#List all of the Microsoft Exchange users and their primary email address then provide the results in a text file
Get-Mailbox | Select Name, SamAccountName, PrimarySmtpAddress | format-list | Out-File -filepath “<<<INSERT PATH>>>\$File.txt”


Microsoft Exchange Server 2007 – List Public Folder Permissions

You may use the script below in the Exchange Management Shell to list public folder permissions in Microsoft Exchange Server 2007.

<#
.SYNOPSIS
This script will list a public folder and it’s subfolders in Microsoft Exchange 2007.
.DESCRIPTION
This script will automate the process of listing a public folder and it’s subfolders in Microsoft Exchange 2007.
.EXAMPLE
N/A.
.AUTHOR
Written by Noel Enrique Alvarez on Thursday, March 24, 2016.
#>

#Request the Microsoft Exchange public folder
$Folder = Read-Host “What is the path to the Microsoft Exchange public folder?”

#List the Microsoft Exchange Server 2007 public folder and it’s subfolder
Get-PublicFolder –Identity $Folder -Recurse