Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Restarting ActiveSync from PowerShell - quick scripts

Reply
 
Old 10-04-2006   #1 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Restarting ActiveSync from PowerShell - quick scripts

If you use a handheld Windows computer of some kind, you're probably aware
of the occasional issues with managing ActiveSync. It may need to be
stopped, started, or restarted, and there is no direct way to do this
normally.

The following 3 short scripts are all used for this purpose:
Stop-ActiveSync, Start-ActiveSync, and Restart-ActiveSync. Note that they
are actually trivial scripts, which could be shortened down to 1-liners. The
real reason they exist is that they _are_ useful, in a very PowerShellish
way. To stop, start, or restart ActiveSync, I don't have to think about the
application name; I just need to use the verb and the noun. Since ActiveSync
also registers its executable's application path, we can also get a highly
reliable automatic find-and-start through [Diagnostics.Process]::Start().


###<script name="Stop-ActiveSync.ps1">
Param([switch]$PassThru)
# Name is fake-wildcarded to suppress errors if
# Activesync is not running.
$result = Stop-Process -Name [w]cescomm -PassThru
if($PassThru){$result;}
###</script>

###<script name="Start-ActiveSync.ps1">
Param([switch]$PassThru)
# Find-and-launch automatically using ShellExecute and
# registered App Paths.
$result = [System.Diagnostics.Process]::Start("WCESCOMM.EXE");
if($PassThru){$result;}
###</script>

###<script name="Restart-ActiveSync.ps1">
Param([switch]$PassThru)
# Name is fake-wildcarded to suppress errors if
# Activesync is not running.
Stop-Process -Name [w]cescomm
# Find-and-launch automatically using ShellExecute and
# registered App Paths.
$result = [System.Diagnostics.Process]::Start("WCESCOMM.EXE");
if($PassThru){$result;}
###</script>




My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Multithread scripts in Powershell PowerShell
run PowerShell scripts from ASP or asp.net PowerShell
Powershell scripts not working with Vista powershell PowerShell
Can't run powershell scripts PowerShell
powershell logon scripts PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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 34 35 36 37 38 39 40 41 42 43 44 45 46