Month: May 2017

[Mac] Backup and restore Microsoft Office 2011 for Mac.

Referring to this article, we could move Office 2011 license from one Mac to another simply by copying a couple files. I had created 2 scripts to simplify the task.


cd ~/Desktop
mkdir OfficeLicense
mkdir OfficeLicense/$HOSTNAME
mkdir OfficeLicense/$HOSTNAME/LaunchDaemons
mkdir OfficeLicense/$HOSTNAME/PrivilegedHelperTools
mkdir OfficeLicense/$HOSTNAME/Preferences
cp /Library/LaunchDaemons/ ./OfficeLicense/$HOSTNAME/LaunchDaemons
cp /Library/PrivilegedHelperTools/ ./OfficeLicense/$HOSTNAME/PrivilegedHelperTools
cp /Library/Preferences/ ./OfficeLicense/$HOSTNAME/Preferences


The script would backup the necessary files to a folder called OfficeLicense on the Desktop. The files will be placed into Desktop/OfficeLicense\$HOSTNAME. Where $HOSTNAME will be the current Mac’s hostname.


cd ~/Desktop
cp ./OfficeLicense/$HOSTNAME/LaunchDaemons/ /Library/LaunchDaemons
cp ./OfficeLicense/$HOSTNAME/PrivilegedHelperTools/ /Library/PrivilegedHelperTools
cp ./OfficeLicense/$HOSTNAME/Preferences/ /Library/Preferences


Assuming that the Mac where you want to restore the license will be using the same hostname, place the folder on the Desktop and run






[Shoretel] Get Workgroup and user extension with login name

To get a list of Workgroup and user extension with login name, connect to the Shoretel Shoreware database and run the following SQL:

SELECT workgroupmembers.WorkgroupDN,workgroupmembers.UserDN,users.GuiLoginName FROM workgroupmembers INNER JOIN users ON workgroupmembers.UserDN=users.UserDN

[PowerShell] Export AD photo

Here is a PowerShell to export AD photo, please make sure you have the rights to do so before running the script. The script will prompt for the username and it will be saved as “username.jpg” under the path specify in $path variable.


$username = Read-Host 'Please enter Username'

$path = 'C:\Photos\'

$User=GET-ADUser $username –properties thumbnailphoto


[System.Io.File]::WriteAllBytes($Filename, $User.Thumbnailphoto)


[PowerShell] Retrieve temperature information for Nvidia display cards

Some Nvidia display cards has support for WMI such that you could retrieve the temperature information.

For more information, please check out NVIDIA Windows Management Instrumentation SDK

Below is the code for local computer, you can always change the $ComputerName variable to point to a remote computer. I had it probe for all instances of the ThermalProbe, you can comment that out and un-comment the last 3 lines for temperature only. The majority part of the code comes from Nvidia’s SDK examples, which you could download from the link above.

Please note, as I only have NVS cards, I had filled up $supportedModels with the NVS model I have.

$supportedModels= "NVIDIA NVS 290","NVIDIA NVS 295","NVIDIA NVS 300","NVIDIA NVS 310","NVIDIA NVS 315","NVIDIA NVS 420","NVIDIA NVS 450","NVIDIA NVS 510","NVIDIA Quadro NVS 450"

$video_card_name=(gwmi win32_videocontroller -ComputerName $ComputerName)|select-object -expand name
write-host $video_card_name

If($supportedModels|?{$video_card_name -match $_})

#Write-Host "True"
gwmi -ComputerName $ComputerName -Namespace root\CIMV2\NV gpu|select-object name,percent*

$namespace = "root\CIMV2\NV"
$classname = "ThermalProbe"
# For local system (e.g. "LocalHost", ".") '-computername $computer' could be omitted
# retrieve all instances of the ThermalProbe class and store them:
$probes =Get-WmiObject -class $classname -computername $ComputerName -namespace $namespace
# print all ThermalProbe instances
# iterate through all Probe instances
foreach( $probe in $probes )
#"Call the info() method and print all the data"
$res = $probe.InvokeMethod("info",$Null)
#"Query just the temperature"
#$temp = $probe.temperature

[Outlook] Search Results can’t be moved or Categorized and Categories column isn’t shown

When using Outlook 2016 with an Exchange account, setting flag or category on search result may not work. To fix the issue, please create and following key:

Key: HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Options\Search
Value name: DisableServerAssistedSearch
Value type: REG_DWORD
Value: 1

More details can be found in this article.

[PowerShell] Decommission user on AD with PowerShell

The following script will do the following:

1.prompt you to input the username to be decommission

2. remove all group while writing a backup of the group to a csv

3.Move the user to OU=Decommission,OU=USER,DC=company,DC=local

4. Set Description to “Left on $date”, where $date is current date

5. Disable the account


$date= Get-Date -Format dd/MM/yyyy
# Removes user from all AD groups except Domain Users.
$user = Read-Host 'Please enter Username'
Get-ADPrincipalGroupMembership $user | Get-ADGroup -Properties * | select name, description,GroupCategory|Export-Csv $user".csv" -NoTypeInformation
$ADgroups = Get-ADPrincipalGroupMembership -Identity $user | where {$_.Name -ne "Domain Users"}
Remove-ADPrincipalGroupMembership -Identity "$user" -MemberOf $ADgroups -Confirm:$false

Get-ADUser $user|Move-ADObject -TargetPath 'OU=Decommission,OU=USER,DC=company,DC=local'
Set-ADUser $user -Description "Left on $date"
Disable-ADAccount -Identity $user

Creating registry to make Outlook add-in to register on both 32 and 64 bit Office.

If you are writing an Outlook add-in and want it to be able to register itself with both 32 and 64 bit without creating 2 different setup files, you could edit the installer to put a registry key for both.

Below are the locations for the registry:


[PowerShell] Getting list of Windows 8 and 10 from AD with PowerShell

This example uses Get-ADComputer and -Filter to get a list of Windows 8 and 10 from AD.

Get-ADComputer -Filter {(OperatingSystem -LIKE "Windows 8*") -or (OperatingSystem -LIKE "Windows 10*")} -Properties *|Select name, operatingSystem, OperatingSystemVersion|Sort-Object OperatingSystemVersion -Descending|Out-GridView

Installing Security Update for Microsoft Windows through Dell Kace

I am taking KB4012212 as an example, as this is the patch that protects you from WannaCry/WannaCrypt on Windows 7.

Under Distribution, select Managed Installations and create a new installation.

  • Select Software
  • Search for “Security Update for Microsoft Windows (KB4012212)” under Software
  • Upload the associated file
  • Select “Override Default Installation” under “Installation Option”
  • Input “wusa.exe /quiet /norestart windows6.1-kb4012212-x64.msu” under “Full Command Line”
  • Check “Don’t Prepend msiexec.exe”


Get mailbox size for users in an OU in GB

Get the users of the OU to the variable $hkusers with UserPrincipalName and Department as column:

$hkusers=get-aduser -SearchBase "OU=HK,OU=User,DC=company,DC=com" -Filter * -Property Department|select UserPrincipalName, Department

Get the mailbox size of the users in GB:

$result=foreach($user in $hkusers){Get-MailboxStatistics -Identity $user.UserPrincipalName|Select displayName, @{Name="Department";Expression={$user.Department}},@{Name="Mailbox Size(GB)"; Expression={ [math]::Round( (( $_.TotalItemSize -replace "(.*\()|,| [a-z]*\)", "") )/1GB,2)}}}

Display the result in grid view: