Problems deleting a old mailbox database

I have a customer, where we have taken over the support from an old supplier, so we don’t know much about their background.

The first thing we do, was to update the Exchange Server.
But after have move all mailboxes, public folders, system mailbox.

I still got this error:

This mailbox database contains one or more mailboxes, mailbox plans, archive mailboxes, or arbitration mailboxes. To ge
t a list of all mailboxes in this database, run the command Get-Mailbox -Database <Database ID>. To get a list of all m
ailbox plans in this database, run the command Get-MailboxPlan. To get a list of archive mailboxes in this database, ru
n the command Get-Mailbox -Database <Database ID> -Archive. To get a list of all arbitration mailboxes in this database
, run the command Get-Mailbox -Database <Database ID> -Arbitration. To disable a non-arbitration mailbox so that you ca
n delete the mailbox database, run the command Disable-Mailbox <Mailbox ID>. To disable an archive mailbox so you can d
elete the mailbox database, run the command Disable-Mailbox <Mailbox ID> -Archive. Arbitration mailboxes should be move
d to another server; to do this, run the command New-MoveRequest <parameters>. If this is the last server in the organi
zation, run the command Disable-Mailbox <Mailbox ID> -Arbitration -DisableLastArbitrationMailboxAllowed to disable the
arbitration mailbox. Mailbox plans should be moved to another server; to do this, run the command Set-MailboxPlan <Mail
boxPlan ID> -Database <Database ID>.

Mailbox Plan is only used on the cloud.

I have look every places, unto i run this command:

dsquery * domainroot -attr * -limit 0 > result.txt

i then open the result.txt in notepad, and found some reference to the old database

msExchDisabledArchiveDatabaseLink: CN=Exch2013MB_Archive,CN=Databases,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=Fibia,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=XXXX,DC=local

After delete this reference, i could delete the database.

 

 

 

MSSQL Free Space in Databases files

To get a list of the databases files, and the current disk size in MB, and the Free Space in MB in each fil, you can use this commands

USE [DATABASE_NAME]

SELECT DB_NAME() AS DbName, 
name AS FileName, 
size/128.0 AS CurrentSizeMB, 
size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS INT)/128.0 AS FreeSpaceMB 
FROM sys.database_files;

If you need a overview of all yours database this TSQL can be used

CREATE TABLE #FileSize
(dbName NVARCHAR(128), 
    FileName NVARCHAR(128), 
    type_desc NVARCHAR(128),
    CurrentSizeMB DECIMAL(10,2), 
    FreeSpaceMB DECIMAL(10,2)
);
    
INSERT INTO #FileSize(dbName, FileName, type_desc, CurrentSizeMB, FreeSpaceMB)
exec sp_msforeachdb 
'USE [?]; 
 SELECT DB_NAME() AS DbName, 
        name AS FileName, 
        type_desc,
        size/128.0 AS CurrentSizeMB,  
        size/128.0 - CAST(FILEPROPERTY(name, ''SpaceUsed'') AS INT)/128.0 AS FreeSpaceMB
FROM sys.database_files
WHERE type IN (0,1);';
    
SELECT * 
FROM #FileSize
WHERE dbName NOT IN ('distribution', 'master', 'model', 'msdb');
    
DROP TABLE #FileSize;

Get a list of user and there Group Membership

This is how to get an CSV file, including user_SamAccountName;User_FullName;group1;group2;group3, etc

It posible to remove the comment before break, and then break the export after 5 user, to see that it function well.

It will first write it output at the ending of the script, so terminate it, will result in an empty file.

$user_count = 0
$output = ""
$OFS = "`r`n"
$users = Get-ADUser -Filter * -SearchBase "DC=dalbjerg,DC=local" | SELECT Name,samaccountname

foreach($user in $users) {
    #echo $user.SamAccountName
    $username = $user.SamAccountName
    $output += $username + ";" + $user.name + ";"
    $groups = Get-ADPrincipalGroupMembership $user.Samaccountname | select name
        foreach($group in $groups) {
            $output += $group.name + ";"
        }
    $output += $OFS
    $output += $OFS
    $user_count += 1
    if($user_count -eq 5) {
        #break
    }
}
Write-Output $output | out-file C:\temp\export.csv

 

