How to quickly schedule a Reboot

Sometime you need to schedule a one shot reboot.
I found easier to past a command on prompt and forget it:

Sleep -Seconds (New-TimeSpan -End "7 PM").TotalSeconds ; Restart-Computer -Force

If you do not put the date, powershell assume you what the current day, so do not use for example “5AM” if you are at in the afternoon. Leave the session running otherwise your command will be killed and the server will not reboot.

Another command to do the same task is this that use scheduled job:

Register-ScheduledJob -Name Reboot -ScriptBlock { Restart-Computer -Force} –Trigger @{Frequency="Once"; At="11:00PM"} -ScheduledJobOption @{RunElevated=$True}

and this command for remove the scheduled job:

Get-ScheduledJob -Name Reboot | Unregister-ScheduledJob

Problem: VMware Player 12 do not start on Fedora 23

VMware Workstation 12 Player (12.0.1) silently fail on Fedora 23. Here a workaround waiting official support:

Become root:

su -

Replace the vmware glib version with the fedora version:

cd /usr/lib/vmware/lib
for mylib in $(ls /usr/lib64/*4600*); do /bin/cp -afv $mylib $(basename $mylib .4600.1 )/$(basename $mylib .4600.1 ); done

Start VMplayer:



How to automate Android settings

Inside a project of rollout of new mobile phone we had the need to automate some settings configuration to make android devices rollout quickly.

We used ADB and Monkeyrunner tools for accomplish this task. These tools are inside Android SDK:

Install Android SDK and from SDK Manager select both “Android SDK Tools” and “Android SDK Platform-tools”

Android SDK Manager

ADB can found on ..\Android\android-sdk\platform-tools

Before using ADB remember to enable Developer Menu and the USB Debug option:

With ADB you can perform various tasks against your Android device.
For example this script wait for a device and then install an app (MDM.apk) and remove some other unnecessary apps:

cd C:\Users\sysadmin\AppData\Local\Android\android-sdk\platform-tools
adb wait-for-device
adb install C:\Data\MDM.apk
adb shell pm uninstall
adb shell pm uninstall
adb shell pm uninstall

To browse all the apps installed you can use this command:

adb shell pm list packages

More commands can be found here: Http://

Then I used monkeyrunner for automate some configuration. Monkeyrunner can be found in this folder: ..\Android\android-sdk\tools
Then I downloaded two scripts to make using monkeyrunner easier:
Copy and into ..\Android\android-sdk\tools folder.

If you already connected your Android device via USB with USB_DEBUG enabled the run this command for record some actions:


Using the mouse perform the actions on MonkeyRunner Recorder screen then save the script clicking on the menu “Export Actions”. Save the file with file extension “.mr”. For example C:\Data\

To perform the same action you recorded again type this command:

monkeyrunner C:\Data\

Remember to insert some sleep after each action you recorded because probably your device is not so quickly as commands are sent by script.


Here a list of actions that you can type directly on your monkeyrunner script:

  • To press “HOME” Button:
  • To type something:
  • To Scroll Down:
  • To Scroll Left:
  • To wait 1 second:

Following some ADB notes:

  • connect adb over Wi-Fi
     adb shell setprop service.adb.tcp.port 5555 && stop adbd && start adbd adb connect 
  • Unlock your Android screen
     adb shell input keyevent 82 
  • Lock your Android screen
     adb shell input keyevent 6 adb shell input keyevent 26 
  • Open default browser
     adb shell input keyevent 23 
  • Keep your android phone volume up(+)
     adb shell input keyevent 24 
  • Keep your android phone volume down(-)
     adb shell input keyevent 25 
  • Go to your Android Home screen
     adb shell input keyevent 3 
  • Take Screenshot from adb
     adb shell screenshot /sdcard/test.png 
  • start clock app
     adb shell am start 
  • stop clock app
     adb shell am force-stop 
  • start wifi settings manager
     adb shell am start -a android.intent.action.MAIN -n 


Problem: GPClient hang on boot

Some days ago I was involved on a Windows 8.1 machine that take up to 60 minutes to boot.

On Application Event log I found this error:

Nome registro: Application
Origine:       Microsoft-Windows-Winlogon

ID evento:     6006
Categoria attività:Nessuna
Livello:       Avviso
Parole chiave: Classico

La gestione dell’evento di notifica (CreateSession) da parte del sottoscrittore delle notifiche di WinLogon ha richiesto 3599 secondi.

As first step I tried to move this machine on a OU without GPOs but nothing was changed.
Then I tried to check WMI status because WMI is checked during GPO analysis.
There is a good blog from “Performance Team”:

This is what I did for solve the problem:

net stop winmgmt /y
winmgmt /resetrepository

Then reboot the system.

How to Provide Input to Applications with PowerShell

Something is useful automate an application task/setting from command line. From powershell  you can use .NET framework and using SendKeys to provide input to graphical applications.

Here a small example that open Notepad, type some text and open “Save as..” window:

# Load Assebly System.Windows.Forms  
[void] [System.Reflection.Assembly]::LoadWithPartialName(“‘System.Windows.Forms”)

# Load NotePad
& “$env:WINDIR\notepad.exe”

# Wait the application start for 1 sec 
Start-Sleep -m 1000

# Send keys
[System.Windows.Forms.SendKeys]::SendWait(“I'm wrinting something”)
[System.Windows.Forms.SendKeys]::SendWait(“Powered by PowerShell”)

# Open "Save As.." menu (Alt+f+s)

# Wait menu opening for 0.5 sec 
Start-Sleep -m 500