<?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>Leoganda.net &#187; Powershell</title>
	<atom:link href="http://www.leoganda.net/tag/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.leoganda.net</link>
	<description></description>
	<lastBuildDate>Fri, 09 Dec 2011 04:12:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Powershell enable execution of script</title>
		<link>http://www.leoganda.net/powershell-enable-execution-of-script/</link>
		<comments>http://www.leoganda.net/powershell-enable-execution-of-script/#comments</comments>
		<pubDate>Mon, 04 Apr 2011 03:38:44 +0000</pubDate>
		<dc:creator>leoganda</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://www.leoganda.net/?p=107</guid>
		<description><![CDATA[By default powershell prevent the user to run a script file (.ps1), in order to enable the execution of script we have to manually enable it. First check your powershell execution policy Get-ExecutionPolicy Restricted If it shows &#8220;Restricted&#8221; then you will have to enable it We can use "Unrestricted" phrase to enable it Set-ExecutionPolicy Unrestricted [...]]]></description>
			<content:encoded><![CDATA[<p>By default powershell prevent the user to run a script file (.ps1), in order to enable the execution of script we have to manually enable it.</p>
<p>First check your powershell execution policy</p>

<div class="wp_syntax"><div class="code"><pre class="ps" style="font-family:monospace;">Get-ExecutionPolicy
Restricted</pre></div></div>

<p>If it shows &#8220;Restricted&#8221; then you will have to enable it</p>
<p>We can use <code>"Unrestricted"</code> phrase to enable it</p>

<div class="wp_syntax"><div class="code"><pre class="ps" style="font-family:monospace;">Set-ExecutionPolicy Unrestricted</pre></div></div>

<p>It will prompt confirmation, if you want it to force put <code>"-f"</code> in the command. The command will look like this</p>

<div class="wp_syntax"><div class="code"><pre class="ps" style="font-family:monospace;">Set-ExecutionPolicy Unrestricted -f</pre></div></div>

<p>Now you can run your scripts on your Powershell.</p>
<h4>What people search:</h4><ul><li><a href="http://www.leoganda.net/powershell-enable-execution-of-script/" title="enable powershell script execution">enable powershell script execution</a></li><li><a href="http://www.leoganda.net/powershell-enable-execution-of-script/" title="powershell webclient uploadfile">powershell webclient uploadfile</a></li><li><a href="http://www.leoganda.net/powershell-enable-execution-of-script/" title="webclient uploadfile powershell">webclient uploadfile powershell</a></li><li><a href="http://www.leoganda.net/powershell-enable-execution-of-script/" title="powershell enable script execution">powershell enable script execution</a></li><li><a href="http://www.leoganda.net/powershell-enable-execution-of-script/" title="powershell allow script execution">powershell allow script execution</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.leoganda.net/powershell-enable-execution-of-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Powershell FTP</title>
		<link>http://www.leoganda.net/simple-powershell-ftp/</link>
		<comments>http://www.leoganda.net/simple-powershell-ftp/#comments</comments>
		<pubDate>Mon, 03 May 2010 15:36:51 +0000</pubDate>
		<dc:creator>leoganda</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.leoganda.net/simple-powershell-ftp/</guid>
		<description><![CDATA[With Powershell we can do FTP transaction really easy. The best feature from Powershell is we can use any dll library in our script, we can import .Net libraries and etc into our script. The script below is simple FTP to upload file to FTP server. In this script I&#8217;m using System.Net.WebClient to handle the [...]]]></description>
			<content:encoded><![CDATA[<p>With Powershell we can do FTP transaction really easy. The best feature from Powershell is we can use any dll library in our script, we can import .Net libraries and etc into our script. The script below is simple FTP to upload file to FTP server. In this script I&#8217;m using System.Net.WebClient to handle the file transfer.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$ftpuser</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;user&quot;</span>
<span style="color: #800080;">$ftppass</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;12345&quot;</span>
<span style="color: #800080;">$ftpserver</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;localhost&quot;</span>
<span style="color: #800080;">$file</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;C:\test.txt&quot;</span>
<span style="color: #800080;">$filenewname</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;test.txt&quot;</span>
&nbsp;
<span style="color: #800080;">$webclient</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Net.WebClient
<span style="color: #800080;">$ftp</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;ftp://&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$ftpuser</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$ftppass</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;@&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$ftpserver</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;/&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$filenewname</span>
<span style="color: #800080;">$uri</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> System.Uri<span style="color: #000000;">&#40;</span><span style="color: #800080;">$ftp</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$webclient</span>.UploadFile<span style="color: #000000;">&#40;</span><span style="color: #800080;">$uri</span><span style="color: pink;">,</span><span style="color: #800080;">$file</span><span style="color: #000000;">&#41;</span>﻿</pre></td></tr></table></div>

<h4>What people search:</h4><ul><li><a href="http://www.leoganda.net/simple-powershell-ftp/" title="powershell ftp upload">powershell ftp upload</a></li><li><a href="http://www.leoganda.net/simple-powershell-ftp/" title="powershell ftp">powershell ftp</a></li><li><a href="http://www.leoganda.net/simple-powershell-ftp/" title="powershell webclient ftp">powershell webclient ftp</a></li><li><a href="http://www.leoganda.net/simple-powershell-ftp/" title="powershell script ftp upload">powershell script ftp upload</a></li><li><a href="http://www.leoganda.net/simple-powershell-ftp/" title="system net webclient powershell ftp">system net webclient powershell ftp</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.leoganda.net/simple-powershell-ftp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell script sort list file</title>
		<link>http://www.leoganda.net/powershell-script-sort-list-file/</link>
		<comments>http://www.leoganda.net/powershell-script-sort-list-file/#comments</comments>
		<pubDate>Mon, 03 May 2010 15:27:09 +0000</pubDate>
		<dc:creator>leoganda</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://www.leoganda.net/?p=69</guid>
		<description><![CDATA[It&#8217;s pretty easy to sort an output from ls or Get-ChildItem using powershell, you can sort the output by name, length, and date. Sort By Name Get-ChildItem C:\ &#124; sort -property Name Sort By Size Get-ChildItem C:\ &#124; sort -property Length Sort By Date Modified Get-ChildItem C:\ &#124; sort -property LastWriteTime You also can reorder [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s pretty easy to sort an output from ls or Get-ChildItem using powershell, you can sort the output by name, length, and date.</p>
<p>Sort By Name</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Get-ChildItem</span> C:\ <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">sort</span> <span style="color: #008080; font-style: italic;">-property</span> Name</pre></div></div>

<p>Sort By Size</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Get-ChildItem</span> C:\ <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">sort</span> <span style="color: #008080; font-style: italic;">-property</span> Length</pre></div></div>

<p>Sort By Date Modified</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Get-ChildItem</span> C:\ <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">sort</span> <span style="color: #008080; font-style: italic;">-property</span> LastWriteTime</pre></div></div>

<p>You also can reorder the sort output with &#8220;-descending&#8221;<br />
example :</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008080; font-weight: bold;">Get-ChildItem</span> C:\ <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">sort</span> <span style="color: #008080; font-style: italic;">-property</span> LastWriteTime <span style="color: #008080; font-style: italic;">-descending</span></pre></div></div>

<h4>What people search:</h4><ul><li><a href="http://www.leoganda.net/powershell-script-sort-list-file/" title="powershell sort list">powershell sort list</a></li><li><a href="http://www.leoganda.net/powershell-script-sort-list-file/" title="powershell file list in array">powershell file list in array</a></li><li><a href="http://www.leoganda.net/powershell-script-sort-list-file/" title="script organize files by date powershell">script organize files by date powershell</a></li><li><a href="http://www.leoganda.net/powershell-script-sort-list-file/" title="powershell sort script">powershell sort script</a></li><li><a href="http://www.leoganda.net/powershell-script-sort-list-file/" title="powershell sort list of date">powershell sort list of date</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.leoganda.net/powershell-script-sort-list-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

