Tuesday 24 November 2015

Moving SUSDB.MDF to another drive

Stop the services locking the SUSDB open

net stop "update services"
net stop "w3svc"

Use SQLCMD to drop the database.

sqlcmd -E -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -Q "sp_detach_db 'SUSDB'"

Use xcopy to move the SUSDB.mdf and SUSDB_LOG.ldf to the D:\

Reattach the database

sqlcmd -E -S np:\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query -Q "sp_attach_db @dbname=N'SUSDB',\
       @filename1=N'D:\WSUS\SUSDB\SUSDB.mdf',\
       @filename2=D'D:\WSUS\SUSDB\SUSDB_log.ldf'"

Start the services

net start "update services"
net start "w3svc"

Wednesday 18 November 2015

Protecting AD OUs from accidental deletion

Before carrying out an AD migration I always like to the the best practice analysers. 9 times out of ten these days we see that the BPA warns that all OUs should be protected against accidental deletion.


You can use the simple line of PoSh to protect all OUs and eradicate the BPA warning.

Get-ADOrganizationalUnit -filter * -Properties ProtectedFromAccidentalDeletion | where {$_.ProtectedFromAccidentalDeletion -eq $false} | Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion $true