<?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>Ideas For Free &#187; PowerShell</title>
	<atom:link href="http://blog.libinuko.com/tag/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.libinuko.com</link>
	<description>Only freedom will grow our ideas</description>
	<lastBuildDate>Sun, 18 Dec 2011 04:51:16 +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>SharePoint 2010: RemoteStsAdm PowerShell Module is available via NuGet</title>
		<link>http://blog.libinuko.com/2011/12/18/sharepoint-2010-remotestsadm-powershell-module-is-available-via-nuget/</link>
		<comments>http://blog.libinuko.com/2011/12/18/sharepoint-2010-remotestsadm-powershell-module-is-available-via-nuget/#comments</comments>
		<pubDate>Sun, 18 Dec 2011 04:15:43 +0000</pubDate>
		<dc:creator>cakriwut</dc:creator>
				<category><![CDATA[Community Content]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[NuGet]]></category>

		<guid isPermaLink="false">http://blog.libinuko.com/?p=716</guid>
		<description><![CDATA[English: Few month ago I have introduced RemoteStsAdm, a PowerShell module that enable you to execute StsAdm.exe remotely. StsAdm.exe is a command line administration tools for SharePoint. Unfortunately to run StsAdm, one must log-in to SharePoint server member &#8211; since the tool can not be executed remotely. RemoteStsAdm is to answer this problem, allowing admin to [...] <a href="http://blog.libinuko.com/2011/12/18/sharepoint-2010-remotestsadm-powershell-module-is-available-via-nuget/">[read more...]</a>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>English:</p>
<p>Few month ago I have introduced RemoteStsAdm, a PowerShell module that enable you to execute StsAdm.exe remotely. StsAdm.exe is a command line administration tools for SharePoint. Unfortunately to run StsAdm, one must log-in to SharePoint server member &ndash; since the tool can not be executed remotely. RemoteStsAdm is to answer this problem, allowing admin to execute StsAdm remotely. You can download the source code from <a href="http://code.msdn.microsoft.com/windowsdesktop/Remote-StsAdm-in-6fec24b8">MSDN Galery here</a> or read the <a href="http://blog.libinuko.com/2011/09/17/sharepoint-2010-remotestsadm-powershell-module/">original article in previous post here</a>.&nbsp;</p>
<p>Yesterday, I have <a href="http://blog.libinuko.com/2011/12/17/introducing-import-psmodule/">released ImportPSModule</a> that will easy PowerShell module distribution, allow update notification and configuration. The RemoteStsAdm PowerShell module is now available via NuGet, so that you don&rsquo;t need to download and extract manually. All will be done seamlessly, and whenever we got script update &ndash; you will get notified as soon as you open PowerShell session.</p>
<p>So what do you wait for, open PowerShell session and type following:</p>
<div class="wlWriterEditableSmartContent" id="scid:E8C2ABEC-2EDF-4263-8854-38F0AFB6C437:4bb12004-931d-431d-af21-4723eda453ef" style="margin: 0px; padding: 0px; float: none; display: inline;">
<pre class="brush: powershell; title: ; notranslate">Import-PSModule RemoteStsAdm </pre>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.libinuko.com/2011/12/18/sharepoint-2010-remotestsadm-powershell-module-is-available-via-nuget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell: Introducing Import-PSModule</title>
		<link>http://blog.libinuko.com/2011/12/17/introducing-import-psmodule/</link>
		<comments>http://blog.libinuko.com/2011/12/17/introducing-import-psmodule/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 11:32:51 +0000</pubDate>
		<dc:creator>cakriwut</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[NuGet]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://blog.libinuko.com/?p=704</guid>
		<description><![CDATA[You may already know PsGet&#160;by Chaliy or PsGet by Anurse for PowerShell module distribution. They have created PowerShell module&#160;distribution mechanism with different approach. Chaliy uses PowerShell script approach and customized module directory. Everytime you want to distribute your PowerShell module, you have to fork his github project to update Directory.xml content. Even tough the instruction in [...] <a href="http://blog.libinuko.com/2011/12/17/introducing-import-psmodule/">[read more...]</a>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>You may already know <strong><a href="http://psget.net/">PsGet</a>&nbsp;by Chaliy</strong> or <strong><a href="http://vibrantcode.com/blog/2011/2/16/psget-v02now-with-more-awesome-and-fewer-version-numbers.html">PsGet </a>by Anurse</strong> for PowerShell module distribution. They have created PowerShell module&nbsp;distribution mechanism with different approach.</p>
<p>Chaliy uses PowerShell script approach and customized module directory. Everytime you want to distribute your PowerShell module, you have to fork his github project to update Directory.xml content. Even tough the instruction in <a href="https://github.com/chaliy/psget/wiki/How-to-add-your-module-to-the-directory">https://github.com/chaliy/psget/wiki/How-to-add-your-module-to-the-directory</a>&nbsp;is very clear, however<u> I think there is risk of incorrect Directory.xml modification</u>.</p>
<p>Anurse uses PowerShell manifest approach and standard NuGet package to download and put module in appropriate location. In this case you can create a NuGet package containing PowerShell files and publish it to NuGet repository. Using his module, you will be able to get PowerShell module from NuGet repository right to your console. I like this approach because it uses standard NuGet package and publishing process. However, sometimes<strong> I want to be able to register the new module in my profile</strong>. I also want to ensure that I always use latest PowerShell Module&nbsp;package &#8211; ie. <strong>update local module automatically when there is new module in NuGet repository</strong>.</p>
<p>So then, I started to create Import-PSModule a PowerShell script module that will give you functionalities such as:</p>
<ol>
<li>Importing PS Module from NuGet repository</li>
<li>Load imported module to current session</li>
<li>Register imported module to current user profile or all user profile</li>
<li>Un-register imported module from current user profile or all user profile</li>
<li>Auto-update imported module when user start PowerShell session</li>
</ol>
<p>To start using the module, start PowerShell session and type following</p>
<p>&nbsp;&nbsp;
<pre class="brush: powershell; title: ; notranslate">(new-object Net.WebClient).DownloadString(&amp;quot;http://blog.libinuko.com/wp-content/plugins/download-monitor/download.php?id=1&amp;quot;) | iex </pre>
</p>
<p>The script will perform following actions:</p>
<ol>
<li>Download latest ImportPSModule from central NuGet repository.</li>
<li>Install the package to desired location. If you choose to install in User-Module or Global-Module, all future packages will be installed under Module path. If you choose to install in other folder, then all future package will be installed within installation folder.</li>
<li>Load the ImportPSModule to the memory. It will also&nbsp; download latest NuGet.CommandLine package if you don&#39;t have in your system.</li>
</ol>
<p>So what do you waiting for? Start to install the module and publish your PowerShell module in NuGet repository. But don&#39;t forget TAG &quot;<strong>PSModule</strong>&quot; to your NuGet package.</p>
<p>If you want to validate InstallPSModule.ps1, please click here <a class="downloadlink" href="http://blog.libinuko.com/wp-content/plugins/download-monitor/download.php?id=1" title="Version1.0.0 downloaded 116 times" >InstallPSModule (116)</a> .</p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.libinuko.com/2011/12/17/introducing-import-psmodule/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SharePoint 2010 : RemoteStsAdm PowerShell Module</title>
		<link>http://blog.libinuko.com/2011/09/17/sharepoint-2010-remotestsadm-powershell-module/</link>
		<comments>http://blog.libinuko.com/2011/09/17/sharepoint-2010-remotestsadm-powershell-module/#comments</comments>
		<pubDate>Sat, 17 Sep 2011 04:50:26 +0000</pubDate>
		<dc:creator>cakriwut</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[StsAdm]]></category>

		<guid isPermaLink="false">http://blog.libinuko.com/2011/09/17/sharepoint-2010-remotestsadm-powershell-module/</guid>
		<description><![CDATA[English The STSADM.exe is command-line tool for administration of Office SharePoint Server (SharePoint 2007, SharePoint 2010). It is installed on the same location as SharePoint Products and Technologies location: %COMMONPROGRAMFILES%\Microsoft Shared\Web Server Extensions\12\bin (for SharePoint 2007) or %COMMONPROGRAMFILES%\Microsoft Shared\Web Server Extensions\14\bin (for SharePoint 2010). You must be Farm Administrator to be able to run the tool. By [...] <a href="http://blog.libinuko.com/2011/09/17/sharepoint-2010-remotestsadm-powershell-module/">[read more...]</a>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>English</p>
<p>The STSADM.exe is command-line tool for administration of Office SharePoint Server (SharePoint 2007, SharePoint 2010). It is installed on the same location as SharePoint Products and Technologies location: %COMMONPROGRAMFILES%\Microsoft Shared\Web Server Extensions\12\bin (for SharePoint 2007) or %COMMONPROGRAMFILES%\Microsoft Shared\Web Server Extensions\14\bin (for SharePoint 2010). You must be Farm Administrator to be able to run the tool.</p>
<p>By default, the STSADM.exe must be executed locally since it will access SharePoint Object Model. It is also necessary for the tools to connect to the SQL Database using credential of the user who executes it. Therefore, normally the Administrator must remote-login to the SharePoint server before he/she can run the tools.</p>
<p>Remote execution of STSADM.exe using PowerShell <em>Invoke-Command </em>cmdlet faces double-hop challenges. This occurs when SQL Database for the farms is installed on different machine than the SharePoint server. The credential in the<em>Invoke-Command </em>session can not pass through to the SQL Database without configuring delegation in the WinRM services.<strong>This module solve double-hop problem without configuring CredSSP</strong>.</p>
<p>Download the module here:   <br /><a title="http://code.msdn.microsoft.com/Remote-StsAdm-in-6fec24b8" href="http://code.msdn.microsoft.com/Remote-StsAdm-in-6fec24b8">http://code.msdn.microsoft.com/Remote-StsAdm-in-6fec24b8</a></p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.libinuko.com/2011/09/17/sharepoint-2010-remotestsadm-powershell-module/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SharePoint 2010: Remote StsAdm using PowerShell</title>
		<link>http://blog.libinuko.com/2011/08/24/powershell-remote-stsadm-using-powershell/</link>
		<comments>http://blog.libinuko.com/2011/08/24/powershell-remote-stsadm-using-powershell/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 16:39:45 +0000</pubDate>
		<dc:creator>cakriwut</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[StsAdm]]></category>

		<guid isPermaLink="false">http://blog.libinuko.com/2011/08/24/powershell-remote-stsadm-using-powershell/</guid>
		<description><![CDATA[English In large network, issuing a command to remote server from current terminal is sometimes necessary. Some propose client-server mode; for example Remote StsAdm (http://netstsadm.codeplex.com/) and other propose to use PsExec (http://thingsthatshouldbeeasy.blogspot.com/2009/08/run-stsadm-commands-remotely.html). The client-server mode requires installation of 3rd party tools. This kind of installation sometimes (or most of the time) is forbidden by company security [...] <a href="http://blog.libinuko.com/2011/08/24/powershell-remote-stsadm-using-powershell/">[read more...]</a>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p><strong><em>English </em></strong></p>
<p>In large network, issuing a command to remote server from current terminal is sometimes necessary. Some propose client-server mode; for example Remote StsAdm (<a href="http://netstsadm.codeplex.com/">http://netstsadm.codeplex.com/</a>) and other propose to use PsExec (<a href="http://thingsthatshouldbeeasy.blogspot.com/2009/08/run-stsadm-commands-remotely.html">http://thingsthatshouldbeeasy.blogspot.com/2009/08/run-stsadm-commands-remotely.html</a>).</p>
<p>The client-server mode requires installation of 3rd party tools. This kind of installation sometimes (or most of the time) is forbidden by company security policy. <br />
	Second option using PsExec from SysInternal (now part of Microsoft) doesn&#39;t requires installation to SharePoint server and may be the correct approach. However, I am not convince that this tools will be compatible with the future Operating System.</p>
<p><strong>So, what is the option? </strong> <br />
	PowerShell and Remoting!</p>
<p>PowerShell has been introduced during Windows 2008 era. However, Windows 2003 server owner can apply KB968930 (http://support.microsoft.com/kb/968930) to bring PowerShell functionality to their server. PowerShell will replace command.com because of the flexibility &#8211; enabling integration between shell and operating system itself.</p>
<p><strong>Let&#39;s get our job done </strong></p>
<p>1. First enable remoting on the SharePoint Server.</p>
<pre class="brush: ps;  html-script: false">    Enable-PSRemoting -Force</pre>
<p>2.&nbsp; Prepare the stsadm command alias</p>
<pre class="brush: ps; html-script: false"> $executable = &quot;$env:ProgramFiles\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe&quot; </pre>
<p>&nbsp;</p>
<p>3.&nbsp; Remember my previous post about how to avoid double hop problem? (<a href="http://blog.libinuko.com/2011/04/29/powershell-how-to-overcome-double-hop-problem-in-powershell-remoting-2/" title="http://blog.libinuko.com/2011/04/29/powershell-how-to-overcome-double-hop-problem-in-powershell-remoting-2/">http://blog.libinuko.com/2011/04/29/powershell-how-to-overcome-double-hop-problem-in-powershell-remoting-2/</a>) . Now we will create new function that uses Invoke-RemoteCommand. Basically, we will construct commandline parameter for Invoke-RemoteCommand. We also try to provide AS-IF user call stsadm.</p>
<pre class="brush:ps; html-script: false">function StsAdm
{
   param(
      [string] $commandOptions,
      [string] $username,
      [string] $password
   )

   $executable = &quot;$env:ProgramFiles\Common Files\Microsoft Shared\web server extensions\12\bin\stsadm.exe&quot;

   Invoke-RemoteCommand -commandline &quot;&#39;$executable&#39; $commandOptions&quot; -username $username -password $password

}

Usage : StsAdm -commandOptions &quot;-o enumwebs&quot; -username &quot;setup account&quot; -password &quot;setup password&quot;</pre>
<p>And voila, you have remote stsadm function without compromising security policy.</p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.libinuko.com/2011/08/24/powershell-remote-stsadm-using-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell : Compress files with Windows an improved version</title>
		<link>http://blog.libinuko.com/2011/06/09/powershell-compress-files-with-windows-an-improved-version/</link>
		<comments>http://blog.libinuko.com/2011/06/09/powershell-compress-files-with-windows-an-improved-version/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 14:43:00 +0000</pubDate>
		<dc:creator>cakriwut</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Howto]]></category>

		<guid isPermaLink="false">http://blog.libinuko.com/?p=666</guid>
		<description><![CDATA[English When I am looking for a way to compress file(s) into Zip, I find a blog from David Aiken here (Compress Files with Windows PowerShell then package a Windows Vista Sidebar Gadget) . I will just focus on Add-Zip function and nothing more. Here is the original code: &#160; function Add-Zip { param([string]$zipfilename) [...] <a href="http://blog.libinuko.com/2011/06/09/powershell-compress-files-with-windows-an-improved-version/">[read more...]</a>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>English</p>
<p>When I am looking for a way to compress file(s) into Zip, I find a blog from David Aiken here (<a href="http://blogs.msdn.com/b/daiken/archive/2007/02/12/compress-files-with-windows-powershell-then-package-a-windows-vista-sidebar-gadget.aspx">Compress Files with Windows PowerShell then package a Windows Vista Sidebar Gadget</a>) . I will just focus on Add-Zip function and nothing more.</p>
<p>Here is the original code:</p>
<p>&#160;</p>
<pre class="brush: ps; highlight: [12,16]; html-script: false">function Add-Zip
{
    param([string]$zipfilename) 

    if(-not (test-path($zipfilename)))
    {
           set-content $zipfilename (&quot;PK&quot; + [char]5 + [char]6 + (&quot;$([char]0)&quot; * 18))
           (dir $zipfilename).IsReadOnly = $false
     } 

     $shellApplication = new-object -com shell.application
     $zipPackage = $shellApplication.NameSpace($zipfilename) 

     foreach($file in $input)
     {
            $zipPackage.CopyHere($file.FullName)
            Start-sleep -milliseconds 500
     }
}

usage: dir c:\demo\files\*.* -Recurse | add-Zip c:\demo\myzip.zip</pre>
<p>I am raising two problems with the code:</p>
<p>1. Looking at the usage example, it is clear that the function accept <strong>only fully path filename</strong>. The reason, on line-12 , the $shellApplication.NameSpace parameter is $zipfilename; and this is not possible without giving fully path filename. </p>
<p>2. On line-16, the operation expect that $input array will contains object with FullName properties, that why the usage example uses DIR. What about if you just want to specify a filename?</p>
<p>With the 2 problem above, I am ready to improve that function. In the new improved version, Get-ChildItem will help us to convert any string representation of a file to a fully path filename. It won’t break DIR piping functionality, since actually Get-ChildItem is dir (and extra) functionality.</p>
<p>Here is the improved version:</p>
<pre class="brush: ps; highlight: [5,15,16]; html-script: false">function Add-Zip
{
	param([string]$zipfilename)

    $currFile = $zipfilename | get-childitem
	if(-not (test-path($zipfilename)))
	{
		set-content $currFile.FullName (&quot;PK&quot; + [char]5 + [char]6 + (&quot;$([char]0)&quot; * 18))
		(dir $currFile.FullName).IsReadOnly = $false
	}

	$shellApplication = new-object -com shell.application
	$zipPackage = $shellApplication.NameSpace($currFile.Fullname)

	$input | % {
            $file = $_ | get-childitem
            $zipPackage.CopyHere($file.FullName)
            Start-sleep -milliseconds 500
	}
}

usage: &quot;FileInThisFolder.txt&quot; -Recurse | add-Zip &quot;ZipInThisFolder.zip&quot;
        dir c:\demo\files\*.* -Recurse | add-Zip c:\demo\myzip.zip</pre>
<p>So, I hope you enjoy the improved version.</p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.libinuko.com/2011/06/09/powershell-compress-files-with-windows-an-improved-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell : How to overcome double-hop problem in PowerShell remoting</title>
		<link>http://blog.libinuko.com/2011/04/29/powershell-how-to-overcome-double-hop-problem-in-powershell-remoting-2/</link>
		<comments>http://blog.libinuko.com/2011/04/29/powershell-how-to-overcome-double-hop-problem-in-powershell-remoting-2/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 09:34:00 +0000</pubDate>
		<dc:creator>cakriwut</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://blog.libinuko.com/2011/04/29/powershell-how-to-overcome-double-hop-problem-in-powershell-remoting-2/</guid>
		<description><![CDATA[English: I am interesting to the PowerShell remoting topic from PowerShell Cookbook Chapter 29 here (http://www.pavleck.net/powershell-cookbook/ch29.html). In order to solve double-hop problem, it uses schedule task. The sample create schedule task to Enable-PSRemoting in remote machine. But don’t you think we need something more generic to overcome double-hop problem? PowerShell offers Enable-WSManCredSSP or Kerberos so that the [...] <a href="http://blog.libinuko.com/2011/04/29/powershell-how-to-overcome-double-hop-problem-in-powershell-remoting-2/">[read more...]</a>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>English:</p>
<p>I am interesting to the PowerShell remoting topic from PowerShell Cookbook Chapter 29 here (<a title="http://www.pavleck.net/powershell-cookbook/ch29.html" href="http://www.pavleck.net/powershell-cookbook/ch29.html">http://www.pavleck.net/powershell-cookbook/ch29.html</a>). In order to solve double-hop problem, it uses schedule task. The sample create schedule task to Enable-PSRemoting in remote machine.</p>
<p>But don’t you think we need something more generic to overcome double-hop problem? PowerShell offers Enable-WSManCredSSP or Kerberos so that the process can delegates the credential to execute next-hop process. However,  CredSSP is only available on Windows 7 and above. What about OS before Windows 7 or Windows Server 2008?  If you have Windows 7 or Windows Server 2008 – you may follow tutorial in this link (<a title="http://www.ravichaganti.com/blog/?p=1230" href="http://www.ravichaganti.com/blog/?p=1230">http://www.ravichaganti.com/blog/?p=1230</a>). But if you have Windows 2003 or previous version, then you must keep reading.</p>
<p>So, lets start by defining our function Invoke-RemoteCommand. This command will accept :</p>
<p>1. (Optional) Taskname, name of task identifier<br />
2. Commandline, actual command for example powershell or cmd.exe<br />
3. Username, credential to execute the command<br />
4. Password, password for the credential to execute the command</p>
<div id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:18da64f8-eb0d-4d0a-9cc2-0ea02f884616" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<pre class="brush: powershell; gutter: true; first-line: 1; tab-size: 4;  toolbar: true; ">function Invoke-RemoteCommand{

    param(
       [System.String]
       $taskname = (get-date -format "'Demo task' dd-MM-yyyy hh.mm.ss"),

       [System.String]
       $commandline = "cmd /c 'dir c:\'",

       [Parameter(Mandatory=$true)]
       [String]
       $username,

       [parameter(Mandatory = $true)]
       [String]
       $password
   )

    schtasks /create /tn $taskname /tr $commandline /sc weekly  /ru $username /rp $password | out-null
    schtasks /run /tn $taskname | out-null
    write-host "Waiting task execution." -nonewline -foreground green
    do {
      $taskStatus = schtasks /query /fo csv /v | convertfrom-csv | ? { $_.TaskName.TrimStart("\") -eq "$taskname"}
      sleep 10
      write-host "." -nonewline -foreground green
    } while ($taskStatus."Status" -eq "Running")
    write-host "Success!" -foreground green
    schtasks /delete /tn $taskname /f | out-null
    return $taskStatus
}</pre>
<p>&nbsp;</p>
<p>The function will create schedule task on remote machine, execute, wait until execution complete and return the result.</p></div>
<p>For example, we want to list directory of the ServerX by issuing command to ServerY. Normally, following command will fail because of double-hop problem (it doesn’t matter whether you supply user credential, it will still failed):</p>
<div id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:ac27d6ef-2c31-4cd1-965a-67e91c478a52" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<pre class="brush: powershell; gutter: true; first-line: 1; tab-size: 4;  toolbar: true; ">Invoke-Command -ComputerName ServerY -Script { "dir \\ServerX\d$" }</pre>
<p>&nbsp;</p>
</div>
<p>Using the new function, we change the command into</p>
<div id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:279054e4-83f7-4d63-a860-568d720f9fb6" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<pre class="brush: powershell; gutter: true; first-line: 1; tab-size: 4;  toolbar: true; ">invoke-command -script { Invoke-RemoteCommand -cmd "powershell -noprofile -command 'dir \\ServerX\d$'" -username "domain\user" -password "password" }</pre>
<p>&nbsp;</p>
</div>
<p>The last script will performs following:</p>
<p>1. Create schedule tasks with a specific identifier</p>
<p>2. Command in schedule task is “powershell –noprofile …..”</p>
<p>3. Execute schedule tasks</p>
<p>4. Wait until execution completes</p>
<p>5. Return the status</p>
<p>Finally, the script will work in Windows 2003 , Windows 7, Windows Vista or Windows 2008.</p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.libinuko.com/2011/04/29/powershell-how-to-overcome-double-hop-problem-in-powershell-remoting-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SharePoint 2010: How to change rating icons</title>
		<link>http://blog.libinuko.com/2010/12/27/sharepoint-2010-how-to-change-rating-icons/</link>
		<comments>http://blog.libinuko.com/2010/12/27/sharepoint-2010-how-to-change-rating-icons/#comments</comments>
		<pubDate>Sun, 26 Dec 2010 17:19:11 +0000</pubDate>
		<dc:creator>cakriwut</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Howto]]></category>

		<guid isPermaLink="false">http://blog.libinuko.com/2010/12/27/sharepoint-2010-how-to-change-rating-icons/</guid>
		<description><![CDATA[English: Sometimes you may received a request to change rating icons, from a normal star to a love icon. So, how would you do it? Figure 1. Original rating icons Figure 2. Modified love rating icons 1. Find and prepare rating icons.  In this case I will need to prepare 4 styles rating icons Title Sample Size a. Empty Rating 16&#215;16 b. Selected Rating 16&#215;16 c. Rating [...] <a href="http://blog.libinuko.com/2010/12/27/sharepoint-2010-how-to-change-rating-icons/">[read more...]</a>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>English:</p>
<p>Sometimes you may received a request to change rating icons, from a normal star to a love icon. So, <strong>how would you do it</strong>?</p>
<p><a href="http://blog.libinuko.com/files/2010/12/OriginalRating.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="OriginalRating" src="http://blog.libinuko.com/files/2010/12/OriginalRating_thumb.png" border="0" alt="OriginalRating" width="709" height="275" /></a><br />
<strong><em>Figure 1. Original rating icons</em></strong></p>
<p><a href="http://blog.libinuko.com/files/2010/12/LoveRating.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="LoveRating" src="http://blog.libinuko.com/files/2010/12/LoveRating_thumb.png" border="0" alt="LoveRating" width="710" height="261" /></a><br />
<em><strong>Figure 2. Modified love rating icons</strong></em></p>
<p>1. Find and prepare rating icons.  In this case I will need to prepare 4 styles rating icons</p>
<table border="1" cellspacing="0" cellpadding="2" width="681">
<tbody>
<tr>
<td width="286" valign="top"><strong>Title</strong></td>
<td width="258" valign="top"><strong>Sample</strong></td>
<td width="135" valign="top"><strong>Size</strong></td>
</tr>
<tr>
<td width="286" valign="top">a. Empty Rating</td>
<td width="258" valign="top"><a href="http://blog.libinuko.com/files/2010/12/love_ratingempty.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="love_ratingempty" src="http://blog.libinuko.com/files/2010/12/love_ratingempty_thumb.png" border="0" alt="love_ratingempty" width="20" height="20" /></a></td>
<td width="135" valign="top">16&#215;16</td>
</tr>
<tr>
<td width="286" valign="top">b. Selected Rating</td>
<td width="258" valign="top"><a href="http://blog.libinuko.com/files/2010/12/love_RatingsNew.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="love_RatingsNew" src="http://blog.libinuko.com/files/2010/12/love_RatingsNew_thumb.png" border="0" alt="love_RatingsNew" width="20" height="20" /></a></td>
<td width="135" valign="top">16&#215;16</td>
</tr>
<tr>
<td width="286" valign="top">c. Rating Overlay</td>
<td width="258" valign="top"><a href="http://blog.libinuko.com/files/2010/12/love_ratings.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="love_ratings" src="http://blog.libinuko.com/files/2010/12/love_ratings_thumb.png" border="0" alt="love_ratings" width="309" height="21" /></a></td>
<td width="135" valign="top">448&#215;16</td>
</tr>
<tr>
<td width="286" valign="top">d. Rating Overlay RightToLeft</td>
<td width="258" valign="top"><a href="http://blog.libinuko.com/files/2010/12/love_Ratingsrtl.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="love_Ratingsrtl" src="http://blog.libinuko.com/files/2010/12/love_Ratingsrtl_thumb.png" border="0" alt="love_Ratingsrtl" width="305" height="24" /></a></td>
<td width="135" valign="top">448&#215;16</td>
</tr>
</tbody>
</table>
<p> </p>
<p>2. Save the new icons under 14 hive\Images.</p>
<p>3. Create script to modify SPWeb property bag. To ease our job, I will use PowerShell script as follows,</p>
<blockquote><p><span style="font-family: Century Gothic;"><strong><span style="color: #8fb08c;">[System.Reflection.Assembly]::</span>LoadWithPartialName(<span style="color: #c0504d;">&#8220;Microsoft.SharePoint&#8221;</span>) &gt; <span style="color: #ff0000;">$null<br />
</span></strong></span><span style="font-family: Century Gothic;"><strong><span style="color: #ff0000;"><br />
$spSite</span> = <span style="color: #0000ff;">new-object</span> <span style="color: #646b86;">Microsoft.SharePoint.SPSite</span><span style="color: #c0504d;">(&#8220;</span></strong></span><span style="font-family: Century Gothic;"><strong><span style="color: #c0504d;">http://win2k8&#8243;);</span></strong></span><br />
<span style="font-family: Century Gothic;"><strong><span style="color: #ff0000;">$spWeb</span> = $spSite.OpenWeb();</strong></span></p>
<p><span style="font-family: Century Gothic;"><strong><span style="color: #ff0000;">$spWeb</span>.Properties["Ratings_NewRatingIconUrl"] =<span style="color: #c0504d;"> &#8220;/_layouts/Images/love_RatingsNew.png&#8221;</span>;<br />
<span style="color: #ff0000;">$spWeb</span>.Properties["Ratings_EmptyIconUrl"] = <span style="color: #c0504d;">&#8220;/_layouts/Images/love_RatingsEmpty.png&#8221;</span>;<br />
<span style="color: #ff0000;">$spWeb</span>.Properties["Ratings_ImageStripUrl"] = <span style="color: #c0504d;">&#8220;/_layouts/Images/love_Ratings.png&#8221;</span>;<br />
<span style="color: #ff0000;">$spWeb</span>.Properties["Ratings_ImageStripRtlUrl"] =<span style="color: #c0504d;"> &#8220;/_layouts/Images/love_Ratingsrtl.png&#8221;</span>;</strong></span></p>
<p><span style="font-family: Century Gothic;"><strong><span style="color: #ff0000;">$spWeb</span>.Properties.Update();<br />
<span style="color: #ff0000;">$spWeb</span>.Dispose();<br />
<span style="color: #ff0000;">$spSite</span>.Dispose();</strong></span></p>
<p><span style="font-family: Century Gothic; color: #0000ff;"><strong>iisreset</strong></span></p></blockquote>
<p> </p>
<p>4. Voila ! And you can refresh your browser to see the changes.</p>
<p>5. Finally you can distribute your solution into a solutions package with feature activation events to register/un-register custom rating images.</p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.libinuko.com/2010/12/27/sharepoint-2010-how-to-change-rating-icons/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PowerShell : Modifying Web AppPool Account</title>
		<link>http://blog.libinuko.com/2010/07/28/powershell-modifying-web-apppool-account-2/</link>
		<comments>http://blog.libinuko.com/2010/07/28/powershell-modifying-web-apppool-account-2/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 14:52:31 +0000</pubDate>
		<dc:creator>cakriwut</dc:creator>
				<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://blog.libinuko.com/2010/07/28/powershell-modifying-web-apppool-account-2/</guid>
		<description><![CDATA[English I think you may already know Set-SPServiceApplicationPool. This command can be used to modify apppool account for service application &#8211; but it doesn&#8217;t work for Web Application. I am looking for Set-SPWebApplicationPool but I can not find it anywhere. So here is the PowerShell script &#160; param([string] $url, [string] $account) $SPWebApp = Get-SPWebApplication $url $SPManagedAccount = Get-SPManagedAccount –Identity [...] <a href="http://blog.libinuko.com/2010/07/28/powershell-modifying-web-apppool-account-2/">[read more...]</a>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>English </p>
<p>I think you may already know Set-SPServiceApplicationPool. This command can be used to modify apppool account for service application &#8211; but it doesn&#8217;t work for Web Application. I am looking for Set-SPWebApplicationPool but I can not find it anywhere.</p>
<p><a href="http://blog.libinuko.com/files/2010/07/image.png"><img style="border-right-width: 0px;border-top-width: 0px;border-bottom-width: 0px;border-left-width: 0px" border="0" alt="image" src="http://blog.libinuko.com/files/2010/07/image_thumb.png" width="614" height="322" /></a> </p>
<p>So here is the PowerShell script</p>
<p>&#160;</p>
<blockquote><p>param([string] $url, [string] $account)</p>
<p>$SPWebApp = Get-SPWebApplication $url</p>
<p>$SPManagedAccount = Get-SPManagedAccount –Identity $account</p>
<p>$SPWebApp.ApplicationPool.ManagedAccount = $SPManagedAccount</p>
<p>$SPWebApp.ApplicationPool.Update()</p>
</blockquote>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.libinuko.com/2010/07/28/powershell-modifying-web-apppool-account-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell : Desktop Experience Feature</title>
		<link>http://blog.libinuko.com/2010/07/28/powershell-desktop-experience-feature/</link>
		<comments>http://blog.libinuko.com/2010/07/28/powershell-desktop-experience-feature/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 08:58:17 +0000</pubDate>
		<dc:creator>cakriwut</dc:creator>
				<category><![CDATA[Office 2010]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Desktop Experience]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Windows 2008]]></category>

		<guid isPermaLink="false">http://blog.libinuko.com/?p=555</guid>
		<description><![CDATA[English Today I find a strange behaviour, my Office 2010 can not browse to the SharePoint 2010 document library. In short, I can not save my document directly to SharePoint 2010.&#160; Office 2010 provide Save and Send functionality, which should give me functionality to save directly to SharePoint 2010 as what it does in previous version; [...] <a href="http://blog.libinuko.com/2010/07/28/powershell-desktop-experience-feature/">[read more...]</a>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>English</p>
<p>Today I find a strange behaviour, my Office 2010 can not browse to the SharePoint 2010 document library. In short, I can not save my document directly to SharePoint 2010.&#160; Office 2010 provide Save and Send functionality, which should give me functionality to save directly to SharePoint 2010 as what it does in previous version; so what could be the problem?</p>
<p>Saving to SharePoint 2010 document library requires WebDAV functionality via Web Client service. Unfortunatelly the Web Client service is not enabled by default, and it is part of <a href="http://technet.microsoft.com/en-us/library/cc772567.aspx">Desktop Experience features</a>.&#160; So, how can we enable it using PowerShell?</p>
<blockquote><p># Open PowerShell console and then type</p>
<p>import-module servermanager     <br />Add-WindowsFeature Desktop-Experience</p>
</blockquote>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.libinuko.com/2010/07/28/powershell-desktop-experience-feature/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell : Working with XML</title>
		<link>http://blog.libinuko.com/2010/07/15/powershell-working-with-xml/</link>
		<comments>http://blog.libinuko.com/2010/07/15/powershell-working-with-xml/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 11:49:55 +0000</pubDate>
		<dc:creator>cakriwut</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://blog.libinuko.com/2010/07/15/powershell-working-with-xml/</guid>
		<description><![CDATA[English I have found 2 good articles on how work with XML in PowerShell. http://www.pluralsight-training.net/community/blogs/dan/archive/2006/11/25/42506.aspx http://www.pluralsight-training.net/community/blogs/dan/archive/2006/11/28/43561.aspx Don’t be surprised that you will find % notation that represent ForEach-Object.  <a href="http://blog.libinuko.com/2010/07/15/powershell-working-with-xml/">[read more...]</a>]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>English</p>
<p>I have found 2 good articles on how work with XML in PowerShell. </p>
<p><a title="http://www.pluralsight-training.net/community/blogs/dan/archive/2006/11/25/42506.aspx" href="http://www.pluralsight-training.net/community/blogs/dan/archive/2006/11/25/42506.aspx">http://www.pluralsight-training.net/community/blogs/dan/archive/2006/11/25/42506.aspx</a>     <br /><a title="http://www.pluralsight-training.net/community/blogs/dan/archive/2006/11/28/43561.aspx" href="http://www.pluralsight-training.net/community/blogs/dan/archive/2006/11/28/43561.aspx">http://www.pluralsight-training.net/community/blogs/dan/archive/2006/11/28/43561.aspx</a></p>
<p>Don’t be surprised that you will find<strong> %</strong> notation that represent ForEach-Object. </p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://blog.libinuko.com/2010/07/15/powershell-working-with-xml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

