Update Synology Mail Plus spam server more than once a day.

Update Synology Mail Plus spam server more than once a day

Just found the scripts that you can run and schedule to run more often than once a day. And if you run ClaimAV as virusscanner.

Run the following scripts.

bash /volume1/@appstore/MailPlus-Server/scripts/SpamRuleUpdate.sh all
bash /volume1/@appstore/MailPlus-Server/scripts/SpamAutoLearn.sh
bash /volume1/@appstore/AntiVirus/scripts/clamav.sh check_update

AD Send mail on password reset

This is based on Security Event ID 4724. When this is logged on the domain controller, Task Scheduler kicks this script. And send a mail to Admin and user. And also creates a local log file who reset the password.

# Created by Daag van der Meer on 12-10-2018
# Blog.van-daag.nl
# Powershell Send mail When account password reset is done To user and admin.
# Save this also in a Log file
 
##################
## Temp location for creating HTML email
##################
$Report= "c:\Temp\reset.html" 

##################
## Log location
##################
$log= "C:\Logs\Accountreset.csv"
 
$HTML=@" 
<title>Account locked out Report</title> 
<!--mce:0--> 
"@ 

##################
## Retrieve eventlog with all value
##################

$event = Get-EventLog -LogName Security -InstanceId 4724 -Newest 1 |
 Select TimeGenerated, ReplacementStrings |
  % { 
     New-Object PSObject -Property @{ 
      "Account name" = $_.ReplacementStrings[0] 
      "Account Domain" = $_.ReplacementStrings[1] 
      "Reset by" = $_.ReplacementStrings[4] 
      Date = $_.TimeGenerated 
    } 
   } 

##################
## Retrieve eventlog For filter username
##################

$userevent= Get-EventLog -LogName Security -InstanceId 4724 -Newest 1 | Select-Object @{n='UserName';e={$_.ReplacementStrings[0]}}
$user= $userevent -replace ".*=" -replace "}"

##################
## send mail to admin
##################


$event | ConvertTo-Html -Property "Account name","Account Domain","Reset By",Date -head $HTML -body  "<H2> User account password is reset</H2>"| 
     Out-File $Report -Append 

##################
## Mail config admin
##################

$MailBody= Get-Content $Report 
$MailSubject= "User password reset" 
$SmtpClient = New-Object system.net.mail.smtpClient 
$SmtpClient.host = "<MAIL SERVER>" 
$MailMessage = New-Object system.net.mail.mailmessage 
$MailMessage.from = "<FROM MAILADRESS>" 
$MailMessage.To.add("<MAILADRESS>") 
$MailMessage.Subject = $MailSubject 
$MailMessage.IsBodyHtml = 1 
$MailMessage.Body = $MailBody 
$SmtpClient.Send($MailMessage) 

del c:\Temp\reset.html
$event | Export-Csv $log -NoTypeInformation -Append


#############################
### Send mail to user #######
#############################

$useremail = Get-ADUser $user -Properties mail | Select-Object -ExpandProperty mail
$userfirstname1 = Get-ADUser $user -Properties GivenName | Select-Object GivenName
$userfirstname = $userfirstname1 -replace ".*=" -replace "}"
$userlastsname1 = Get-ADUser $user -Properties Surname | Select-Object Surname
$userlastsname = $userlastsname1 -replace ".*=" -replace "}"

$Pic = '<ADD LOCATION FOR PICTURE IN MAIL>'

$att1 = new-object Net.Mail.Attachment($Pic)
$att1.ContentType.MediaType = “image/png”
$att1.ContentId = “Attachment”

##################
## HTML mail setup to user
##################

$userBody = @"
<html>
    <body>
    <span lang=NL style='font-size:10.0pt;line-height:106%;color:black'>
Dear $userfirstname $userlastsname,<br>
<br>
The password for your <b>DOMAIN\$user</b> account has been reset.<br>
If you did not request this, please inform:<br>
<br>
This is an automated email.<br>
<br>
</span>
<img src="cid:Attachment">
"@

##################
## Mail config user
##################

$userSubject = "Your password is changed"
$userMessage = New-Object system.net.mail.mailmessage 
$userMessage.from = "<FROM MAILADRESS>"
$userMessage.To.add("$useremail")  
$userMessage.Subject = $userSubject  
$userMessage.IsBodyHtml = 1
$userMessage.Body = $userBody 


