Tuesday, January 21, 2014

Site Down for Maintenance

Here is something that I've been trying to setup as part of our deployment process. The goal is to provide users with a site maintenance page during the deployment. We do not require 100% up-time so this solution should meet our needs. I found additional details here which work pretty nice.

Steps:

  1. Copy App_Offline.htm.disabled to the website directory and move to App_Offline.htm
  2. Copy the application’s Web.config to Web.config.backup and move Web.config.disabled to Web.config, replacing the original
  3. Test that the offline page is rendered
  4. Deploy file system changes
  5. Move Web.config.backup to Web.config, replacing the temporary file
  6. Delete App_Offline.htm

<!DOCTYPE html>
<html lang="en">
<head>
<title>Down for Maintenance</title>
</head>
<body>
<div>&nbsp;</div>
<div id="wrapper">
<div id="page">
<div id="content">
<div class="box">
<h2>This website is down for maintenance</h2>
<p>
We&#39;re currently undergoing scheduled maintenance. We will come back very shortly. Please check back in fifteen minutes. Thank you for your patience.
</p>
</div>
</div>
</div>
</div>
</body>
</html>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<httpRuntime waitChangeNotification="300" maxWaitChangeNotification="300"/>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>

Friday, January 17, 2014

Report Duplicate AD Users By EmployeeID

Note: The employeeID is formatted to 7 characters so that if you had numbers with leading 0s they would still be matched.
# Get all the enabled users.
$users = Get-ADUser -Filter { Enabled -eq $true } -Properties EmployeeId
# Collect all the ids and format them to 7 characters.
$ids = @{}; $users | ForEach-Object { if($_.EmployeeId) { $ids[("{0:D7}" -f [int]$_.EmployeeId)] += 1 } }
$filteredUsers = $users | Where-Object { if($_.EmployeeId) { $ids[("{0:D7}" -f [int]$_.EmployeeId)] -gt 1 } }
$filteredUsers | Select-Object -Property SamAccountName, EmployeeId
$filteredUsers | Export-Csv -Path "C:\temp\DuplicateEmployeeId-$((Get-Date).ToString('yyyyMMddThhmmss')).csv" -NoTypeInformation