PS: Get last logon time on exchange

To get the last logon time for a user in exchange use the following powershell script:

Get-MailboxStatistics -identity "Joe smith" | select-object displayname, lastlogontime

If you want to see the lastlogontime for all users in a Distribution group, use the following powershell script:

 

$usergroup = Get-DistributionGroupMember -identity "DL name" -domaincontroller dcname

foreach ($user in $usergroup) { Get-MailboxStatistics -identity $user.samaccountname | select-object displayname, lastlogontime}

 

Powershell: Enable Remote Desktop on a Windows 2012 machine

Run the following Powershell commands to enable remote desktop.

#Enable Remote Desktop
Invoke-Command -computername localhost -scriptblock {(gwmi -class win32_terminalservicesetting -namespace "root\cimv2\terminalservices").setallowtsconnections(1)}

#Configure Firewall for Remote Desktop
Invoke-command -computername localhost -scriptblock {netsh advfirewall firewall set rule group="remote desktop" new enable=Yes }