Windows Server 2008 Restore fails with error 0×80042406

When trying to restore a Windows Server 2008 R2 backup from disk it failed immediately with error 0×80042406
The solution was to hit Shift-F10 and bring up the command prompt, from there type:

diskpart

list all the disks on the machine and find your target disk:

list disk 

Select our destination in this scenario is disk 0 (Yours may be different)

select disk 0

Now we wipe all partition information and filesystem tables on the disk we selected above (destructive!)

clean all

Now try your restore again!

Grep with Powershell

where {$_ -match “SomeString”}

Or Inverse match (grep -v)
where {$_ -notmatch “SomeString”}

Powershell command to check Send-As Permissions

Find all users who have Full Access to the mailbox of others:

Get-Mailbox -ResultSize Unlimited | Get-MailboxPermission | ? {($_.AccessRights -match "FullAccess") -and 
not ($_.User -like "NT AUTHORITYSELF")} | ft Identity, User

Finding all users who have Send-As :

Get-Mailbox -Resultsize Unlimited | Get-ADPermission | ? {($_.ExtendedRights -like "*send-as*") -and -not
($_.User -like "nt authorityself")} | ft Identity, User -auto

Finding all users who have Send-As (Restricted to an OU):

Get-Mailbox -Resultsize Unlimited | Get-ADPermission | ? {($_.ExtendedRights -like "*send-as*") -and
($_.Identity -like "*/SomeOU/Users/*") -and -not ($_.User -like "nt authorityself")} | ft Identity, User -auto

Find out who a particular user can Send-As:

Get-Mailbox -Resultsize Unlimited | Get-ADPermission | ? {($_.ExtendedRights -like "*send-as*") -and -not
($_.User -like "nt authorityself") -and ($_.User -like "DOMAINUsernameUwantToFind")} | ft Identity, User -auto

How to move flatpress to SSL

Apart from all the Virtual Hosting and SSL certificates, you have probably found that it keeps redirecting you to the HTTP version.
What you need to change is the defaults.php file.

Change:

define('BLOG_BASEURL', 'http://'.$_SERVER['HTTP_HOST']. BLOG_ROOT);

to:

define('BLOG_BASEURL', 'https://'.$_SERVER['HTTP_HOST']. BLOG_ROOT);

and that should do it!

Delete Files Older than 90 Days with Powershell

Here is a powershell script that has been stolen, chopped up and modified.
Its logs the changes to Windows Event Viewer (because log files are so yesterday!) and removes files more than 90 days old from the directories specified.

# Script that deletes files older than 90 days in the E:Data directory.

Function Write-Log {
    [cmdletbinding()]

    Param(
    [Parameter(Position=0)]
    [ValidateNotNullOrEmpty()]
    [string]$Message
    )
	$evt=new-object System.Diagnostics.EventLog("Application")
	$evt.Source="Scans Directory Cleanup"
	$infoevent=[System.Diagnostics.EventLogEntryType]::Information
	$vdate=Get-Date
	$val="$Message"
	$evt.WriteEntry($val,$infoevent,2455) 

}

Function RemoveFilesAndDirs {

    Param(
    [Parameter(Position=0)]
    [array]$Paths,
    [Parameter(Position=1)]
    [ValidateNotNullOrEmpty()]
    [DateTime]$TargetDate
    )

    foreach ($path in $Paths){
        $files = (Get-ChildItem $path -recurse | where {$_.Lastwritetime -lt $TargetDate})
        Write-Log "Attempting to remove old files on $path"
        # Test if we are really moving files
        $re=0
        try {
            foreach ($file in $files){
                Write-Log ($file.fullname).ToString()
            }
        }
        catch [System.Management.Automation.RuntimeException] {
            $re = 1
            Write-Log "Nothing to delete"
        }
        if($re -ne 1){
            Get-ChildItem $path -recurse | where {$_.Lastwritetime -lt $TargetDate} | remove-item -recurse
        }
    }
}

$today = Get-Date -displayhint date
$targetdate = ($today.AddDays(-90))

$path = "E:/Data"
$directories = @("$path/temp","$path/scratch","$path/dev-temp","$path/rubbish")

Write-Log "Starting cleanup"
Write-Log "Files older than $targetdate will be deleted"

RemoveFilesAndDirs $directories $targetdate

Write-Log "*** Done ***"