Search This Blog

Monday, July 27, 2020

Windows 10 Display settings closes as soon as opened - Solved

Came across a very interesting issue, Windows 10 Enterprise 1903 (and 2004), cannot open display properties to change monitor settings. As soon as you right click on the desktop and hit Display settings, the application opens and closes right away. 
Going through Start > Settings > System > Display resulted in the same issue.
Bringing up display services through command line or a start search, resulted in the same issue.
This problem is not present in previous version of Windows 10, including LTSB. 
Windows 10 Enterprise 1909 did not have this problem as Microsoft fixed it.
Windows 10 Enterprise 2004 has the problem.

The only way to open the display properties is to login as the first created admin account on the system, no one else can open them.

After quite a bit of research and trying everything i can find online, opened a case with Microsoft and we found a solution. 

Microsoft has an internal article describing the problem that was introduced with version of Windows 10 1903, where display settings and other setting components try to pull data from "Connected Devices Platform Service" (CDPSvc) and "Network Connection Broker" (NcbService). 


In our environment the "Connected Devices Platform Service" was disabled. As soon as we set it to automatic and started, everything opened up successfully.

We have created a GPO that sets the service to automatic, and starts it.

Hopefully this helps people out.

Saturday, May 23, 2020

OneDriveStatus Central OneDrive Status Logs for Microsoft's Rodney Vianna ODSyncService/OneDriveLib.dll file

Good day,

Quite a few organizations are migrating to Office365 with OneDrive/SharePoint.

While there are many benefits to migrating, there are a few features that are lacking.

One such feature is the ability to know if a OneDrive client is actually synchronizing user data.

A nifty little dll has been developed by a Microsoft engineer Rodney Vianna


Also referenced on this site.

It is called OneDriveLib.dll
The file is fairly easy to use, however we still need a way to get central reporting.
This blog post is a solution to the problem.

The OneDriveStatus.ps1 script pulls the data from the OneDriveLib.dll and logs to a predefined path. The script utilizes the following known states of the dll error output: "NotInstalled", "ReadOnly", "Error", "OnDemandOrUnknown", if additional terms are known, just add into the $ErrorList array in the script.

OneDriveStatus.vbs launches the OneDriveStatus.ps1 script with the PowerShell window hidden.

The group policy copies the files to each user's machine and sets up a Scheduled Task that kicks off the script on a preset schedule.

Feel free to change the scripts and GPO to run over the network instead.

Both scripts and the dll should be placed on a read-only share accessible by domain users.

A sub-folder called "logs" with write/change access by users should be created inside of the share (or modify the script with any other location).

One final stage of the setup is the email notification script called OneDriveStatusNotification.ps1
Place this script in the same folder as the other scripts, and create a scheduled task on a server that is allowed to relay off an Exchange or any other email server.


NOTES/Concerns:
OneDriveLib.dll is a third party, open source dll. If Microsoft makes changes to OneDrive or Windows that stop the function of the dll, functionality may be limited until a newer version of the dll comes out and/or the script is adjusted to reflect the changes.
The script only checks for information available via OneDriveLib.dll, there is no other detailed synchronization information.
The script flickers the Windows Taskbar when executing. This flicker is caused by running Get-ODStatus, not related to the script itself.


SETUP INSTRUCTIONS:

Create a OneDriveStatus.ps1 file with the following code, and place it on a share users can read from.


1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# OneDriveStatus.ps1
# Alex Belenkiy © 2020
# ab@nyitsupport.com
# https://www.nyitsupport.com

$ErrorActionPreference = "SilentlyContinue"

Unblock-File 'C:\Software\OneDriveStatus\OneDriveLib.dll'
import-module 'C:\software\OneDriveStatus\OneDriveLib.dll'

$ErrorList = @("NotInstalled", "ReadOnly", "Error", "OndemandOrUnknown")

$ODStatus = ((get-ODStatus | ConvertTo-Json) | ConvertFrom-Json).value

$ODSError = 0
foreach ($ODS in $ODStatus) 
	{
		$ODErrors = "OneDrive Library '$($ODS.LocalPath)' state is '$($ODS.StatusString)'"
		if ($ODS.StatusString -in $ErrorList) 
		{
			remove-item -Path "\\SRV1\OneDriveStatus\Logs\$env:USERNAME - $env:COMPUTERNAME.healthy" 
			add-Content -Path "\\SRV1\OneDriveStatus\Logs\$env:USERNAME - $env:COMPUTERNAME.error" -Value $ODErrors
			$ODSError = 1
		}
		elseif ($ODSError -eq 0)
		{
			remove-item -Path "\\SRV1\OneDriveStatus\Logs\$env:USERNAME - $env:COMPUTERNAME.error" 
			add-Content -Path "\\SRV1\OneDriveStatus\Logs\$env:USERNAME - $env:COMPUTERNAME.healthy" -Value $ODErrors
			
		}
			
	}
	

Create a OneDriveStatus.vbs file in the same place. The vbs file prevents PowerShell from creating a popup window:


1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
' OneDriveStatus.vbs
' Alex Belenkiy © 2020
' ab@nyitsupport.com
' https://www.nyitsupport.com

Dim objShell
Set objShell=CreateObject("WScript.Shell")