Powershell: Copy IIS from a time range to a specific folder

I need to search for entry in logfiles between 3/8-2017 and 6/8-2017. So i make this powershell script to prevent search all IIS logfiles.

This script will copy all log files from the orginal IIS log path to a temp log directory, including the parent folder.

	$destination = "c:\temp\log\"
	$files = get-childitem "C:\inetpub\logs\LogFiles\" -Recurse | ? {$_.LastWriteTime -ge "08/02/2017" -and $_.LastWriteTime -le "08/06/2017"}
	Foreach($file in $files) {
		#Test to see if the file already exists in the destination. If not => Move/Copy/Action you want :D
		$directory = Split-Path (Split-Path $file.fullname -Parent) -Leaf
		new-item $destination"\"$directory -type directory
		Copy-Item -Path $file.fullname -Destination $destination"\"$directory

	}

Delete specific mail in Sophus Exim queu

To show the queue in sophus, from CLI type:

chroot /var/storage/chroot-smtp /bin/exim -bp

To delete a specific mail type

chroot /var/storage/chroot-smtp /bin/exim -Mrm {mailid}

example:

chroot /var/storage/chroot-smtp /bin/exim -Mrm 1daHZv-000EaR-0A

To see how many mails, there are in queue, you can type:

chroot /var/storage/chroot-smtp /bin/exim -bpc

Give access to calendar based on the user is member of the group.

If you need to give auser access to users calendar, based on if there are member of an group, this is the way.
Start Exchange Management Shell

$users = Get-ADGroupMember [groupname] | select -ExpandProperty name
foreach ($user in $users) {
    $Mailbox = Get-Mailbox $user
	#The Calendar, is name "Kalender" in danish
	add-MailboxFolderPermission -identity “$($Mailbox.Name):\kalender” -AccessRights Editor -User [username]
	set-MailboxFolderPermission -identity “$($Mailbox.Name):\kalender” -AccessRights Editor -User [username]

	#English calendar
	add-MailboxFolderPermission -identity “$($Mailbox.Name):\calendar” -AccessRights Editor -User [username]
	set-MailboxFolderPermission -identity “$($Mailbox.Name):\calendar” -AccessRights Editor -User [username]
} 

New Equallogic warning mail: Free space is below threshold of 15 percent for pool PoolName. Default Snapshot Schedule will run with max-keep set to 1

After an upgrade of our Equallogic SAN to version 8 or later, i get this warning everyday:
Free space is below threshold of 15 percent for pool PoolName. Default Snapshot Schedule will run with max-keep set to 1.

I have 5% left on my SAN, and dosen’t used Snapshot at all on it. It only contain backup data. No needs to take snapshot of Backup data :).
So i turn of this warning message by SSH to the Grp Management IP, and logon with username, grpadmin and my password for this account.

After login I run this command: grpparams default-snapshot-sched disable

This will disabled the schedule running at 00:00, that checks for this 15% free space left.

Install Linux OSCore OS – With static network address

When you start the Linux OS – OSCore, from the bootable ISO file, you will just the a prompt.
To Install it, i following these steps

First we needed to be root

sudo su

Then we setup the IP address of the server

ip addr add 192.168.1.1/24 dev eth0
ip link set dev eth0 up
ip route add default via 192.168.1.254

Then we set the root password, and create a user

passwd
useradd itadmin
passwd itadmin

Then you ssh to the CoreOS server.

Then we need to setup the DNS settings

su
cd /etc
rm resolv.conf
vim resolv.conf

Type these into resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4

We now need to setup the cloud-config-yaml file

cd /home/core/
vim cloud-config.yaml

Change the settings below so it fit you

#cloud-config
hostname: CoreOS_Name01
users:
- name: "YOURUSERNAME"
groups:
- "sudo"
- "docker"
ssh_authorized_keys:
- ssh-rsa YORESSSH-RSAKEY [email protected]
coreos:
units:
- name: static.network
content: |
[Match]
Name=eth0
[Network]
Address=192.168.1.1/24
Gateway=192.168.1.254
DNS=8.8.8.8
DNS=8.8.4.4

