Friday, February 13, 2015

Windows Server time sync command cheat sheet, How to connect to Office 365 via Powershell

Sync server with external time source:

w32tm /config /syncfromflags:manual /manualpeerlist:pool.ntp.org  

w32tm /config /reliable:yes

net stop w32time
net start w32time

Sync server with AD controller:

w32tm /config /syncfromflags:domhier /update

net stop w32time
net start w32time

Sync with replacement AD controller:

w32tm /resync /rediscover

Partially disable time sync with hyper-v host on AD controller:


reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\VMICTimeProvider /v Enabled /t reg_dword /d 0 

net stop w32time
net start w32time

Check time sync status and configuration:

w32tm /query /configuration
w32tm /query /status
w32tm /query /source



Reset Time Service to default values:


net stop w32time
w32tm /unregister
w32tm /register
net start w32time



Reset Time Zone on Azure VM


  • In Powershell Admin type "get-timezone" to display current time zone
  • Type Get-TimeZone -ListAvailable | where ({$_.Id -like "Pacific*"}) to list time zones that start with "Pacific". Use a different variable if you are looking for time zones outside the Pacific
  • Type Set-TimeZone -Id "Pacific Standard Time" to change time zone to PST. Use a different variable for time zones outside the Pacific.



Transfer FSMO roles via Powershell

Run the command below on the server the roles are being transferred to.

Move-ADDirectoryServerOperationMasterRole -Identity "Target AD" –OperationMasterRole PDCEmulator,RIDMaster,InfrastructureMaster,SchemaMaster,DomainNamingMaster

If the above does not work, or generates an error message, run "netdom query fsmo" to see if any roles have transferred. You may find that some have transferred, while others have not. If so, you can individually transfer over the remaining roles one at a time using the same command as above, but only including the missing roles after -OperationMasterRole

ex. Move-ADDirectoryServerOperationMasterRole -Identity "Target AD" –OperationMasterRole SchemaMaster


Connecting to Office 365 via Powershell

https://activedirectorypro.com/powershell-connect-to-office-365/

If you get an authentication failure when running connect-msolservice run this command:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12


FORCE DELTA SYNC ON AD CONNECT SERVER

Start-ADSyncSyncCycle -PolicyType Delta


Disconnect from MSOLService

[Microsoft.Online.Administration.Automation.ConnectMsolService]::ClearUserSessionState()