strCMD="powershell -executionpolicy bypass -nologo -file " & "c:\software\OneDriveStatus\OneDriveStatus.ps1"

On Error Resume Next
objShell.Run strCMD,0

Set objShell = Nothing

Create a user Group Policy that copies the following files to the user's c:\software\OneDriveStatus directory. (This is optional, i just don't like pulling dll and script files across the network en-masse.)



OneDriveStatus.ps1

OneDriveStatus.vbs

OneDriveLib.dll


Create a "Scheduled Task (At least Windows 7)" in the GPO:




The OneDriveLib.dll causes the desktop and taskbar to flicker/refresh when it is executed. To avoid annoying users, set it to only run if idle for 1 minute.




This script will check each machine on a schedule and write a "UserName - ComputerName.Error" or a "UsersName - ComputerName.Healthy" depending on the resulting output form the OneDriveLib.dll

Create a OneDriveStatusNotification.ps1 file with the following content in the same folder as the other scripts.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# OneDriveStatusNotification.ps1
# Alex Belenkiy © 2020
# ab@nyitsupport.com
# https://www.nyitsupport.com

$ErrorActionPreference = "SilentlyContinue"

$ErrorFilesExist = test-path -path "c:\shares\OneDriveStatus\Logs\*.error"
if ($ErrorFilesExist)
{
	$SourcePath = "c:\shares\OneDriveStatus\Logs\"
	$newBody = ""
	$dir = Get-ChildItem -path $SourcePath -name -filter *.error -File

	$recipients = "CoolestAdmin@nyitsupport.com" ,"CoolAdmin@nyitsupport.com" # Change these
	
	$subject = "OneDriveStatus Notification: " + $dir.count + " Errors Detected"
		
	$body = ($dir|out-string).replace(".Error","") + "`r`n\\SRV1\scripts\OneDriveStatus\Logs" 
	
	foreach($i in $dir)
	{
		$a = $SourcePath + $i
		$nb = get-content $a -raw
		$newBody = $newBody + "`r`n" + $i.replace(".Error","") + "`r`n" + $nb + "`r`n"
	}		
	
	$newBody = $newBody + "`r`n\\SRV1\OneDriveStatus\Logs" 
	Send-MailMessage -SmtpServer 10.0.0.99 -From OneDriveStatusNotification@nyitsupport.com -To $recipients -Subject $subject -Body $NewBody # Change these
	
}

Create a scheduled task on a server (add it to the relay allow list on your mail server if required to email outside of company) that will be used to parse through the logs and send notifications.



Set a desired notification time, or create multiple email schedules.



Set the action to "Start a program" as follows:
Program/script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add arguments based on script location: -executionpolicy bypass -nologo -file c:\shares\OneDriveStatus\OneDriveStatusNotification.ps1



Enjoy, let me know if this helped you.

Also, stay tuned, i will be posting a new version that doesnt utilize the dll file soon.


Wednesday, October 17, 2018

RunOnce

This one will be familiar to every IT pro that has ever had to deploy something through Group Policy, when you dont have SCCM and have it only apply once, instead of at every start.

Here is a solution:


#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:   Alex Belenkiy © 2018
 Created:   09/21/2018
 Last Update:  09/24/2018

 Script Function:
 Run an install or a program only once
  To execute run as follows:
   RunOnce.exe "\\server\share\folder\file.exe" "/i /qn" "c:\program Files\RunOnce\test.txt"
   or
    RunOnce.exe "\\server\share\folder\file.exe" - "c:\program Files\RunOnce\test.txt"
#ce ----------------------------------------------------------------------------

if $CmdLine[0] <> 3 then Exit
$CommandFile = $CmdLine[1]
$Switches = $CmdLine[2]
if $Switches = "-" then $Switches = ""
$FlagFile = $CmdLine[3]
if FileExists ($FlagFile) then Exit
$a = RunWait(@ComSpec & " /c " & $CommandFile & " " & $Switches, @SystemDir, @SW_HIDE)
if @error then Exit

$File = FileOpen ($FlagFile, 10)
if @error then Exit
FileWriteLine($File,"RunOnce Executed")
FileClose($File)




If the file named by the third variable exists when the runonce.exe executes, the program will just exit. If the file does not exist, the first variable will be executed along with the switches passed in the second variable. Use a - for the second variable to specify no switches. Once the execution has completed, the file in the third variable will be created.

Enjoy and modify as needed :)

Friday, September 7, 2018

Chrome missing recently visited tiles

I have come across a strange issue with Chrome suddenly missing recently visited sites.

The issue can be resolved by typing the following into the address bar:
chrome://flags

Find the #use-google-local-ntp flag and enable it. Hit RELAUNCH NOW.



The tiles should be back now.

Came across this on REDDIT 

Wednesday, February 22, 2017

Dual boot Windows and Linux time offset

Good day,

long time no post.
I have come across an interesting fix for an annoying problem.

Issue:
If you dual boot Linux and Windows, every time you go into Windows after Linux, the time is wrong.
This is due to Linux using GMT while Windows trying to get the local time.

Fix: create the following DWORD value under 

HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
RealTimeIsUniversal 

and set it to 1
Reboot and problem solved.

Source: