2015. május 27., szerda

"Verbose" event logging in Windows

The behavior that my Windows 2008 Network Policy Server (aka Radius Server) did not log the successfully authorized usernames always bothered me. Fortunately there is a way to get that stupid habit to work as expected.
Open an elevated command promt and type this to get a list of your event categories and their subcategories:
Auditpol /list /subcategory:* /r  (optional)

Then type: (note that category name strings are localized!)
Auditpol /set /subcategory:"Network Policy Server" /success:enable /failure:enable  
and... backup your policy(ies):
Auditpol /backup /file:C\mypolic.csv  (optional)

Another method to log both Event 6273 and 6279 could be done via a GPO:
Computer Configuration -> Policies -> Windows Settings -> Security Settings -> Advanced Audit Policy Configuration -> Audit Policies -> Logon/Logoff -> Audit Network Policy Server (set both success and failure to enable). Don't forget to gpupdate /force.

Further reading here.

2015. május 20., szerda

Querying Exchange quota limits in Powershell

Get-mailbox | where {$_.UseDatabaseQuotaDefaults -ne $true} 

Get-MailboxDatabase | Get-MailboxStatistics | Where-Object {$_.StorageLimitStatus -match 'BelowLimit|IssueWarning|ProhibitSend|MailboxDisabled'} 

Get-mailbox | get-mailboxstatistics | sort-object totalitemsize –descending | ft displayname,totalitemsize

Get-PublicFolder -Recurse -ResultSize Unlimited  | Get-PublicFolderStatistics -Server <exchange> | Select FolderPath, ItemCount, TotalAssociatedItemSize, TotalDeletedItemSize, TotalItemSize | fl Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object DisplayName,StorageLimitStatus,TotalItemSize -First 100  | Sort-Object TotalItemSize

Set-Mailbox <mailbox> -UseDatabaseQuotaDefaults $false -IssueWarningQuota 8GB -ProhibitSendQuota 8.5GB


Get-PublicFolder "\" -Recurse -resultsize unlimited| Get-PublicFolderStatistics -Server <server> | Select FolderPath, ItemCount, TotalAssociatedItemSize, TotalDeletedItemSize, TotalItemSize | fl

2015. május 4., hétfő

Windows 2008 Server R2 hangs on "Preparing to configure Windows. Do not turn off your computer"

Last night I started installing updates on a Windows 2008 R2 box but when I had my dinner and returned to my computer I got pissed off seeing the server stalled at
and I could not RDP into the OS. I spent ca. half an hour waiting for something to happen, then, made a short google search. It turned out that if I connected to this OS via the services.msc console of an other server being in the same domain network I could see that WINDOWS MODULES INSTALLER Service was stuck in Stopping state.
Using the built-in Sysinternals utils:
taskkill /S hostname /IM trustedinstaller.exe
or
sc \\computername queryex TrustedInstaller
taskkill /s computername /pid /f
...I could have been able to terminate that task. According to some internet records if I had done so, my server would have restarted without a hitch. Luckily enough, after entertaining me for more than one hour (-meanwhile actualy doing nothing-) this damn server finally restarted by itself! After the reboot it installed the updates and got ready in less than 5 minutes.
So, in case you are here because you are in the same business as I was, now you'd better have some coffee and wait patiently instead of roughly interfere.