Archive for January, 2017

Manage Office 365 User licenses with Powershell

January 13, 2017 Leave a comment

Install required Software first

  • Install the 64-bit version of the Microsoft Online Services Sign-In Assistant – LINK
  • Install the 64-bit version of the Windows Azure Active Directory Module for Windows PoweShell – LINK

PowerShell commands

# Import MSOnline Module

Import-Module MSOnline

# Connect to Office 365

$O365Cred = Get-Credential
Connect-MsolService -Credential $O365Cred

# Show Licenses


# View details about the Services that are available in all of your license plans

Get-MsolAccountSku | Select -ExpandProperty ServiceStatus

# Check which users have licenses

Get-MsolUser -All | fl DisplayName, UsageLocation,isLicensed,Licenses

# Check if a user has a license – Single

Get-MsolUser -UserPrincipalName "" | ft DisplayName, UsageLocation,isLicensed,Licenses

# Add a license – Single user

Set-MsolUserLicense -UserPrincipalName "" -AddLicenses "company:ENTERPRISEPACK"

# Remove a license – Single user

Set-MsolUserLicense -UserPrincipalName "" –RemoveLicenses "company:ENTERPRISEPACK"

# Bulk Add licenses

$Users = Import-Csv -Path "C:\Temp\licenses.csv"
foreach ($User in $Users)
    $UPN = $User.‘SamAccountName’ + ""
    Set-MsolUser -UserPrincipalName "$UPN" -UsageLocation "GB"
    Set-MsolUserLicense -UserPrincipalName "$UPN" -AddLicenses "company:ENTERPRISEPACK"

# Bulk check added licenses 

$Users = Import-Csv -Path "C:\Temp\licenses.csv"
foreach ($User in $Users)

    $UPN = $User.‘SamAccountName’ + ""
    Get-MsolUser -UserPrincipalName "$UPN" | ft DisplayName, UsageLocation, Licenses



How to recover sysadmin access to SQL Server 2012 when sa password is lost

January 12, 2017 Leave a comment
  1. Open the SQL Server Configuration Manager tool
  2. Navigate to SQL Server Services and Stop the SQL Server Instance that needs a sa password reset
  3. Right click the on the instance/service and select properties.
  4. Go to the “Startup Parameters” tab, and in the Specify a Startup Parameter text box write  “-mSQLCMD”, click Add and then click OK.
  5. Restart the SQL Server Instance  which will now be running in single-user mode

When the SQL Server Instance starts in single-user mode,  you can use the Windows Administrator account to connect to SQL Server using the sqlcmd utility and Windows authentication.

Connect to SQL Server using sqlcmd: sqlcmd –S.\SQLExpress

The following example adds the account “John” in the “EXAMPLE” domain to the SQL Server “sysadmin” role:

EXEC sp_addsrvrolemember ‘EXAMPLE\John, ‘sysadmin’;

Once the sysadmin access has been recovered, remove the “;-mSQLCMD” from the startup parameters using the Configuration Manager and restart the SQL Server Instance


Categories: Commands, Microsoft, SQL Tags: ,

Configure logs to be sent to External Syslog Server (Synology) using ESXi Web Host Client

January 10, 2017 Leave a comment

Step 1 – Add the external log server

Go to Manage > System > Advanced Settings and locate and edit settings.

Add the following: udp://

Step 2 – Configure Firewall rules to allow access to external syslog server.

Go to Host > Networking > Firewall Rules and locate syslog and edit settings:

Select Only allow connections from the following networks and enter the external syslog server.


Can’t import Windows 10 Pro WIM into MDT 2013 Update 2

January 9, 2017 Leave a comment

Here are the steps:

  • Download Microsoft Media Creation Tool.
  • Start the tool and select the option to create ISO files to install on another computer.
  • Once all is downloaded and the Tool allows you to press finish – DON’T
  • Check C:\ESD folder for files (as it should contain installx86.esd and installx64.esd)
  • Copy ESD folder to C:\TEMP
  • Convert the esd files to wim using the following command: dism /export-image /sourceimagefile:C:\$Windows.~WS\Sources\installx64.esd /SourceIndex:4
    /destinationimagefile:C:\install.wim /destinationname:"Windows 10 Pro x64" /compress:max /checkintegrity
  • Import the new WIM files to MDT 2013 Update 2