29 October 2017

Search message tracking logs in Exchange 2013+

Because having a GUI would be too easy, use the EMC to search message logs in recent versions of Exchange.

An example of searching for emails from bill@microsoft.com, from 25 Oct 2016 to 27 Oct 2016, outputting to a file:

Get-MessageTrackingLog -ResultSize Unlimited -Start "10/25/2016" -End "10/27/2016" -Sender "bill@microsoft.com" | Select-Object Timestamp,SourceContext,Source,EventId,MessageSubject,Sender,{$_Recipients} | Export-CSV C:\temp\MessageLogResults.txt

(Note that sometimes Microsoft ignores your regional settings and forces you to use the United States date notation.)

It's also the only want to search using a wildcard in older versions of Exchange.

Check for Windows Updates using PowerShell

Windows 10 seems to hide the GUI option to check for updates if it found updates last time. Tell it to recheck using PowerShell:

(New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow()

Get list of AD users with no lastLogonTimestamp value

Retrieve a list of AD users that don't have a 'last logon' timestamp attribute value:

Get-ADUser -f {-not ( lastlogontimestamp -like "*") -and (enabled -eq $true)} |ft Name, DistinguishedName

17 August 2017

View and remove Where From file metadata on Mac

When downloading a file on macOS, metadata may be added to the file that specifies where the file was downloaded from. This can be seen in the file's Info window:

It can also be viewed from Terminal with:

xattr -lp com.apple.metadata:kMDItemWhereFroms nameoffile.dmg

You can also use the following command to list files in a directory that have various metadata:

ls -l@

To remove the metadata, run the following in Terminal:

xattr -d com.apple.metadata:kMDItemWhereFroms nameoffile.dmg

Ta, robmathers.

31 December 2016

Set ImmutableID for Office 365 user

From the Azure Active Directory command line:

Set-MsolUser -UserPrincipalName "joe@bloggs.com" -ImmutableId "123xyz"

Set to null:

Set-MsolUser -UserPrincipalName "joe@bloggs.com" -ImmutableId "$null"

24 March 2016

If you expect an answer, Microsoft, ask a fucking question.

20 March 2016

List Exchange users that are (or have) delegates

Use this command:

ldifde -f delegates.txt -d "ou=Users,dc=domain,dc=com" -l name,publicDelegates,publicDelegatesBL -r "(|(publicDelegates=*)(publicDelegatesBL=*))"

Cheers, William Lefkovics.

Check progress of PST imports in Office 365

First, get the RequestGUID for the import request (because the ImportRequest name is different from the RequestGUID, even though they look similar):

Get-MailboxImportRequest | ft Mailbox,RequestGUID

Then get the detailed report on that import:

Get-MailboxImportRequestStatistics -Id (The RequestGUID) -IncludeReport |fl

Empty Recycle Bin for all users

From an elevated command prompt:

rd /s c:\$Recycle.Bin

Enable remote administration access from the command line

For tools that use WMI/RPC/DCOM.

netsh advfirewall firewall set rule group="Windows Remote Management" new enable=yes

Remotely log off users

Check the sessions on a remote server:

qwinsta /server:myservername

Kill the session with ID "4":

rwinsta 4 /server:myservername

Access the Exchange Admin Center for Office 365 Small Business

Because Microsoft couldn't be bothered putting a link to it in the Small Business GUI:


19 March 2016

Set Windows proxy settings at the system level

Check the current proxy settings:

netsh winhttp show proxy

Set the proxy settings (bypassing local addresses):

netsh winhttp set proxy myproxyserver:8080 "<local>"

Reset/remove the proxy settings:

netsh winhttp reset proxy

Change SID of Server 2012 R2 machine

If you've cloned a Windows Server 2012 R2 machine, you may need to change its SID:

  1. C:\Windows\System32\Syprep\sysprep.exe - Run As Administrator.
  2. Select "Enter System Out-of-Box Experience (OOBE)", tick "Gereralize", select "Reboot", click OK. The server will restart.
  3. After reboot, follow the Settings wizard.
  4. Set the server's static IP address again, if necessary.

Ta, M Hamizi.

Connect PowerShell to Office 365

Connect to Office 365 (MSOL) PowerShell:

  • $UserCredential = Get-Credential
  • Connect-MsolService -Credential $UserCredential

Connect Remote Exchange PowerShell for O365:

  • $UserCredential = Get-Credential
  • $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
  • Import-PSSession $Session

       Once finished, remove your session:

  • Remove-PSSession $Session

10 March 2016

Fix broken trust relationship without rejoining domain

To fix the seemingly-random "The trust relationship between this workstation and the primary domain failed" error, you can remove the PC from the domain, then re-add it. Sometimes doing this is a PITA.

You can often fix the error using netdom.exe with the below steps. You can do it through your remote access utility, or by logging in as a local administrator.

  1. Extract netdom.exe and netdom.exe.mui from the Remote Server Administration tools. Or grab them from a machine that already has the tools installed.
  2. Put netdom.exe in C:\Windows\System32\ , and netdom.exe.mui in C:\Windows\System32\en-US\ , on the broken PC.
  3. Run the following command on the broken PC:

    netdom.exe resetpwd /s:myserver /ud:MYDOMAIN\adminuser /pd:(adminpassword)

    (Where "myserver" is your domain controller, "MYDOMAIN\adminuser" is a domain administrator, and "adminpassword" is the domain administrator's password.)

Enable file and print sharing from the command line

Run this command on the remote computer to enable file and print sharing (all one line):

netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes

15 November 2015

Use Adobe CS5 applications without Java on OS X

Using OS X, opening the Adobe CS5 applications may prompt you to install Java 6. To bypass this prompt without installing Java, make sure both these directories exist:


You can create them via Terminal using the following commands:

sudo mkdir -p /System/Library/Java/JavaVirtualMachines/1.6.0.jdk
sudo mkdir -p /System/Library/Java/Support/Deploy.bundle

Thanks to Michael Stassen.

19 July 2015

Reset album artwork cache in Sony Music app

Sometimes the Sony Music app gets confused and displays incorrect album art. Using the File Commander app, reset the cache by deleting these two folders:


FFmpeg commands

To convert an MKV to MP4:

C:\Program Files\WinFF\ffmpeg.exe -i input.mkv -c copy output.mp4

To extract the audio from an MP4:

C:\Program Files\WinFF\ffmpeg.exe -i use-audio.mp4 -vn -acodec copy audio.mp4

To replace the audio in an MP4:

C:\Program Files\WinFF\ffmpeg.exe -i use-video.mp4 -i audio.mp4 -vcodec copy -acodec copy -map 0:0 -map 1:0 output.mp4