<?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>..::\\ www.christiano.ch //::.. &#187; Elevation</title>
	<atom:link href="http://www.christiano.ch/wordpress/tag/elevation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.christiano.ch/wordpress</link>
	<description>christiano.ch blog - personal knowledge base, news, memoires et cetera</description>
	<lastBuildDate>Fri, 06 Jan 2012 15:28:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<meta xmlns="http://www.w3.org/1999/xhtml" name="robots" content="noindex,follow" />
		<item>
		<title>PowerShell: UAC, SUDO, Elevation, Access to the path &#8216;C:\Program Files&#8217; is denied.</title>
		<link>http://www.christiano.ch/wordpress/2009/07/26/get-content-access-to-the-path-cprogram-files-is-denied/</link>
		<comments>http://www.christiano.ch/wordpress/2009/07/26/get-content-access-to-the-path-cprogram-files-is-denied/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 07:56:08 +0000</pubDate>
		<dc:creator>christian</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Access Denied]]></category>
		<category><![CDATA[Elevation]]></category>
		<category><![CDATA[RunAs]]></category>
		<category><![CDATA[SUDO]]></category>
		<category><![CDATA[UAC]]></category>

		<guid isPermaLink="false">http://blog.christiano.ch/?p=40</guid>
		<description><![CDATA[Powershell on Windows Vista and Windows 7 runs restricted and not-elevated by default. Microsoft did a good job when they invented the so called UAC (User Account Control). As ususal, Microsoft started something new and did not finish it yet &#8230; <a href="http://www.christiano.ch/wordpress/2009/07/26/get-content-access-to-the-path-cprogram-files-is-denied/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Powershell on Windows Vista and Windows 7 runs restricted and not-elevated by default. Microsoft did a good job when they invented the so called UAC (User Account Control). As ususal, Microsoft started something new and did not finish it yet &#8211; the product is still not feature-complete. Well, probably it&#8217;s their philosophy to create thousands of products in a vertical manner, the user then is left all alone finding out how to dive into the features from a horizontal perspective&#8230;</p>
<p>What i mean: PowerShell runs restricted and has NO SUDO command. For sake of christ, there is a workaround.</p>
<p>First, find out the location of your profile.ps1. it easy as:</p>
<p><code><br />
PS C:\> $profile<br />
C:\Users\<ohn FooBar\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1<br />
PS C:\><br />
</code></p>
<p>Probably this script does not exist by default. At least on my systems this was the case. So create it.<br />
When created / if it does exist do:</p>
<p><code><br />
PS C:\> notepad.exe $profile<br />
</code></p>
<p>This should open your profile.ps1 script in notepad..<br />
Edit this Script to include:</p>
<p><code><br />
function elevate-process<br />
      {<br />
              $file, [string]$arguments = $args;<br />
              $psi = new-object System.Diagnostics.ProcessStartInfo $file;<br />
              $psi.Arguments = $arguments;<br />
              $psi.Verb = "runas";<br />
              $psi.WorkingDirectory = get-location;<br />
              [System.Diagnostics.Process]::Start($psi);<br />
      }</p>
<p>set-alias sudo elevate-process;<br />
</code></p>
<p>Now you&#8217;re almost done. After starting a new PowerShell session &#8211; even a non-elevated one &#8211; you can run commands elevated by using the sudo command.<br />
For Illustration:<br />
<code><br />
PS C:\> sudo notepad.exe<br />
</code></p>
<p>If the new PowerShell session should display a warning regarding the execution of scripts, check out my older posts (using the site search), i&#8217;ve postet a solution for that.</p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/intent/tweet?text=PowerShell%3A+UAC%2C+SUDO%2C+Elevation%2C+Access+to+the+path+%E2%80%98C%3A%5CProgram+Files%E2%80%99+is+denied.+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D40" title="Post to Twitter"><img class="nothumb" src="http://www.christiano.ch/wordpress/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/intent/tweet?text=PowerShell%3A+UAC%2C+SUDO%2C+Elevation%2C+Access+to+the+path+%E2%80%98C%3A%5CProgram+Files%E2%80%99+is+denied.+http%3A%2F%2Fchristiano.ch%2Fwordpress%2F%3Fp%3D40" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.christiano.ch/wordpress/2009/07/26/get-content-access-to-the-path-cprogram-files-is-denied/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

