<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dizid &#187; Scripting</title>
	<atom:link href="http://www.dizid.com/category/scripting/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dizid.com</link>
	<description>Advanced Websites</description>
	<lastBuildDate>Tue, 27 Apr 2010 15:30:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Starting a service through Powershell on the Windows 7 local PC</title>
		<link>http://www.dizid.com/coldfusion/starting-a-service-through-powershell-on-the-windows-7-local-pc/</link>
		<comments>http://www.dizid.com/coldfusion/starting-a-service-through-powershell-on-the-windows-7-local-pc/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 12:33:17 +0000</pubDate>
		<dc:creator>Marc de Ruijter</dc:creator>
				<category><![CDATA[Coldfusion]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.dizid.com/?p=268</guid>
		<description><![CDATA[In 1 sentence Create a shortcut with &#8216;Run as administrator&#8217; properties which points to powershell.exe path\to\script.ps1  with 1  line in it:  Start-Service -displayname  &#8220;the-name-of-the-service-that-you-want-to-sart&#8221; and have  the right execution policy for PS scripts. The longer version Through Windows Powershell-scripts administrators can automate almost all computermanagement tasks. All things that can be done through visual windows [...]]]></description>
			<content:encoded><![CDATA[<h2>In 1 sentence</h2>
<p>Create a shortcut with &#8216;Run as administrator&#8217; properties which points to powershell.exe path\to\script.ps1  with 1  line in it:  Start-Service -displayname  &#8220;the-name-of-the-service-that-you-want-to-sart&#8221; and have  the right execution policy for PS scripts.</p>
<h2>The longer version</h2>
<p>Through Windows Powershell-scripts administrators can automate almost all computermanagement tasks. All things that can be done through visual windows -and more- can be done through Powershell scripts.</p>
<p>When you want to start, restart or stop services it can be usefull to do that through a shortcut on the desktop, here is how i start or restart the Coldfusion service on my local PC.</p>
<p>Before you can execute Powershell scripts on Windows systems, you first have to set an execution policy. To get the current execution policy, open a Powershell command window or ISE  (Start &gt; type powershell &gt; hit enter) &#8216;as administrator&#8217;  and type get-executionpolicy. To set the needed execution policy, type set-executionpolicy RemoteSigned.  Now start creating the shortcut which start the service:</p>
<p>1. Create a file start-cf-service.ps1 and add the following line in it:<br />
Restart-Service -displayname &#8220;ColdFusion 9 Application Server&#8221;<br />
Save the file somewhere and notice i wrote the &#8216;Restart-Service&#8217; command instead of &#8216;Start-Service&#8217; because i want the script to double as a restarting service command, which restarts a service when it is already running (which can be usefull when a service &#8216;hangs&#8217;) and just starts the service when it is not running.</p>
<p>If this is the first time you are running Powershell scripts you also have to set an security policy for running scripts. without going into that too deep, you have to run a script with Set-ExecutionPolicy RemoteSigned in it once (see below).</p>
<p>2. Create a shortcut to powershell.exe by rightclicking on the desktop and typing the location of powershell.exe and the location of your newly created .ps1 script, for example: powershell.exe C:\powershell\start-coldfusion.ps1</p>
<p>3. The shortcut needs to be run &#8216;as administrator&#8217; (through advanced &gt; run as administrator in the shortcut tab of the shortcut (lol?)</p>
<p>5. Plus: the security settings of the local PC have to be changed to  &#8220;no notifications when a program tries to make changes&#8221;, to avoid pop-ups.</p>
<p>Some services, like the Coldfusion 9 (beta) service on my 4 year-old PC take a little time to start and stop, so the command window will show repeating warnings about starting or stopping the services. You can just ignore these warnings, they will stop when the service is really stopped or started and also the command windows will automatically disappear (except when used with the -noexit option, see below.)</p>
<p>There are a great number of other things that can be done with powershell, but starting a service on a remote PC is not 1 of them, due to beta status. If you want to see the status of your startservice script then use the -noexit option, as in: powershell.exe –noexit c:\scripts\test.ps1 which makes the command window stay open.</p>
<p>For more information on Powershell just <a href="http://www.google.com/search?q=powershell" target="_blank">Google</a> it or read the free online <a href="http://powershell.com/cs/blogs/ebook/" target="_blank">book on Powershell</a>. Example scripts can be found in thePowershell category of the <a onmousedown="return rwt(this,'','','res','1','AFQjCNGMr35_vTvF119lX6b13FN6Niv8bg','&amp;sig2=IbvM2N_vj4Xw0a7_l3DdIg')" href="http://www.google.com/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fgallery.technet.microsoft.com%2FScriptCenter%2Fen-us%2F&amp;ei=-Mu0Srr2KOCK4gbo_pl8&amp;usg=AFQjCNGMr35_vTvF119lX6b13FN6Niv8bg&amp;sig2=IbvM2N_vj4Xw0a7_l3DdIg">TechNet <em>Script</em> Center Gallery</a></p>
<p>Happy scripting <img src='http://www.dizid.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.dizid.com/coldfusion/starting-a-service-through-powershell-on-the-windows-7-local-pc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