Then we just need to installed the CoreOS

coreos-install -d /dev/sda -C stable -c cloud-config.yaml
shutdown -h now

Remember after you have installed CoreOS, the username and password, and aslo the root password, will be lost.
You need to set this up in the Cloud-config file, if you for some reason will like static password after.

Unmount the CDROM from the server
Start the server again

Usefull things, about CoreOS, after you have installed it

cloud-config is located in /var/lib/coreos-install/user_data

if you need Boot Core os, with autologin. (If you for some reason can’t access the server though network).
Reboot the server, and press “e” in grup (Bootmenu) to edit the first boot option.
At the end of the line that begins with “linux$” add ” coreos.autologin=tty1″ (no quotes).
Press CTRL-X or F10 to boot. You will be logged in as “core” when the system boots.
And use sudo to become root

Move vSwitch vlans information from old host to a new one

To use this examples, there requirements are: VMware PowerCLI and a VMWare vCenter.

This example will copy all vlan’s (Virtualportgroup) from one host to another.
It will take all vlan’s from vSwitch0 on the old host, and copy it to the new host on vSwitch1.

connect-viserver
$oldhost = get-vmhost -name OldServerIP
$newhost = get-vmhost -name NewServerIP
 
$oldhost | get-virtualswitch -name vSwitch0 | get-virtualportgroup | foreach { $newportgroup = $newhost | get-virtualswitch -name vSwitch1 | new-virtualportgroup -name $_.Name -VLanID $_.VLanID }

 

Tomcat Web Server SSL Certificate Installation

How to generate a CSR in Tomcat with Keytool

Create a New Keystore

You will need to create a new Keystore, this is done by this command:

keytool -genkey -alias domainname.prefix -keyalg RSA -keysize 2048 -keystore /path/domainname.prefix.jks

When the commands ask for the firstname and lastname, please type domainname.prefix instead of you name, else the certificate will issues to you name, instead of the domain name.

Generate a CSR from Your New Keystore

  1. Next, you need to generate a CSR file, this is done by this command
    keytool -certreq -alias domainname.prefix -file certreq.cer -keystore /path/domainname.prefix.jks
  2. Type the keystore password that you chose earlier and hit Enter.
  3. Please upload the certreq.cer, to you standard certificate supplier.

Installing the SSL Certificates to the Keystore

  1. You will then get a certificate, save it as signcert.cer
  2. Download aswell the correct intermediate certificate, aswell as the correct root certificate.
  3. Import them with this command:
    keytool -import -trustcacerts -alias root -file root.cer -keystore /path/domainname.prefix.jks
    
    keytool -import -trustcacerts -alias intermediate -file intermediate.cer -keystore /path/domainname.prefix.jks
  1. Import the signed certificate
    keytool -import -trustcacerts -alias domainanme.prefix -file signcert.cer -keystore /path/domainname.prefix.jks

Configuring your SSL Connector

Before Tomcat can accept secure connections, you need to configure an SSL Connector.

  1. In a text editor, open the Tomcat server.xml file.
    The server.xml file is usually located in the conf folder of your Tomcat’s home directory.
  1. Locate the connector that you want to use the new keystore to secure.
    Usually, a connector with port 443 or 8443 is used, as shown in step 4.
  1. If necessary, uncomment the connector.
    To uncomment a connector, remove the comment tags (<!– and –>).
  1. Specify the correct keystore filename and password in your connector configuration.

When you are done, your connector should look something like this:

<Connector port="443" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" disableUploadTimeout="true" acceptCount="100" scheme="https" secure="true" SSLEnabled="true"clientAuth="false" sslProtocol="TLS" keyAlias="server" keystoreFile="/path/domainname.prefix.jks " keystorePass="your_keystore_password" />

Note: If you are using a version of Tomcat prior to Tomcat 7, you need to change “keystorePass” to “keypass”.

  1. Save your changes to the server.xml file.
  2. Restart Tomcat.