ADUC properties – Displaying and changing user’s hidden properties with powershell

It is not so obvious how to display/change some properties like “ipphone”, because they are not shown in Get-QADUser.

To display hidden properties of user like”ipphone” number we can use the command:

get-qaduser -IncludeAllProperties ipphone

Changing this property we can do like this:

set-qaduser -objectAttributes @{ipphone=”666″}

ADUC properties – Home Directory folder mapped on the letter “B”

As you can notice, when you try to map “Home Directory” folder on the letter “B”, there is no possibility for doing this from ADUC’s user properties window:

The resolution for this is making that change using powershell:

Set-QADUser test.test -HomeDrive “B:”

Or using dsmod:

dsmod user “CN=Test Test,OU=people,DN=domain,DN=pl” -hmdrv “B:”

After that operation, the field that is responsible for “Home Directory” drive will be left blank, despite of that you will be able to see that setting in powershell:

The Home Directory folder should now be mapped on “B” letter.

Powershell / Exchange 2007 – sum in MB of all mailboxes, deleted elements, .edb file and white spaces for a storage group

Some time ago, I had a need to determine some of storage groups parameters from Exchange 2007, that need become more frequent than I thought, and here is that script.

The script wll return those values like in 3th line of it, so there will be: Storage group name, sum of all mailboxes (in megabytes), sum of all deleted items (in megabytes), size of the *.edb database file, and the amount of white space in each storage group.

$data = Get-Date –f "yyyy-MM-dd";
$MailboxServer = "Here enter the name of your mailbox server"
out-file -filepath StorageGroupsReport_$data.txt -append -inputobject "Storage GRoup Name ($elem);Sum for all mailboxes (MB) ($suma);Sum of all deleted elements (MB) ($sumdel);Database file size (MB) ($sumadb);Sum of White Space (MB) ($SG_WS)"

foreach ($elem in Get-MailboxDatabase){
	$SG_MB = (Get-Mailbox -ResultSize Unlimited -Database "$elem" |  get-mailboxstatistics  | measure-object totalitemsize -sum)
	$suma = "{0:N2}" -f ($SG_MB.sum / 1MB)

	$SGdel_MB = (Get-Mailbox -ResultSize Unlimited -Database "$elem" |  get-mailboxstatistics  | measure-object totaldeleteditemsize -sum)
	$sumadel = "{0:N2}" -f ($SGdel_MB.sum / 1MB)

	$SGDB_MB = (Get-MailboxDatabase "$elem" | foreach-object {add-member -inputobject $_ -membertype noteproperty -name mailboxdbsizeinGB -value ([math]::Round(([int64](get-wmiobject cim_datafile -computername $_.server -filter ('name=''' + $_.edbfilepath.pathname.replace("\","\\") + '''')).filesize / 1mb),2)) -passthru}  | measure-object mailboxdbsizeinGB -sum)
	$sumadb = "{0:N2}" -f ($SGDB_MB.sum)

	$dt = $
	$s = (get-eventlog Application -ComputerName $MailboxServer -instanceID 1074136261 -Message "*$dt*" -newest 1 | select -expand message )
	$d = ($s.IndexOf(" megabytes") - $s.IndexOf("`has "))
	$SG_WS = ($s.Substring($s.IndexOf("has "),$d).trim("has "))
	out-file -filepath StorageGroupsReport_$data.txt -append -inputobject "$elem;$suma;$sumadel;$sumadb;$SG_WS"