$userMessage.Attachments.Add($att1)


$SmtpClient.Send($userMessage)

 

AD Send mail on Account Lock

At a company where I worked, there was no logging with account lock and the had plans to change the GPO that accounts will not be auto unlocked.
So I also added mailing to the admin of that specific OU (Country)

I found a script from Maxzor1908 on Technet
That was the basic. I Added a lot of extra.

# Powershell User Account locked out Maxzor1908 *16/4/2013* 
# Checked and edit by Daag van der Meer - 03-10-2018
# blog.van-daag.nl
#              Email adress needs to be filled in at the admin account.
 
##################
## Temp location for creating HTML email
##################
$Report= "c:\Temp\Lockedhtml.html" 

##################
## Log location
##################
$log= "C:\Logs\AccountLocked.csv"
 
$HTML=@" 
<title>Account locked out Report</title> 
<!--mce:0--> 
"@ 
 
$Account_Name = @{n='Account name';e={$_.ReplacementStrings[-1]}} 
$Account_domain = @{n='Account Domain';e={$_.ReplacementStrings[-2]}} 
$Caller_Computer_Name = @{n='Caller Computer Name';e={$_.ReplacementStrings[-1]}} 
 
##################
## Retrieve eventlog with all value
##################

             
$event= Get-EventLog -LogName Security -InstanceId 4740 -Newest 1 | 
   Select TimeGenerated,ReplacementStrings,"Account name","Account Domain","Caller Computer Name" | 
   % { 
     New-Object PSObject -Property @{ 
      "Account name" = $_.ReplacementStrings[-7] 
      "Account Domain" = $_.ReplacementStrings[5] 
      "Caller Computer Name" = $_.ReplacementStrings[1] 
      Date = $_.TimeGenerated 
    } 
   } 
    
  $event | ConvertTo-Html -Property "Account name","Account Domain","Caller Computer Name",Date -head $HTML -body  "<H2> User is locked in the Active Directory</H2>"| 
     Out-File $Report -Append 
 

##################
## Retrieve eventlog For filter username
##################


 $user= Get-EventLog -LogName Security -InstanceId 4740 -Newest 1 | 
   Select ReplacementStrings | 
   % { 
     New-Object PSObject -Property @{ 
      "Account name" = $_.ReplacementStrings[-7] 
      } 
   } 

$userrename = $user -replace ".*=" -replace "}"
$userou = Get-ADUser $userrename -Properties DistinguishedName | Select-Object -ExpandPropert DistinguishedName

##############################
## Here is the ad Groups configured who can unlock accounts
#############################
 

if ($userou.Contains('OU=<OU>')) {$mail = "<AD GROUP>"}

elseif ($userou.Contains('OU=<OU>')) {$mail = "<AD GROUP>"}

else {$mail = "<AD GROUP>" }

$adminmail = Get-ADGroupMember $mail | select samaccountname | %{Get-ADUser $_.samaccountname -Properties mail} | %{write-output "$($_.mail)"}
$mailadmin =  $adminmail -join "," -replace ",,"

##################
## Mail config admin
##################


$MailBody= Get-Content $Report 
$MailSubject= "User Account locked out" 
$SmtpClient = New-Object system.net.mail.smtpClient 
$SmtpClient.host = "<MAIL SERVER>" 
$MailMessage = New-Object system.net.mail.mailmessage 
$MailMessage.from = "<FROM MAIL ADRESS>" 
$MailMessage.To.add("<TO MAIL ADRESS>,$mailadmin") 
$MailMessage.Subject = $MailSubject 
$MailMessage.IsBodyHtml = 1 
$MailMessage.Body = $MailBody 
$SmtpClient.Send($MailMessage) 


##################
## Remove the temp document
##################
del c:\Temp\Lockedhtml.html

##################
## Write to log about the account lock
##################

$event | Export-Csv $log -NoTypeInformation -Append

AD Change Display name

At the company were I worked we had a name change. They also use the display name in outlook to send mail. Example: Daag van der Meer [Company] So everyone see direct what the company is.

The script below built the display name with firstname lastname [Company]

# Script created by Daag van der Meer
# Blog.van-daag.nl

Import-Module ActiveDirectory

