Powershell from scheduled task

As powershell is running by default in secure mode , use the following setting to run powershell scripts from a scheduled task.

This way you do not have to elevate the rights for running scripts. Ensure your Powershell script is located in a folder where he is well protected from tempering bud accessible by the user the scheduled task is running under.

 

executable: Powershell.exe

Option: -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File <Path and Scriptname>

Example for Option :-ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden –File C:\scripts\myscript.ps1

Posted in Information Technology, Tips | Tagged | Comments Off on Powershell from scheduled task

WordPress 4.1 and XML-RPC for Microsoft Word

 

Problem

I used to write posts using Microsoft Word. After updating to WordPress 4.1 blogging was not possible anymore . In WordPress the settings for XML-RPC disappeared.

Solution

Microsoft is offering a free bundle of software called : Windows Essentials

http://windows.microsoft.com/de-ch/windows-live/essentials-other#essentials=overviewother

Install only Windows Live Writer from this bundle. It is better than Word for blogging as you can apply categories etc.

Info: to change the path where Live Writer saves your local documents add the following RegKey

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows Live\Writer]
“PostsDirectory”=”A:\\Cloud-Mix\\Posts”

Posted in Fix IT | Tagged | Comments Off on WordPress 4.1 and XML-RPC for Microsoft Word

ADDS Dump thumbnailPhoto to JPG file

Use this command line in Powershell to save a users thumbnailPhoto to a file.
First start a Powershell session with Active Directory Modules loaded, then:

get-aduser “sAMAccountname” -server “FQDN Domain Controller”-properties thumbnailPhoto | select -expandproperty thumbnailphoto | set-content -path “JPG Location” -encoding byte

Example:
get-aduser peter_miller -server dc1.contoso.com -properties thumbnailPhoto | select -expandproperty thumbnailphoto | set-content -path c:\temp\peter_miller.jpg -encoding byte

The option -server is optional. Use it to prove that all servers return the same picture (check sync problems)

Posted in Information Technology, Tips | Tagged , | Comments Off on ADDS Dump thumbnailPhoto to JPG file

Clear Protected from accidental deletion flag

Windows Active Directory protects per default Organizational Units (OU) from accidential deletion .

To clear this flag for an entire OU structure you can use this Powershell commands . This example command will remove the flag from an OU structure  OU=acme,DC=scom,DC=local and all child OUs .

sl AD:
sl "dc=scom,dc=local"
get-childitem -recurse OU=acme | where {$_.ObjectClass -match "organizationalUnit"} | Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion $false
Posted in Information Technology, Tips | Tagged , | Comments Off on Clear Protected from accidental deletion flag

Powershell write to file creates strange characters

Problem

Reason

The file was created by using the command  add-content without definition of encoding (default ANSI encoding). Later on lines where added by using command out-file (default Unicode encoding)

Solution

Do not mix the two line writer add-content and out-file without definining encoding.

Posted in Fix IT | Tagged , | Comments Off on Powershell write to file creates strange characters

Windows 10 Store is closing after selecting a new app

Problem

After selecting an app in Windows 10 store the store is closing without message. Different internet tips like rebuilding the store did not help. Here some sites I tried,  including extracted commands.

  • http://winsupersite.com/windows-10/how-fix-stopped-windows-store-downloads-windows-10
    PS1: $manifest = (Get-AppxPackage Microsoft.WindowsStore).InstallLocation + ‘\AppxManifest.xml’ 
    PS1: Add-AppxPackage -DisableDevelopmentMode -Register $manifest
  • https://social.technet.microsoft.com/Forums/en-US/66658cdc-3fd1-4406-96b3-bca91f3ec90c/windows-store-will-not-start?forum=win10itprogeneral
    PS1: Same as site above
    CMD: Dism /Online /Cleanup-Image /RestoreHealth
    CMD: SFC /scannow

Error Log

Event ID 1000 Source Application Error

Faulting application name: WinStore.Mobile.exe, version: 2015.9.9.2, time stamp: 0x55f0f2eb
Faulting module name: twinapi.appcore.dll, version: 10.0.10240.16397, time stamp: 0x55af1390

Solution

Windows Update Service was stopped. Windows 10 store is using parts of the update service to download  apps.

 

Posted in Fix IT | Tagged | Comments Off on Windows 10 Store is closing after selecting a new app

synology config ddns with dnsmadeeasy

DSM 6.x

Open Control panel , change to “external access” and “DDNS”
press Customize
Enter a name for DDNS
Enter the following string as URL and safe the provider:

http://cp.dnsmadeeasy.com/servlet/updateip?username=__USERNAME__&password=__PASSWORD__&id=__HOSTNAME__&ip=__MYIP__

Now press “add” and fill in all parameters. The Hostname  has to be filled with the ID provided by dnsmadeeasy as shown below in this article in section DSM 5.x.

DSM 5.x

The following part was written for DSM 5.1 , based on existing module scripts. It will check good and failed authentication.

dnsmadeeasy enables you to use multiple DDNS entries by sending an update to an ID not a Namespace.

Problem:

The default  module DynDNS in  /etc.defaults/ddns_provider.conf is not working correct as the response from dnsmadeeasy is “success” and not “good” as expected.

Solution:

login as admin
sudo -i      (twice so you get root access)

By adding a PHP script for dnsmadeeasy and multiple lines to ddns_provider.conf  you can add dns updates to multiple sites.

create a script called  /usr/syno/bin/ddns/dnsmadeeasy.php with the following content.

#!/usr/bin/php -d open_basedir=/usr/syno/bin/ddns
php
 
 
 
$account = (string)$argv[1];
$pwd = (string)$argv[2];
$hostname = (string)$argv[3];
$ip = (string)$argv[4];
 
 
 
// only for IPv4 format
if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
    echo "badparam";
    exit();
}
 
$url = 'http://cp.dnsmadeeasy.com/servlet/updateip?username='.$account.'&amp;password='.$pwd.'&amp;id='.$hostname.'&amp;ip='.$ip;
// $url = 'https://'.$account.':'.$pwd.'@api.nic.ru/dyndns/update?hostname='.$hostname.'$myip='.$ip;
// echo $url;
$req = curl_init();
curl_setopt($req, CURLOPT_URL, $url);
$res = curl_exec($req);
curl_close($req);
 
if (strpos($res, 'success') === true) {
	echo 'good';
	exit();
} 
 
if (strpos($res, 'error-auth') === true) {
	echo 'badauth';
	exit();
} 
echo 'good';

Next add three lines to /etc.defaults/ddns_provider.conf for each of your DNS name spaces hosted. The entries need different names  as synology allows only one entry per DDNS Provider. And do not use long names. Here [dnsmade1].

[dnsmade1]
modulepath=/usr/syno/bin/ddns/dnsmadeeasy.php
queryurl=cp.dnsmadeeasy.com/

Next open your DDNS GUI on your synology NAS  (Control Panel -> External Access)
  ddns2

Click add and select one of you new created providers.
ddns3

Fill in your Numbers, Name and Password to access dnsmadeeasy and test your connection. If all ist good you get a Normal.
ddns4

Posted in Fix IT, Information Technology | Tagged , | Comments Off on synology config ddns with dnsmadeeasy