Archive

Author Archive

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

Get-MsolAccountSku

# 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 "user.name@domain.com" | ft DisplayName, UsageLocation,isLicensed,Licenses

# Add a license – Single user

Set-MsolUserLicense -UserPrincipalName "user.name@domain.com" -AddLicenses "company:ENTERPRISEPACK"

# Remove a license – Single user

Set-MsolUserLicense -UserPrincipalName "user.name@domain.com" –RemoveLicenses "company:ENTERPRISEPACK"

# Bulk Add licenses

$Users = Import-Csv -Path "C:\Temp\licenses.csv"
foreach ($User in $Users)
{
    $UPN = $User.‘SamAccountName’ + "@zhgplc.com"
    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’ + "@zhgplc.com"
    Get-MsolUser -UserPrincipalName "$UPN" | ft DisplayName, UsageLocation, Licenses
}

 

-Eric

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’;
GO

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

-Eric

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 Syslog.global.logHost and edit settings.

Add the following: udp://SERVER.domain.com:514

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.

-Eric

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

-Eric

The Active Directory integrated DNS zone _msdcs.domain.com was not found

November 22, 2016 Leave a comment

I did not discover this fix. I found this from TechNet forums but have since lost the link.

The fix below helped me resolve this problem.

Problem:
The Active Directory integrated DNS zone _msdcs.domain.com was not found.

Solution:

  • Create a zone called "_msdcs.domain.com"
  • Make it AD integrated
  • Allow secure only updates and Click Finish
  • Go back into the zone properties
  • Change the replication scope to "All DCs in the Forest"
  • Delete the _msdcs folder under domain.com
  • Run an ipconfig /registerdns
  • stop netlogon
  • start netlogon
  • The SRVs should populate shortly, if they already haven’t

Credit goes to users on TechNet Forums.

-Eric

PowerShell – Search any User on Active Directory–updated

November 21, 2016 Leave a comment

Below is an updated script that helps you find any user in AD with details like when the User object was created, modified, lockout time, bad password time, last logon etc.

$user = Read-Host "Enter the name of the user"
Get-ADUser -Filter "sAMAccountName -like ‘*$user*’" |
Get-ADObject -Properties * | fl Name,SamAccountName,UserPrincipalName,DistinguishedName,objectSID,Title,Department,telephoneNumber,` Created,Modified,lockoutTime,`
@{n=’accountExpires’;e={[DateTime]::FromFileTime($_.accountExpires)}},`
@{n=’LastLogon’;e={[DateTime]::FromFileTime($_.LastLogon)}},`
@{n=’badPasswordTime’;e={[DateTime]::FromFileTime($_.badPasswordTime)}},`
@{n=’pwdLastSet’;e={[DateTime]::FromFileTime($_.pwdLastSet)}},`
msExchWhenMailboxCreated

-Eric

VMware – Commands to power on VMs from command line

November 10, 2016 Leave a comment

ESXi 5.x and 6.0

List the inventory ID of the virtual machine with the command:

vim-cmd vmsvc/getallvms | grep <vm name>

Note: The first column of the output shows the vmid.

Check the power state of the virtual machine with the command:

vim-cmd vmsvc/power.getstate <vmid>

Power-on the virtual machine with the command:

vim-cmd vmsvc/power.on <vmid>

ESX 4.0 and ESX 4.1

To list the path of all the virtual machines on the host:

vmware-cmd –l

Get the state of the virtual machine with the command:

vmware-cmd <path to the VMX file> getstate

Power on the virtual machine with the command:

vmware-cmd <path to the VMX file> start
    
-Eric