#creates a list of all users (change all between <>
$allUsers = Get-ADUser -Filter * -SearchBase 'ou=Users,ou=<OU>,DC=<DC>,DC=<DC' -Properties cn,displayName

 
# Add your company name or something else after username 
$hi = "<company>"

 

foreach ( $u in $allUsers | Where-Object { ($_.givenName) -and ($_.surName) } ) {

    $fn = $u.givenName.Trim()

    $ln = $u.surName.Trim()

   

    Write-Host $fn $ln

    Set-ADUser -Identity $u -DisplayName "$fn $ln $hi" -GivenName "$fn" -SurName "$ln"-PassThru |

        Rename-ADObject -NewName "$fn $ln $hi"

}

 

Enable Windows Photo Viewer in Windows 10

In windows 10 Windows Photo Viewer is gone.
Here is how to activate it.
Download the following regkeys.
Activate-Windows-Photo-Viewer-on-Windows-10

When runned. Right click on a picture. Goto open with, Choose another app.

Now you get a list, Select Windows Photo Viewer and check Always use this app to open .* files.

Source: howtogeek.com

Here is the XML for GPO import Registry. Save as XML and drag and drop it in Computer Configuration > Preferences > Windows Settings > Registry

<Collection clsid="{53B533F5-224C-47e3-B01B-CA3B3F3FF4BF}" name="Windows Photo Viewer" changed="2016-09-20 14:00:00" uid="{26D98409-EB77-4970-B752-C90AD76A92FE}" bypassErrors="1">
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="MuiVerb" status="MuiVerb" image="7" changed="2020-03-20 12:54:01" uid="{818C8763-9895-4F80-B735-60F27C4386BB}">
		<Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="Applications\photoviewer.dll\shell\open" name="MuiVerb" type="REG_SZ" value="@photoviewer.dll,-3043"/>
	</Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="command" status="(Default)" image="7" changed="2020-03-20 12:54:07" uid="{36B81D47-DC5E-449D-9723-A561E07949E4}">
		<Properties action="U" displayDecimal="0" default="1" hive="HKEY_CLASSES_ROOT" key="Applications\photoviewer.dll\shell\open\command" name="" type="REG_EXPAND_SZ" value="%SystemRoot%\System32\rundll32.exe &quot;%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll&quot;, ImageView_Fullscreen %1"/>
	</Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="Clsid" status="Clsid" image="7" changed="2020-03-20 12:54:14" uid="{8BAF044A-5CF7-4CCD-BAC3-933887108900}">
		<Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="Applications\photoviewer.dll\shell\open\DropTarget" name="Clsid" type="REG_SZ" value="{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}"/>
	</Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="command" status="(Default)" image="7" changed="2020-03-20 12:54:21" uid="{59D93675-BF4C-4FC3-80EF-46BE54D187D2}">
		<Properties action="U" displayDecimal="0" default="1" hive="HKEY_CLASSES_ROOT" key="Applications\photoviewer.dll\shell\print\command" name="" type="REG_SZ" value="%SystemRoot%\System32\rundll32.exe &quot;%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll&quot;, ImageView_Fullscreen %1"/>
	</Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="Clsid" status="Clsid" image="7" changed="2020-03-20 12:54:29" uid="{1C3BE016-D09D-4098-B16B-0F5D5E51B3E7}" bypassErrors="1">
		<Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="Applications\photoviewer.dll\shell\print\DropTarget" name="Clsid" type="REG_SZ" value="{60fd46de-f830-4894-a628-6fa81bc0190d}"/>
	</Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="ImageOptionFlags" status="ImageOptionFlags" image="12" changed="2020-03-20 12:19:23" uid="{0B0E13E5-06CE-4A7C-A6AA-0EA1CE3D191D}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Bitmap" name="ImageOptionFlags" type="REG_DWORD" value="00000001"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="FriendlyTypeName" status="FriendlyTypeName" image="7" changed="2020-03-20 12:15:22" uid="{4BCEE34B-B09E-4116-A9A0-61613EBCDD80}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Bitmap" name="FriendlyTypeName" type="REG_EXPAND_SZ" value="@%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll,-3056"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="DefaultIcon" status="(Default)" image="7" changed="2020-03-20 12:17:22" uid="{1BAA4738-5084-4302-AAC5-ED99DF4B71DC}"><Properties action="U" displayDecimal="0" default="1" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Bitmap\DefaultIcon" name="" type="REG_SZ" value="%SystemRoot%\System32\imageres.dll,-70"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="command" status="(Default)" image="7" changed="2020-03-20 12:17:16" uid="{DE804BCD-86BE-4874-A373-A548C47F2D9A}"><Properties action="U" displayDecimal="0" default="1" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Bitmap\shell\open\command" name="" type="REG_EXPAND_SZ" value="%SystemRoot%\System32\rundll32.exe &quot;%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll&quot;, ImageView_Fullscreen %1"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="Clsid" status="Clsid" image="7" changed="2020-03-20 12:18:21" uid="{5354AA59-F6C7-44C9-8E05-BCEC2DEF680B}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Bitmap\shell\open\DropTarget" name="Clsid" type="REG_SZ" value="{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="EditFlags" status="EditFlags" image="12" changed="2020-03-20 12:19:16" uid="{FD1440E7-AAFB-40DA-8762-6F964927E1B2}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.JFIF" name="EditFlags" type="REG_DWORD" value="00010000"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="ImageOptionFlags" status="ImageOptionFlags" image="12" changed="2020-03-20 12:20:06" uid="{60940264-3F52-4F23-BC7D-C751D3E9469F}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.JFIF" name="ImageOptionFlags" type="REG_DWORD" value="00000001"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="FriendlyTypeName" status="FriendlyTypeName" image="7" changed="2020-03-20 12:22:31" uid="{AC3FCD87-45F1-42EA-A514-9E893190BC57}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.JFIF" name="FriendlyTypeName" type="REG_EXPAND_SZ" value="@%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll,-3055"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="DefaultIcon" status="(Default)" image="7" changed="2020-03-20 12:23:38" uid="{8ADEB44E-D03A-40DD-9D14-13D55A87E8AD}"><Properties action="U" displayDecimal="0" default="1" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.JFIF\DefaultIcon" name="" type="REG_SZ" value="%SystemRoot%\System32\imageres.dll,-72"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="MuiVerb" status="MuiVerb" image="7" changed="2020-03-20 12:24:27" uid="{FADE9D5A-46D1-4248-B4E1-056656732D6E}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.JFIF\shell\open" name="MuiVerb" type="REG_EXPAND_SZ" value="@%ProgramFiles%\Windows Photo Viewer\photoviewer.dll,-3043"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="command" status="(Default)" image="7" changed="2020-03-20 12:25:20" uid="{FDB758AC-5178-4576-88E4-BEB4E9907B83}"><Properties action="U" displayDecimal="0" default="1" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.JFIF\shell\open\command" name="" type="REG_EXPAND_SZ" value="%SystemRoot%\System32\rundll32.exe &quot;%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll&quot;, ImageView_Fullscreen %1"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="Clsid" status="Clsid" image="7" changed="2020-03-20 12:25:58" uid="{DF76ED93-D126-492D-A855-C63CD9D979A9}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.JFIF\shell\open\DropTarget" name="Clsid" type="REG_SZ" value="{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="EditFlags" status="EditFlags" image="12" changed="2020-03-20 12:26:42" uid="{3557C4B9-01EC-4DF7-98A8-5B9CA421F7EF}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Jpeg" name="EditFlags" type="REG_DWORD" value="00010000"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="ImageOptionFlags" status="ImageOptionFlags" image="12" changed="2020-03-20 12:27:07" uid="{B2181548-7565-4AC0-A466-E657C274AF3A}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Jpeg" name="ImageOptionFlags" type="REG_DWORD" value="00000001"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="FriendlyTypeName" status="FriendlyTypeName" image="7" changed="2020-03-20 12:27:44" uid="{76EB2C26-3E65-4ABD-9A40-3E34C5A1B5A6}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Jpeg" name="FriendlyTypeName" type="REG_EXPAND_SZ" value="@%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll,-3055"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="DefaultIcon" status="(Default)" image="7" changed="2020-03-20 12:28:43" uid="{7D74558A-ACAE-4E43-AF78-A67864384762}"><Properties action="U" displayDecimal="0" default="1" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Jpeg\DefaultIcon" name="" type="REG_SZ" value="%SystemRoot%\System32\imageres.dll,-72"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="MuiVerb" status="MuiVerb" image="7" changed="2020-03-20 12:29:24" uid="{C743374F-B65C-4AA4-A7EB-E066B9AD91C0}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Jpeg\shell\open" name="MuiVerb" type="REG_EXPAND_SZ" value="@%ProgramFiles%\Windows Photo Viewer\photoviewer.dll,-3043"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="command" status="(Default)" image="7" changed="2020-03-20 12:30:16" uid="{BDB3DBC8-A056-480B-8334-0C322BA6AB03}"><Properties action="U" displayDecimal="0" default="1" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Jpeg\shell\open\command" name="" type="REG_EXPAND_SZ" value="%SystemRoot%\System32\rundll32.exe &quot;%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll&quot;, ImageView_Fullscreen %1"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="Clsid" status="Clsid" image="7" changed="2020-03-20 12:30:53" uid="{4DEF65EC-E6BB-4FB0-AE02-187678BBD7C7}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Jpeg\shell\open\DropTarget" name="Clsid" type="REG_SZ" value="{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="ImageOptionFlags" status="ImageOptionFlags" image="12" changed="2020-03-20 12:31:37" uid="{A4C76D3A-741D-4E0E-AFD2-5F25F938BDFB}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Gif" name="ImageOptionFlags" type="REG_DWORD" value="00000001"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="FriendlyTypeName" status="FriendlyTypeName" image="7" changed="2020-03-20 12:32:08" uid="{177AF4D6-CD2E-42C9-98C6-DA4973C2A765}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Gif" name="FriendlyTypeName" type="REG_EXPAND_SZ" value="@%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll,-3057"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="DefaultIcon" status="(Default)" image="7" changed="2020-03-20 12:33:00" uid="{0784BD34-64B6-4058-995B-1023865586A9}"><Properties action="U" displayDecimal="0" default="1" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Gif\DefaultIcon" name="" type="REG_SZ" value="%SystemRoot%\System32\imageres.dll,-83"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="command" status="(Default)" image="7" changed="2020-03-20 12:33:36" uid="{10C4DFA6-08E0-4898-9777-50E00E8505DD}"><Properties action="U" displayDecimal="0" default="1" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Gif\shell\open\command" name="" type="REG_EXPAND_SZ" value="%SystemRoot%\System32\rundll32.exe &quot;%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll&quot;, ImageView_Fullscreen %1"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="Clsid" status="Clsid" image="7" changed="2020-03-20 12:34:40" uid="{B3FE350F-2A1A-4845-8F63-C7440AAE79D2}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Gif\shell\open\DropTarget" name="Clsid" type="REG_SZ" value="{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="ImageOptionFlags" status="ImageOptionFlags" image="12" changed="2020-03-20 12:38:02" uid="{D2B47B31-919D-4F3C-9CAD-6CB3E089ADD4}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Png" name="ImageOptionFlags" type="REG_DWORD" value="00000001"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="FriendlyTypeName" status="FriendlyTypeName" image="7" changed="2020-03-20 12:39:19" uid="{0C83CF63-7F85-4DCC-8400-4C9CB8F9DF5B}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Png" name="FriendlyTypeName" type="REG_EXPAND_SZ" value="@%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll,-3057"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="DefaultIcon" status="(Default)" image="7" changed="2020-03-20 12:40:04" uid="{7582A529-CE69-417A-B060-74DAB25E3A54}"><Properties action="U" displayDecimal="0" default="1" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Png\DefaultIcon" name="" type="REG_SZ" value="%SystemRoot%\System32\imageres.dll,-71"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="command" status="(Default)" image="7" changed="2020-03-20 12:40:51" uid="{FF654653-73C2-43EC-9FCE-24AD79738C43}"><Properties action="U" displayDecimal="0" default="1" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Png\shell\open\command" name="" type="REG_EXPAND_SZ" value="%SystemRoot%\System32\rundll32.exe &quot;%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll&quot;, ImageView_Fullscreen %1"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="Clsid" status="Clsid" image="7" changed="2020-03-20 12:41:45" uid="{BE45829D-6D4D-48C3-B701-E940226B566D}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Png\shell\open\DropTarget" name="Clsid" type="REG_SZ" value="{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="EditFlags" status="EditFlags" image="12" changed="2020-03-20 12:42:12" uid="{EC5A9C82-4D8C-4E71-8C65-3F521A5B7470}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Wdp" name="EditFlags" type="REG_DWORD" value="00010000"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="ImageOptionFlags" status="ImageOptionFlags" image="12" changed="2020-03-20 12:42:38" uid="{44A34E0B-992D-4EE4-975A-427FA376C81A}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Wdp" name="ImageOptionFlags" type="REG_DWORD" value="00000001"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="DefaultIcon" status="(Default)" image="7" changed="2020-03-20 12:43:11" uid="{B704F2DE-70D1-44A5-900B-609D466739F2}"><Properties action="U" displayDecimal="0" default="1" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Wdp\DefaultIcon" name="" type="REG_SZ" value="%SystemRoot%\System32\wmphoto.dll,-400"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="MuiVerb" status="MuiVerb" image="7" changed="2020-03-20 12:44:03" uid="{C3877333-B9B3-4F8F-B487-7735FEF9DC6E}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Wdp\shell\open" name="MuiVerb" type="REG_EXPAND_SZ" value="@%ProgramFiles%\Windows Photo Viewer\photoviewer.dll,-3043"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="command" status="(Default)" image="7" changed="2020-03-20 12:44:30" uid="{EF90B883-3446-45DF-A9F8-7CABFA4ADB09}"><Properties action="U" displayDecimal="0" default="1" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Wdp\shell\open\command" name="" type="REG_EXPAND_SZ" value="%SystemRoot%\System32\rundll32.exe &quot;%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll&quot;, ImageView_Fullscreen %1"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="Clsid" status="Clsid" image="7" changed="2020-03-20 12:45:06" uid="{97368AB3-C0A6-4D93-8AB0-05CB8C528E37}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CLASSES_ROOT" key="PhotoViewer.FileAssoc.Wdp\shell\open\DropTarget" name="Clsid" type="REG_SZ" value="{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="ApplicationDescription" status="ApplicationDescription" image="7" changed="2020-03-20 12:46:50" uid="{C24BFFF8-7CC2-4157-88F6-832B29C14CF1}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_LOCAL_MACHINE" key="SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities" name="ApplicationDescription" type="REG_SZ" value="@%ProgramFiles%\Windows Photo Viewer\photoviewer.dll,-3069"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="ApplicationName" status="ApplicationName" image="7" changed="2020-03-20 12:47:13" uid="{F197301F-7DE8-44DA-A71C-529226A54C08}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_LOCAL_MACHINE" key="SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities" name="ApplicationName" type="REG_SZ" value="@%ProgramFiles%\Windows Photo Viewer\photoviewer.dll,-3009"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name=".bmp" status=".bmp" image="7" changed="2020-03-20 12:47:48" uid="{04687C41-7FC7-4FDD-970B-2C029D38C57F}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_LOCAL_MACHINE" key="SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations" name=".bmp" type="REG_SZ" value="PhotoViewer.FileAssoc.Bitmap"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name=".dib" status=".dib" image="7" changed="2020-03-20 12:48:26" uid="{2C81593E-4406-4938-8C26-70E80ADC3162}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_LOCAL_MACHINE" key="SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations" name=".dib" type="REG_SZ" value="PhotoViewer.FileAssoc.Bitmap"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name=".gif" status=".gif" image="7" changed="2020-03-20 12:48:49" uid="{7D3386C2-D482-4E6D-A8AB-C6C3E16D5E5F}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_LOCAL_MACHINE" key="SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations" name=".gif" type="REG_SZ" value="PhotoViewer.FileAssoc.Gif"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name=".jfif" status=".jfif" image="7" changed="2020-03-20 12:49:09" uid="{79162896-0EB2-4382-BD9E-DDA23A1823B2}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_LOCAL_MACHINE" key="SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations" name=".jfif" type="REG_SZ" value="PhotoViewer.FileAssoc.JFIF"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name=".jpe" status=".jpe" image="7" changed="2020-03-20 12:49:37" uid="{A22C4574-B35F-45B9-B8A4-8A339221E911}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_LOCAL_MACHINE" key="SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations" name=".jpe" type="REG_SZ" value="PhotoViewer.FileAssoc.Jpeg"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name=".jpeg" status=".jpeg" image="7" changed="2020-03-20 12:50:08" uid="{E2AB304C-3E6D-4A8F-8DB7-B3D82E6D24BD}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_LOCAL_MACHINE" key="SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations" name=".jpeg" type="REG_SZ" value="PhotoViewer.FileAssoc.Jpeg"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name=".jpg" status=".jpg" image="7" changed="2020-03-20 12:50:32" uid="{98050833-9901-48CF-BDCF-3246D6CBD430}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_LOCAL_MACHINE" key="SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations" name=".jpg" type="REG_SZ" value="PhotoViewer.FileAssoc.Jpeg"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name=".jxr" status=".jxr" image="7" changed="2020-03-20 12:50:53" uid="{BE414F2F-F6AF-4BF1-94BF-B9349D306FDB}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_LOCAL_MACHINE" key="SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations" name=".jxr" type="REG_SZ" value="PhotoViewer.FileAssoc.Wdp"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name=".png" status=".png" image="7" changed="2020-03-20 12:51:18" uid="{2607795B-A4E5-49B6-9074-F5B2A52DBFDF}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_LOCAL_MACHINE" key="SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations" name=".png" type="REG_SZ" value="PhotoViewer.FileAssoc.Png"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name=".tif" status=".tif" image="7" changed="2020-03-20 12:51:43" uid="{73097066-8C4B-4D0B-BDE1-C123791EFD98}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_LOCAL_MACHINE" key="SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations" name=".tif" type="REG_SZ" value="PhotoViewer.FileAssoc.Tiff"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name=".tiff" status=".tiff" image="7" changed="2020-03-20 12:52:02" uid="{7FC5395F-FEAE-45D1-B0B6-0B8B9EDFB6C2}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_LOCAL_MACHINE" key="SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations" name=".tiff" type="REG_SZ" value="PhotoViewer.FileAssoc.Tiff"/></Registry>
	<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name=".wdp" status=".wdp" image="7" changed="2020-03-20 12:52:27" uid="{F81A621E-1D6F-494E-9BC4-595A750BF82D}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_LOCAL_MACHINE" key="SOFTWARE\Microsoft\Windows Photo Viewer\Capabilities\FileAssociations" name=".wdp" type="REG_SZ" value="PhotoViewer.FileAssoc.Wdp"/></Registry>
</Collection>

AD Change Roaming profile Path Terminal server

I created this script because of moving the profiles to a server in the data center were also the terminal server is located.

Powershell needs to be runned as Administrator

########
## created by Daag van der Meer
## blog.van-daag.nl
## 26-04-2018
########
#
# Script is used to set Homedrive, RDP Homedrive, Profilepath, RDP profile path.
#
# Script needs to be runned as Admin!!!


Import-Module ActiveDirectory
     # On the Domain Controller There is on C:\Temp\Users.txt with the usernames to change the path

foreach ($user in (get-content c:\temp\Users.txt)) {
    ## Homedrive and profile location
    $homeDirectory = '\\<NewServer>\home$\<Country>\' + $user; 
    $ProfilePath = '\\<NewServer>\Profile$\<Country>\' + $user; 

    ## Set homedrive (DISABLE THIS IF YOU DON'T WANT TO CHANGE THIS)
    # Finally set their home directory and home drive letter in Active Directory
    Set-ADUser -Identity $user -HomeDirectory $homeDirectory -HomeDrive H
	
	## Set Profile (DISABLE THIS IF YOU DON'T WANT TO CHANGE THIS)
		Set-ADUser -Identity $user -ProfilePath $ProfilePath
        
        ## Set RDP Profile and Homedrive
        Get-ADUser -Filter "SAMAccountName -like '$user*'"| ForEach-Object {
        $ADSI = [ADSI]('LDAP://{0}' -f $_.DistinguishedName)
        try {
            $ADSI.InvokeSet('TerminalServicesProfilePath',$ProfilePath)
            $ADSI.InvokeSet("TerminalServicesHomeDrive","H:")
            $ADSI.InvokeSet("TerminalServicesHomeDirectory",$homeDirectory)
            $ADSI.SetInfo()
        }
        catch {
            Write-Error $Error[0]
        }
}
	
}