# AutomatedServerSetup-Cleanup.ps1

## Overview

This Powershell script will acleanup the directory you used in AutomatedServerSetup.ps1.    
The script will also send you an email with the automation logged attached, if you supplied your email address in Variables.xml - Variables.Email.EmailTo.   

## Source    

Public download link: https://toolkit.datapipe.net/BesTasks/anthony/AutomatedServerSetup/AutomatedServerSetup-Cleanup.ps1  

## Requirements
- Server 2012, Server 2012 R2.  

- Powershell execution policy must be set to unrestricted or bypass.   
`Set-ExecutionPolicy unrestricted -Force  

- AutomatedServerSetup-Cleanup.ps1 must be saved to the server.  Suggested location: C:\DPAutomation\AutomatedServerSetup-Cleanup.ps1    

- DP Windows Powershell module (DPWindowsPSM), saved to C:\DPAutomation\DPWindowsPSM.psm1 (unless the location is changed in Variables.xml - Variables.AutomationSettings.WindowsPSMPath.     
PSM link: https://toolkit.datapipe.net/BesTasks/anthony/WindowsPSM/DPWindowsPSM.psm1       

- Variables.xml must be saved to the server.  Suggested location: C:\DPAutomation\Variables.xml    

## Usage
- Parameter -VariablesFile must be used, pointing the script to the location of Variables.xml   

- Parameter -Directory must be used, pointing the script to directory you want to remove     

To automatically invoke this script once AutomatedServerSetup.ps1 configures the server and it is rebooted, in Variables.xml - Variables.PostConfiguration.PostReboot.PSCommand, enter: `C:\DPAutomation\AutomatedServerSetup-Cleanup.ps1 -VariablesFile 'C:\DPAutomation\Variables.xml' -Directory 'C:\DPAutomation'`

## Contributors

* Anthony Marino (<amarino@datapipe.com>)
