<?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>Techibee.com &#187; PowerShell</title>
	<atom:link href="http://techibee.com/category/powershell/feed" rel="self" type="application/rss+xml" />
	<link>http://techibee.com</link>
	<description>A System Administrator&#039;s Blog</description>
	<lastBuildDate>Mon, 21 May 2012 14:13:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Powershell: Most useful powershell commands for XenApp environment</title>
		<link>http://techibee.com/powershell/powershell-most-useful-powershell-commands-for-xenapp-environment/1659?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-most-useful-powershell-commands-for-xenapp-environment</link>
		<comments>http://techibee.com/powershell/powershell-most-useful-powershell-commands-for-xenapp-environment/1659#comments</comments>
		<pubDate>Mon, 21 May 2012 05:42:57 +0000</pubDate>
		<dc:creator>Sitaram Pamarthi</dc:creator>
				<category><![CDATA[Citrix]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[citrix]]></category>
		<category><![CDATA[Get all Desktops published in XenApp environment]]></category>
		<category><![CDATA[Get all published applications on a Server]]></category>
		<category><![CDATA[Get the computer(or client) name from where a Application is launched]]></category>
		<category><![CDATA[Get the list of Users currently using a published Application]]></category>
		<category><![CDATA[Get the users or groups who has permission to a published application]]></category>
		<category><![CDATA[How to get the list of processes running in a given XenApp session on server]]></category>
		<category><![CDATA[Logoff a user(user1) session who opened "MS Word" application in XenApp]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[XenApp]]></category>

		<guid isPermaLink="false">http://techibee.com/?p=1659</guid>
		<description><![CDATA[This is continuation to my previous post. I want to add more commands that System Administrator require to manage XenApp environment using powershell. Below are some of them. I will extend the list as and when I find something. Get the list of Users currently using a published Application: Get-XASession -BrowserName notepad &#124; select AccountName [...]]]></description>
			<content:encoded><![CDATA[<p>This is continuation to <a href="http://techibee.com/powershell/powershell-how-to-get-list-of-citrix-xenapp-servers-publishing-a-given-application/1655">my previous</a> post. I want to add more commands that System Administrator require to manage XenApp environment using powershell. Below are some of them. I will extend the list as and when I find something.</p>
<h4>Get the list of Users currently using a published Application:</h4>
<p>Get-XASession -BrowserName notepad | select AccountName</p>
<h4>Get the computer(or client) name from where a Application is launched</h4>
<p>Get-XASession -BrowerName notepad | select ClientName, AccountName</p>
<h4>Logoff a user(user1) session who opened &#8220;MS Word&#8221; application in XenApp:</h4>
<p>(Get-XASession -BrowserName &#8220;MS Word&#8221; -ServerName XenAPP1 | ? {$_.AccountName -match &#8220;User1&#8243; }).SessionID | Stop-XASession</p>
<h4>Get all published applications on a Server</h4>
<p>Get-XAApplication -ServerName XenApp1 | select DisplayName</p>
<h4>Get all Desktops published in XenApp environment</h4>
<p>Get-XAApplication | ? {$_.ApplicationType -eq &#8220;ServerDesktop&#8221; } | select DisplayName</p>
<h4>Get the users or groups who has permission to a published application:</h4>
<p>Get-XAAccount -BrowserName App1</p>
<h4>How to get the list of processes running in a given XenApp session on server:</h4>
<p>Get-XASessionProecss -ServerName XenApp1 -Sessionid 10</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://techibee.com/powershell/powershell-most-useful-powershell-commands-for-xenapp-environment/1659/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell: How to get list of Citrix XenApp Servers publishing a given Application</title>
		<link>http://techibee.com/powershell/powershell-how-to-get-list-of-citrix-xenapp-servers-publishing-a-given-application/1655?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-how-to-get-list-of-citrix-xenapp-servers-publishing-a-given-application</link>
		<comments>http://techibee.com/powershell/powershell-how-to-get-list-of-citrix-xenapp-servers-publishing-a-given-application/1655#comments</comments>
		<pubDate>Mon, 21 May 2012 03:41:47 +0000</pubDate>
		<dc:creator>Sitaram Pamarthi</dc:creator>
				<category><![CDATA[Citrix]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[citrix]]></category>
		<category><![CDATA[get citrix installed applicaitons]]></category>
		<category><![CDATA[get XenApp servers list powershell]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://techibee.com/?p=1655</guid>
		<description><![CDATA[Today I got a requirement to find out the list of Citrix XenApp Servers where a application is published. All I have is the name of the published application. Though I have been using powershell for a while now, I never tried it in Citrix environment. I took me some time to figure out the [...]]]></description>
			<content:encoded><![CDATA[<p>Today I got a requirement to find out the list of Citrix XenApp Servers where a application is published. All I have is the name of the published application. Though I have been using powershell for a while now, I never tried it in Citrix environment. I took me some time to figure out the Add-Ins, modules required for querying the XenApp6 environment.  After familiarizing with XenApp powershell commands, I realized there is lot I can do with it in XenApp environment. And it is faster than GUI.</p>
<p>So, here is the script I am talking about which takes application name as parameter and displays the XenApp servers where it is published, Accounts that have access to it, path of the application, Type of the application(streamed/serverInstalled), Executable path and many more details.</p>
<p>Note that you need to download and install <a href="http://community.citrix.com/display/xa/XenApp+6+PowerShell+SDK">Citrix XenApp 6 Powershell SDK</a> to get the required SnapIns. This is not required if you are running the script from a XenApp server since it already contains the required Powershell SDK installation.</p>
<pre class="PowerShellColorizedScript"><span style="color: #00008b;">function</span> <span style="color: #8a2be2;">Get-CitrixPublishedApplicationDetails</span> <span style="color: #000000;">{</span>
<span style="color: #a9a9a9;">[</span><span style="color: #add8e6;">cmdletbinding</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">]</span>
<span style="color: #00008b;">param</span><span style="color: #000000;">(</span>
<span style="color: #008080;">[string]</span><span style="color: #ff4500;">$AppName</span>
<span style="color: #000000;">)</span>            

<span style="color: #0000ff;">Add-PsSnapIn</span> <span style="color: #8a2be2;">Citrix*</span>
<span style="color: #0000ff;">Get-XAApplicationReport</span> <span style="color: #000080;">-BrowserName</span> <span style="color: #ff4500;">$AppName</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Select</span> <span style="color: #8a2be2;">DisplayName</span><span style="color: #a9a9a9;">,</span> <span style="color: #8a2be2;">ServerNames</span><span style="color: #a9a9a9;">,</span> <span style="color: #8a2be2;">Accounts</span><span style="color: #a9a9a9;">,</span> <span style="color: #8a2be2;">ApplicationType</span><span style="color: #a9a9a9;">,</span> <span style="color: #8a2be2;">ClientFolder</span><span style="color: #a9a9a9;">,</span> <span style="color: #8a2be2;">CommandlineExecutable</span>            

<span style="color: #000000;">}</span></pre>
<p><strong>Usage:</strong></p>
<p>Get-CitrixPublishedApplicationDetails -AppName Notepad</p>
<p>Hope this helps&#8230;</p>
<p>[update]</p>
<p>There is another way available as well which returns the list of XenApp Servers on which a given application is hosted.</p>
<p><strong>Get-XAServer -BrowserName Notepad | select ServerName</strong></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://techibee.com/powershell/powershell-how-to-get-list-of-citrix-xenapp-servers-publishing-a-given-application/1655/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Powershell: Unexpected attribute ‘cmdletbinding’(ParentContainsErrorRecordException)</title>
		<link>http://techibee.com/powershell/powershell-unexpected-attribute-cmdletbindingparentcontainserrorrecordexception/1651?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-unexpected-attribute-cmdletbindingparentcontainserrorrecordexception</link>
		<comments>http://techibee.com/powershell/powershell-unexpected-attribute-cmdletbindingparentcontainserrorrecordexception/1651#comments</comments>
		<pubDate>Sun, 20 May 2012 15:43:51 +0000</pubDate>
		<dc:creator>Sitaram Pamarthi</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[cmdletbinding error powershell]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://techibee.com/?p=1651</guid>
		<description><![CDATA[I get the below error sometimes while working with powershell scripts. Every time I end up spending some efforts to recollect what I have done previously to fix this. This time I decided to document it for my quick reference and for other powershell users. ERROR Message: Unexpected attribute ‘cmdletbinding’. At line:24 char:15 + [cmdletbinding [...]]]></description>
			<content:encoded><![CDATA[<p>I get the below error sometimes while working with powershell scripts. Every time I end up spending some efforts to recollect what I have done previously to fix this. This time I decided to document it for my quick reference and for other powershell users.</p>
<h2><strong>ERROR Message:</strong></h2>
<p><span style="color: #ff0000;">Unexpected attribute ‘cmdletbinding’.</span><br />
<span style="color: #ff0000;"> At line:24 char:15</span><br />
<span style="color: #ff0000;"> + [cmdletbinding &lt;&lt;&lt;&lt; ()] + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnexpectedAttribute</span></p>
<h2>When we will get this error?</h2>
<p>This error we will generally observe when copy pasting a function from script to powershell console for quick execution. It is also quite possible that you might get this error while running some script or importing a function.</p>
<h2>What are the causes for this error?</h2>
<p>Mainly there are two cases where you will get this error.</p>
<h3>Missing of param declaration:</h3>
<p>We declare [cmdletbinding()] in a function or script but may miss to declare parameters after that. It is possible that your script/function doesn&#8217;t requires any parameters but you still need to declare it like <strong>param ( )</strong>. Otherwise you will get the above error.</p>
<p>So, it is general thump rule that [cmdletbinding()] should follow param() like below.</p>
<pre class="PowerShellColorizedScript">
<span style="color: #00008b;">function</span> <span style="color: #8a2be2;">foo-bar</span> <span style="color: #000000;">{</span>
<span style="color: #a9a9a9;">[</span><span style="color: #add8e6;">cmdletbinding</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">]</span>
<span style="color: #00008b;">param</span> <span style="color: #000000;">(</span>
<span style="color: #000000;">)</span>
<span style="color: #0000ff;">...</span>
<span style="color: #0000ff;">...</span>
<span style="color: #0000ff;">...</span>
<span style="color: #000000;">}</span></pre>
<h3>A new line between [cmdletbinding()] and param declaration:</h3>
<p>Just try copy pasting the below code into a powershell window and let me know what happens. You will definitely observe the above given error. This is because of the new line between [cmdletbinding()] and param declaration. Now remove the new line and try again. It should go well.</p>
<pre class="PowerShellColorizedScript">
<span style="color: #00008b;">function</span> <span style="color: #8a2be2;">foo-bar</span> <span style="color: #000000;">{</span>
<span style="color: #a9a9a9;">[</span><span style="color: #add8e6;">cmdletbinding</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">]</span>            

<span style="color: #00008b;">param</span> <span style="color: #000000;">(</span>
<span style="color: #000000;">)</span>
<span style="color: #0000ff;">...</span>
<span style="color: #0000ff;">...</span>
<span style="color: #0000ff;">...</span>
<span style="color: #000000;">}</span></pre>
<p>Note that above is true while copy pasting the code into powershell window. If you have this space in a script and you are executing the script from powershell window, then you may not notice this.</p>
<p>Hope this helps&#8230; Happy learning&#8230;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://techibee.com/powershell/powershell-unexpected-attribute-cmdletbindingparentcontainserrorrecordexception/1651/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell: Get scheduled tasks list from Windows 7/2008 computers</title>
		<link>http://techibee.com/powershell/powershell-get-scheduled-tasks-list-from-windows-72008-computers/1647?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-get-scheduled-tasks-list-from-windows-72008-computers</link>
		<comments>http://techibee.com/powershell/powershell-get-scheduled-tasks-list-from-windows-72008-computers/1647#comments</comments>
		<pubDate>Sat, 19 May 2012 17:08:40 +0000</pubDate>
		<dc:creator>Sitaram Pamarthi</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[export scheduled tasks powershell]]></category>
		<category><![CDATA[list scheduled tasks powershell]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://techibee.com/?p=1647</guid>
		<description><![CDATA[The below script helps you to query scheduled tasks from remote computer which is running with Windows 7/Windows 2008  or above. You can use this script to query multiple computers to get all the scheduled tasks. You can also query the computer by using a scheduled task name as well. &#60;#     .Synopsis         Get [...]]]></description>
			<content:encoded><![CDATA[<p>The below script helps you to query scheduled tasks from remote computer which is running with Windows 7/Windows 2008  or above. You can use this script to query multiple computers to get all the scheduled tasks. You can also query the computer by using a scheduled task name as well.</p>
<p>&lt;#</p>
<pre class="PowerShellColorizedScript">    .Synopsis
        Get the list of scheduled Tasks from Windows 7 or Windows 2008 computers
        
    .Description
        This script displays all the scheduled tasks available in a windows 7 or windows 2008 computer.
 
    .Parameter ComputerName    
        Computer Name(s) from which you want to get the scheduled tasks information. If this
        parameter is not used, the the script gets the scheduled tasks list from local computer.
        
    .Parameter TaskName    
        Name of the scheduled task that you want to query. This is a optional parameter.
        
    .Example 1
        Get-ScheduledTask.ps1 -ComputerName Comp1, Comp2
        Get the scheduled tasks information from listed computers.
    .Example 2
        Get-ScheduledTask.ps1 -ComputerName Comp1 -TaskName "Calibration Loader"
        
        Get the details of given task from Comp1.
        
    .Notes
        NAME:      Get-ScheduledTask.ps1
        AUTHOR:    Sitaram Pamarthi
        WEBSITE:   http://techibee.com

#&gt;
<span style="color: #a9a9a9;">[</span><span style="color: #add8e6;">cmdletbinding</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">]</span>
<span style="color: #00008b;">param</span> <span style="color: #000000;">(</span>
 <span style="color: #a9a9a9;">[</span><span style="color: #add8e6;">parameter</span><span style="color: #000000;">(</span><span style="color: #000000;">ValueFromPipeline</span><span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$true</span><span style="color: #a9a9a9;">,</span><span style="color: #000000;">ValueFromPipelineByPropertyName</span><span style="color: #a9a9a9;">=</span><span style="color: #ff4500;">$true</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">]</span>
 <span style="color: #008080;">[string[]]</span> <span style="color: #ff4500;">$ComputerName</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$env:computername</span><span style="color: #a9a9a9;">,</span>
 <span style="color: #008080;">[string]</span> <span style="color: #ff4500;">$TaskName</span>
<span style="color: #000000;">)</span>
<span style="color: #006400;">#function to get all scheduled task folder details.</span>
<span style="color: #00008b;">function</span> <span style="color: #8a2be2;">Get-TaskSubFolders</span> <span style="color: #000000;">{</span>
<span style="color: #a9a9a9;">[</span><span style="color: #add8e6;">cmdletbinding</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">]</span>
<span style="color: #00008b;">param</span> <span style="color: #000000;">(</span>
 <span style="color: #ff4500;">$FolderRef</span>
<span style="color: #000000;">)</span>
<span style="color: #ff4500;">$ArrFolders</span> <span style="color: #a9a9a9;">=</span> <span style="color: #000000;">@(</span><span style="color: #000000;">)</span>
<span style="color: #ff4500;">$folders</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$folderRef</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">getfolders</span><span style="color: #000000;">(</span><span style="color: #800080;">1</span><span style="color: #000000;">)</span>
<span style="color: #00008b;">if</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$folders</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
 <span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$folder</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$folders</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
  <span style="color: #ff4500;">$ArrFolders</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$ArrFolders</span> <span style="color: #a9a9a9;">+</span> <span style="color: #ff4500;">$folder</span>
  <span style="color: #00008b;">if</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$folder</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">getfolders</span><span style="color: #000000;">(</span><span style="color: #800080;">1</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
   <span style="color: #0000ff;">Get-TaskSubFolders</span> <span style="color: #000080;">-FolderRef</span> <span style="color: #ff4500;">$folder</span>
  <span style="color: #000000;">}</span>
 <span style="color: #000000;">}</span>
<span style="color: #000000;">}</span>
<span style="color: #00008b;">return</span> <span style="color: #ff4500;">$ArrFolders</span>
<span style="color: #000000;">}</span>            

<span style="color: #006400;">#MAIN</span>            

<span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$Computer</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$ComputerName</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
 <span style="color: #ff4500;">$SchService</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">New-Object</span> <span style="color: #000080;">-ComObject</span> <span style="color: #8a2be2;">Schedule.Service</span>
 <span style="color: #ff4500;">$SchService</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Connect</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span>
 <span style="color: #ff4500;">$Rootfolder</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$SchService</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">GetFolder</span><span style="color: #000000;">(</span><span style="color: #8b0000;">"\"</span><span style="color: #000000;">)</span>
 <span style="color: #ff4500;">$folders</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-Tasksubfolders</span> <span style="color: #000080;">-FolderRef</span> <span style="color: #ff4500;">$RootFolder</span>
 <span style="color: #00008b;">foreach</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$Folder</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$folders</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
  <span style="color: #ff4500;">$Tasks</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$folder</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">gettasks</span><span style="color: #000000;">(</span><span style="color: #800080;">1</span><span style="color: #000000;">)</span>
  <span style="color: #00008b;">foreach</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$Task</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$Tasks</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
   <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">New-Object</span> <span style="color: #000080;">-TypeName</span> <span style="color: #8a2be2;">PSobject</span>
   <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Add-Member</span> <span style="color: #000080;">-MemberType</span> <span style="color: #8a2be2;">NoteProperty</span> <span style="color: #000080;">-Name</span> <span style="color: #8a2be2;">ComputerName</span> <span style="color: #000080;">-Value</span> <span style="color: #ff4500;">$Computer</span>
   <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Add-Member</span> <span style="color: #000080;">-MemberType</span> <span style="color: #8a2be2;">NoteProperty</span> <span style="color: #000080;">-Name</span> <span style="color: #8a2be2;">TaskName</span> <span style="color: #000080;">-Value</span> <span style="color: #ff4500;">$Task</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Name</span>
   <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Add-Member</span> <span style="color: #000080;">-MemberType</span> <span style="color: #8a2be2;">NoteProperty</span> <span style="color: #000080;">-Name</span> <span style="color: #8a2be2;">TaskFolder</span> <span style="color: #000080;">-Value</span> <span style="color: #ff4500;">$Folder</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">path</span>
   <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Add-Member</span> <span style="color: #000080;">-MemberType</span> <span style="color: #8a2be2;">NoteProperty</span> <span style="color: #000080;">-Name</span> <span style="color: #8a2be2;">IsEnabled</span> <span style="color: #000080;">-Value</span> <span style="color: #ff4500;">$task</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">enabled</span>
   <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Add-Member</span> <span style="color: #000080;">-MemberType</span> <span style="color: #8a2be2;">NoteProperty</span> <span style="color: #000080;">-Name</span> <span style="color: #8a2be2;">LastRunTime</span> <span style="color: #000080;">-Value</span> <span style="color: #ff4500;">$task</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">LastRunTime</span>
   <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Add-Member</span> <span style="color: #000080;">-MemberType</span> <span style="color: #8a2be2;">NoteProperty</span> <span style="color: #000080;">-Name</span> <span style="color: #8a2be2;">NextRunTime</span> <span style="color: #000080;">-Value</span> <span style="color: #ff4500;">$task</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">NextRunTime</span>
   <span style="color: #00008b;">if</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$TaskName</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
    <span style="color: #00008b;">if</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$Task</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Name</span> <span style="color: #a9a9a9;">-eq</span> <span style="color: #ff4500;">$TaskName</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
     <span style="color: #ff4500;">$OutputObj</span>
    <span style="color: #000000;">}</span>
   <span style="color: #000000;">}</span> <span style="color: #00008b;">else</span> <span style="color: #000000;">{</span>
     <span style="color: #ff4500;">$OutputObj</span>
   <span style="color: #000000;">}</span>
  <span style="color: #000000;">}</span>            

 <span style="color: #000000;">}</span>            

<span style="color: #000000;">}</span></pre>
<p><strong>Output:</strong></p>
<p><a href="http://techibee.com/wp-content/uploads/2012/05/get-scheduledtasks.png"><img class="aligncenter size-full wp-image-1648" title="get-scheduledtasks" src="http://techibee.com/wp-content/uploads/2012/05/get-scheduledtasks.png" alt="" width="1200" height="609" /></a>Feel Free to post here if you have any trouble in using this script. Happy to help!!!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://techibee.com/powershell/powershell-get-scheduled-tasks-list-from-windows-72008-computers/1647/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell: Split a string by white space(s)</title>
		<link>http://techibee.com/powershell/powershell-split-a-string-by-white-spaces/1641?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-split-a-string-by-white-spaces</link>
		<comments>http://techibee.com/powershell/powershell-split-a-string-by-white-spaces/1641#comments</comments>
		<pubDate>Tue, 15 May 2012 15:15:26 +0000</pubDate>
		<dc:creator>Sitaram Pamarthi</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[split string by using spaces]]></category>
		<category><![CDATA[Split string using powershell by white spaces]]></category>

		<guid isPermaLink="false">http://techibee.com/?p=1641</guid>
		<description><![CDATA[While writing a script today, I faced a situation where I have a string like &#8220;This is my       test                string&#8221;. As you have already noticed there are more than one spaces at different places in the string. All I need to do is eliminate all spaces and fit the words alone into a array. Since [...]]]></description>
			<content:encoded><![CDATA[<p>While writing a script today, I faced a situation where I have a string like <strong>&#8220;This is my       test                string&#8221;</strong>. As you have already noticed there are more than one spaces at different places in the string. All I need to do is eliminate all spaces and fit the words alone into a array.</p>
<p>Since this is a split by white space operation, I tried below and got bit surprised with the output.</p>
<pre class="PowerShellColorizedScript"><span style="color: #ff4500;">$string</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">"This is my test string"</span>
<span style="color: #ff4500;">$string</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">split</span><span style="color: #000000;">(</span><span style="color: #8b0000;">" "</span><span style="color: #000000;">) </span></pre>
<p><strong>Output:</strong></p>
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAekAAADLCAIAAADFv/xJAAAGeUlEQVR4nO3c27KrKBAA0Pz/V/lp83BqdhmBpsFLNFnrYSoh0Daorcdkz2v53+vdsvLKmRiyHrsOMjocAAA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></p>
<p>The output is array which is containing the words plus some spaces in middle. This is not what I expected. After some struggle, I made it to work by using <strong>-Split.</strong></p>
<p>Now the working code is&#8230;</p>
<pre class="PowerShellColorizedScript"><span style="color: #ff4500;">$string</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">"This is my test string"</span>
<span style="color: #ff4500;">$array</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$string</span> <span style="color: #a9a9a9;">-split</span> <span style="color: #8b0000;">"\s+"</span>
<span style="color: #ff4500;">$array</span></pre>
<p>&nbsp;</p>
<p><strong>Output:</strong></p>
<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAkYAAACECAIAAAD6AHOtAAAIQklEQVR4nO3c25KrKhAA0Pz/V/lp5+FU7XIEmgYxxmSth10Jgeai0qOT2a8XAAAArLRt27Ztd48CgLttf1XLJ0KdHM/VTUZ9Ttbcj+Tf662wrxCMfNW8Pmd94LnOX0fV/eG3BFtkWWE0TlA5GSrZ71AqnTjMn3NytI5X+basH0dbNSoOVq2MFX6WW/YZKW1NSjvUqb7N77PJTvPVTjb5KMGhqU7t6fN9Oj80/Ka7jpeU1k9po0Fanx4qLMlqQZ1tp1pYTrw690yc1mTzU2hFazU5vNiHqsZPzisoz4x/Ok6wCPu3+VF9iO68kusWxOFeQ8dr/zZzPgQHPQ51ePFbWqs2dPHMXWbdVpmwweCrQVoxD+dH9QTqxg/6fYNqj8GpX5ZMj/9knP0Ig+bvX9LzgoOSf92Kw70mjtfhYpy7Hp9+UVwrXpHkek0va9BwNOboKVUt34ottRv85Km2FbpN4lBBYXderSATXQ/F2a98MOaT63OL4KBUD3prjk+c+y8YPV77I969ajIXghPjKLjkggpxkOrbVpDuAJKScea2jEecahOHcm418vWTcf5V24pL/d4lPW/u9M4fKT7BT+0zn25iH+zGqR6YuQOZ6bSM3x3MaKej8btTvsLEoczPa6jr0Tj7g9KK9v71XKJ6vo2+bsXhXhPHKz58+eto++vcPL5La1Em1uvMEreOXL7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p>
<p>&nbsp;</p>
<p>Hope this little tip helps. Visit to <a href="http://www.powershelladmin.com/wiki/Powershell_split_operator">http://www.powershelladmin.com/wiki/Powershell_split_operator</a> for more examples about using <strong>-Split.</strong></p>
<p><strong>[Update]:</strong></p>
<p>The usage for -split is very simple and I believe this is a best suit for simple requirements like the one I showed you above. But if you have something more complex, then you may want to explore the usage of <strong>[regedit]::Split()</strong> dotnet method.</p>
]]></content:encoded>
			<wfw:commentRss>http://techibee.com/powershell/powershell-split-a-string-by-white-spaces/1641/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why am I getting powershell output in @{parametername=parametervalue}.parametername</title>
		<link>http://techibee.com/powershell/why-am-i-getting-powershell-output-in-parameternameparametervalue-parametername/1635?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=why-am-i-getting-powershell-output-in-parameternameparametervalue-parametername</link>
		<comments>http://techibee.com/powershell/why-am-i-getting-powershell-output-in-parameternameparametervalue-parametername/1635#comments</comments>
		<pubDate>Wed, 09 May 2012 14:24:23 +0000</pubDate>
		<dc:creator>Sitaram Pamarthi</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[@{Name]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://techibee.com/?p=1635</guid>
		<description><![CDATA[One of my friend is trying to get computers list from active directory using below code. All he want is names of the computers in a array. $TestPcNames = Get-QAComptuer -Id TEST* &#124; select Name $TestPCNames &#124; % { write-host "$_.Name" } There is nothing really wrong with the above code. All it contains is [...]]]></description>
			<content:encoded><![CDATA[<p>One of my friend is trying to get computers list from active directory using below code. All he want is names of the computers in a array.</p>
<pre class="PowerShellColorizedScript"><span style="color: #ff4500;">$TestPcNames</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-QAComptuer</span> <span style="color: #000080;">-Id</span> <span style="color: #8a2be2;">TEST*</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">select</span> <span style="color: #8a2be2;">Name</span>
<span style="color: #ff4500;">$TestPCNames</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">%</span> <span style="color: #000000;">{</span> <span style="color: #0000ff;">write-host</span> <span style="color: #8b0000;">"$_.Name"</span> <span style="color: #000000;">}</span></pre>
<p>There is nothing really wrong with the above code. All it contains is computer names but in object format. For that reason when he is trying to print the computer name, he is getting something like @{Name=TESTPC1}.Name</p>
<p>There he is stuck and now don&#8217;t know how to get list of computer accounts(in string format) in a array. This is very basic problem that every system administrator will face when trying to get their hands wet with powershell. I have also gone through this a couple of years back when I am studying ABCs of powershell.</p>
<p>The solution for this is very easy. First get the things printed correctly. You can use either of below one liners for that.</p>
<pre class="PowerShellColorizedScript"><span style="color: #ff4500;">$TestPCNames</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">%</span> <span style="color: #000000;">{</span> <span style="color: #0000ff;">write-host</span> <span style="color: #8b0000;">"$($_.Name)"</span> <span style="color: #000000;">}</span>         

<span style="color: #ff4500;">$TestPCNames</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">%</span> <span style="color: #000000;">{</span> <span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Name</span> <span style="color: #000000;">}</span></pre>
<p>Once you seen them printed as string array(you will noted there won&#8217;t be any column header with work &#8220;Name&#8221;), all you need to do is assign the output to a variable.</p>
<pre class="PowerShellColorizedScript"><span style="color: #ff4500;">$CompArray</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$TestPCNames</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">%</span> <span style="color: #000000;">{</span> <span style="color: #0000ff;">write-host</span> <span style="color: #8b0000;">"$($_.Name)"</span> <span style="color: #000000;">}</span>
<span style="color: #ff4500;">$CompArray</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$TestPCNames</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">%</span> <span style="color: #000000;">{</span> <span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Name</span> <span style="color: #000000;">}</span></pre>
<p>Now <strong>$CompArray </strong>contains the list of computers. Hope this little tip helps&#8230;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://techibee.com/powershell/why-am-i-getting-powershell-output-in-parameternameparametervalue-parametername/1635/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interesting Video on PowerShell V3</title>
		<link>http://techibee.com/powershell/interesting-video-on-powershell-v3/1628?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=interesting-video-on-powershell-v3</link>
		<comments>http://techibee.com/powershell/interesting-video-on-powershell-v3/1628#comments</comments>
		<pubDate>Sun, 06 May 2012 12:59:25 +0000</pubDate>
		<dc:creator>Uma Padmavathi</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[PowerShell V3]]></category>

		<guid isPermaLink="false">http://techibee.com/?p=1628</guid>
		<description><![CDATA[Here is an interesting video about PowerShell V3 which I came across through linked in&#8230; Thought of sharing with Scripting guys&#8230; http://channel9.msdn.com/posts/PowerShell-V3-Guru-Don-Jones?goback=%2Egde_140856_member_112620896 &#160;]]></description>
			<content:encoded><![CDATA[<p>Here is an interesting video about PowerShell V3 which I came across through <strong>linked in</strong>&#8230;</p>
<p>Thought of sharing with Scripting guys&#8230;</p>
<p><a href="http://channel9.msdn.com/posts/PowerShell-V3-Guru-Don-Jones?goback=%2Egde_140856_member_112620896">http://channel9.msdn.com/posts/PowerShell-V3-Guru-Don-Jones?goback=%2Egde_140856_member_112620896</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://techibee.com/powershell/interesting-video-on-powershell-v3/1628/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell: Script to take a screenshot of your desktop</title>
		<link>http://techibee.com/powershell/powershell-script-to-take-a-screenshot-of-your-desktop/1626?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-script-to-take-a-screenshot-of-your-desktop</link>
		<comments>http://techibee.com/powershell/powershell-script-to-take-a-screenshot-of-your-desktop/1626#comments</comments>
		<pubDate>Wed, 25 Apr 2012 16:13:18 +0000</pubDate>
		<dc:creator>Sitaram Pamarthi</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[take a screenshot using powershell]]></category>

		<guid isPermaLink="false">http://techibee.com/?p=1626</guid>
		<description><![CDATA[&#8220;Could you please send me a screenshot of what you are seeing?&#8221;. This is a frequent question we system administrators ask the end users. So, I just got a thought why I can&#8217;t take a screenshot of desktop using powershell so that I can incorporate this to my other automations if needed. That is when [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;Could you please send me a screenshot of what you are seeing?&#8221;. This is a frequent question we system administrators ask the end users. So, I just got a thought why I can&#8217;t take a screenshot of desktop using powershell so that I can incorporate this to my other automations if needed. That is when this script born.</p>
<p>When searched in google for this, I found a stackoverflow thread(<a href="http://stackoverflow.com/questions/2969321/how-can-i-do-a-screen-capture-in-windows-powershell">http://stackoverflow.com/questions/2969321/how-can-i-do-a-screen-capture-in-windows-powershell</a>) where different approaches are described to take a screenshot using powershell. I could make only one method working and the other is having problems. However, the working method has a limitation as I need to explicitly pass the width and height of the screen that has to be captured. If I am interested on whole screen, from where I can get these coordinates? My previous post(Get-ScreenResolution) came handy here. I read the screen resolution details using Get-Screenresolution.ps1 script and passed the output to the function I found in stackoverflow. Now it is working exactly the way I want.</p>
<p>For general usage, I made few more modifications to the code to allow explicitly pass the width and height details using <strong>-Width and -Height </strong>parameters. There is also another parameter called -FileName using which you can provide the name you want for the screenshot. Don&#8217;t provide a file extension here. The script saves the output in PNG format by default. If <strong>-FileName </strong>parameter is not specified you can see the output in %temp% with Screenshot.png name.</p>
<p><strong>Get-ScreenShot.ps1</strong></p>
<pre class="PowerShellColorizedScript"><span style="color: #a9a9a9;">[</span><span style="color: #add8e6;">cmdletbinding</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">]</span>
<span style="color: #00008b;">param</span><span style="color: #000000;">(</span>
  <span style="color: #008080;">[string]</span><span style="color: #ff4500;">$Width</span><span style="color: #a9a9a9;">,</span>
  <span style="color: #008080;">[string]</span><span style="color: #ff4500;">$Height</span><span style="color: #a9a9a9;">,</span>
  <span style="color: #008080;">[String]</span><span style="color: #ff4500;">$FileName</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">"Screenshot"</span>            

<span style="color: #000000;">)</span>            

<span style="color: #006400;">#Function to take screenshot. This function takes the width and height of the screen that has</span>
<span style="color: #006400;">#to be captured</span>            

<span style="color: #00008b;">function</span> <span style="color: #8a2be2;">Take-Screenshot</span><span style="color: #000000;">{</span>
<span style="color: #a9a9a9;">[</span><span style="color: #add8e6;">cmdletbinding</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">]</span>
<span style="color: #00008b;">param</span><span style="color: #000000;">(</span>
 <span style="color: #008080;">[Drawing.Rectangle]</span><span style="color: #ff4500;">$bounds</span><span style="color: #a9a9a9;">,</span>
 <span style="color: #008080;">[string]</span><span style="color: #ff4500;">$path</span>
<span style="color: #000000;">)</span>
   <span style="color: #ff4500;">$bmp</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">New-Object</span> <span style="color: #8a2be2;">Drawing.Bitmap</span> <span style="color: #ff4500;">$bounds</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">width</span><span style="color: #a9a9a9;">,</span> <span style="color: #ff4500;">$bounds</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">height</span>
   <span style="color: #ff4500;">$graphics</span> <span style="color: #a9a9a9;">=</span> <span style="color: #008080;">[Drawing.Graphics]</span><span style="color: #a9a9a9;">::</span><span style="color: #000000;">FromImage</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$bmp</span><span style="color: #000000;">)</span>
   <span style="color: #ff4500;">$graphics</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">CopyFromScreen</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$bounds</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Location</span><span style="color: #a9a9a9;">,</span> <span style="color: #008080;">[Drawing.Point]</span><span style="color: #a9a9a9;">::</span><span style="color: #000000;">Empty</span><span style="color: #a9a9a9;">,</span> <span style="color: #ff4500;">$bounds</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">size</span><span style="color: #000000;">)</span>
   <span style="color: #ff4500;">$bmp</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Save</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$path</span><span style="color: #000000;">)</span>
   <span style="color: #ff4500;">$graphics</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Dispose</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span>
   <span style="color: #ff4500;">$bmp</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Dispose</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span>
<span style="color: #000000;">}</span>            

<span style="color: #006400;">#Function to get the primary monitor resolution.</span>
<span style="color: #006400;">#This code is sourced from </span>
<span style="color: #006400;"># http://techibee.com/powershell/powershell-script-to-get-desktop-screen-resolution/1615</span>            

<span style="color: #00008b;">function</span> <span style="color: #8a2be2;">Get-ScreenResolution</span> <span style="color: #000000;">{</span>
 <span style="color: #ff4500;">$Screens</span> <span style="color: #a9a9a9;">=</span> <span style="color: #008080;">[system.windows.forms.screen]</span><span style="color: #a9a9a9;">::</span><span style="color: #000000;">AllScreens</span>
 <span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$Screen</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$Screens</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
  <span style="color: #ff4500;">$DeviceName</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$Screen</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">DeviceName</span>
  <span style="color: #ff4500;">$Width</span>  <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$Screen</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Bounds</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Width</span>
  <span style="color: #ff4500;">$Height</span>  <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$Screen</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Bounds</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Height</span>
  <span style="color: #ff4500;">$IsPrimary</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$Screen</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Primary</span>
  <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">New-Object</span> <span style="color: #000080;">-TypeName</span> <span style="color: #8a2be2;">PSobject</span>
  <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Add-Member</span> <span style="color: #000080;">-MemberType</span> <span style="color: #8a2be2;">NoteProperty</span> <span style="color: #000080;">-Name</span> <span style="color: #8a2be2;">DeviceName</span> <span style="color: #000080;">-Value</span> <span style="color: #ff4500;">$DeviceName</span>
  <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Add-Member</span> <span style="color: #000080;">-MemberType</span> <span style="color: #8a2be2;">NoteProperty</span> <span style="color: #000080;">-Name</span> <span style="color: #8a2be2;">Width</span> <span style="color: #000080;">-Value</span> <span style="color: #ff4500;">$Width</span>
  <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Add-Member</span> <span style="color: #000080;">-MemberType</span> <span style="color: #8a2be2;">NoteProperty</span> <span style="color: #000080;">-Name</span> <span style="color: #8a2be2;">Height</span> <span style="color: #000080;">-Value</span> <span style="color: #ff4500;">$Height</span>
  <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Add-Member</span> <span style="color: #000080;">-MemberType</span> <span style="color: #8a2be2;">NoteProperty</span> <span style="color: #000080;">-Name</span> <span style="color: #8a2be2;">IsPrimaryMonitor</span> <span style="color: #000080;">-Value</span> <span style="color: #ff4500;">$IsPrimary</span>
  <span style="color: #ff4500;">$OutputObj</span>
 <span style="color: #000000;">}</span>
<span style="color: #000000;">}</span>            

<span style="color: #006400;">#Main script begins</span>            

<span style="color: #006400;">#By default captured screenshot will be saved in %temp% folder</span>
<span style="color: #006400;">#You can override it here if you want</span>
<span style="color: #ff4500;">$Filepath</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">join-path</span> <span style="color: #ff4500;">$env:temp</span> <span style="color: #ff4500;">$FileName</span>            

<span style="color: #008080;">[void]</span> <span style="color: #008080;">[Reflection.Assembly]</span><span style="color: #a9a9a9;">::</span><span style="color: #000000;">LoadWithPartialName</span><span style="color: #000000;">(</span><span style="color: #8b0000;">"System.Windows.Forms"</span><span style="color: #000000;">)</span>
<span style="color: #008080;">[void]</span> <span style="color: #008080;">[Reflection.Assembly]</span><span style="color: #a9a9a9;">::</span><span style="color: #000000;">LoadWithPartialName</span><span style="color: #000000;">(</span><span style="color: #8b0000;">"System.Drawing"</span><span style="color: #000000;">)</span>            

<span style="color: #00008b;">if</span><span style="color: #000000;">(</span><span style="color: #a9a9a9;">!</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$width</span> <span style="color: #a9a9a9;">-and</span> <span style="color: #ff4500;">$height</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>            

 <span style="color: #ff4500;">$screen</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-ScreenResolution</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">?</span> <span style="color: #000000;">{</span><span style="color: #ff4500;">$_</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">IsPrimaryMonitor</span> <span style="color: #a9a9a9;">-eq</span> <span style="color: #ff4500;">$true</span><span style="color: #000000;">}</span>
 <span style="color: #ff4500;">$Width</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$screen</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Width</span>
 <span style="color: #ff4500;">$Height</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$screen</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">height</span>
<span style="color: #000000;">}</span>            

<span style="color: #ff4500;">$bounds</span> <span style="color: #a9a9a9;">=</span> <span style="color: #008080;">[Drawing.Rectangle]</span><span style="color: #a9a9a9;">::</span><span style="color: #000000;">FromLTRB</span><span style="color: #000000;">(</span><span style="color: #800080;">0</span><span style="color: #a9a9a9;">,</span> <span style="color: #800080;">0</span><span style="color: #a9a9a9;">,</span> <span style="color: #ff4500;">$Screen</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Width</span><span style="color: #a9a9a9;">,</span> <span style="color: #ff4500;">$Screen</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Height</span><span style="color: #000000;">)</span>            

<span style="color: #0000ff;">Take-Screenshot</span> <span style="color: #000080;">-Bounds</span> <span style="color: #ff4500;">$bounds</span> <span style="color: #000080;">-Path</span> <span style="color: #8b0000;">"$Filepath.png"</span>
<span style="color: #006400;">#Now you have the screenshot</span></pre>
<p><strong>Usage:</strong></p>
<p>Simple, just run the script from powershell window, you will see the output in %temp%\screenshot.png</p>
<p>Hope this helps&#8230; feedback welcome.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://techibee.com/powershell/powershell-script-to-take-a-screenshot-of-your-desktop/1626/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell: Write-EventLog Error &#8220;Write-EventLog : The source name XXX does not exist on computer</title>
		<link>http://techibee.com/powershell/powershell-write-eventlog-error-write-eventlog-the-source-name-xxx-does-not-exist-on-computer/1621?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-write-eventlog-error-write-eventlog-the-source-name-xxx-does-not-exist-on-computer</link>
		<comments>http://techibee.com/powershell/powershell-write-eventlog-error-write-eventlog-the-source-name-xxx-does-not-exist-on-computer/1621#comments</comments>
		<pubDate>Wed, 25 Apr 2012 11:23:24 +0000</pubDate>
		<dc:creator>Sitaram Pamarthi</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[write-eventlog is failing]]></category>

		<guid isPermaLink="false">http://techibee.com/?p=1621</guid>
		<description><![CDATA[If you are using Write-EventLog to write any new events to event log, it is possible that you might see below error. Write-EventLog : The source name &#8220;XXX&#8221; does not exist on computer &#8220;localhost&#8221;. I am into similar situation today. What I was doing is trying to write a new event in to Application event [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using Write-EventLog to write any new events to event log, it is possible that you might see below error.</p>
<blockquote><p><span style="color: #ff0000;">Write-EventLog : The source name &#8220;XXX&#8221; does not exist on computer &#8220;localhost&#8221;.</span></p></blockquote>
<p>I am into similar situation today. What I was doing is trying to write a new event in to Application event log with a Event Source that is not already exists in the computer where I am trying. So the error message makes sense. It is saying the source I am trying to use, XXX doesn&#8217;t exists. So, how should get this added to list of available event sources in the computer so that it won&#8217;t through the error message again.</p>
<p>After little bit of googling, I found the below method promising.</p>
<blockquote><p><span style="color: #ff00ff;">New-EventLog -LogName Application -Source &#8220;XXX&#8221;</span></p></blockquote>
<p>This command creates a new event source in Application Event log with the name XXX. All I need to do is just use this command once and try the write-EventLog cmdlet with the same source name(XXX). It worked this time.</p>
<p>Hope this little trick helps you&#8230;</p>
<p><strong>[Update]</strong></p>
<p>There are some dotnet ways available as well to see if a given source is available in EventLog and create one if needed.</p>
<p><strong>To check if the source exists:</strong></p>
<p>PS C:\&gt; [system.diagnostics.eventlog]::SourceExists(&#8220;XXX&#8221;)<br />
False<br />
PS C:\&gt;</p>
<p><strong>To create a new source entry in event log:</strong></p>
<p>[system.diagnostics.EventLog]::CreateEventSource(&#8220;XXX&#8221;, &#8220;Application&#8221;)</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://techibee.com/powershell/powershell-write-eventlog-error-write-eventlog-the-source-name-xxx-does-not-exist-on-computer/1621/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell: Script to Get Desktop Screen Resolution</title>
		<link>http://techibee.com/powershell/powershell-script-to-get-desktop-screen-resolution/1615?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-script-to-get-desktop-screen-resolution</link>
		<comments>http://techibee.com/powershell/powershell-script-to-get-desktop-screen-resolution/1615#comments</comments>
		<pubDate>Tue, 24 Apr 2012 17:15:17 +0000</pubDate>
		<dc:creator>Sitaram Pamarthi</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[get screen resolution]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[script to get screen resolution]]></category>

		<guid isPermaLink="false">http://techibee.com/?p=1615</guid>
		<description><![CDATA[The Powershell code described in this article will help you to get screen resolution details of your desktops It uses System.Drawing and System.Windows.Forms namespaces. The Screen class in System.Windows.Forms provides the data we need &#8212; that is screen resolution details. This code will also tell you which one is your primary monitor and it&#8217;s resolution [...]]]></description>
			<content:encoded><![CDATA[<p>The Powershell code described in this article will help you to get screen resolution details of your desktops It uses <strong>System.Drawing</strong> and <strong>System.Windows.Forms</strong> namespaces. The <strong>Screen</strong> class in <strong>System.Windows.Forms</strong> provides the data we need &#8212; that is screen resolution details. This code will also tell you which one is your primary monitor and it&#8217;s resolution details.</p>
<p><strong>Code:</strong></p>
<pre class="PowerShellColorizedScript"><span style="color: #00008b;">function</span> <span style="color: #8a2be2;">Get-ScreenResolution</span> <span style="color: #000000;">{</span>
<span style="color: #008080;">[void]</span> <span style="color: #008080;">[Reflection.Assembly]</span><span style="color: #a9a9a9;">::</span><span style="color: #000000;">LoadWithPartialName</span><span style="color: #000000;">(</span><span style="color: #8b0000;">"System.Windows.Forms"</span><span style="color: #000000;">)</span>
<span style="color: #008080;">[void]</span> <span style="color: #008080;">[Reflection.Assembly]</span><span style="color: #a9a9a9;">::</span><span style="color: #000000;">LoadWithPartialName</span><span style="color: #000000;">(</span><span style="color: #8b0000;">"System.Drawing"</span><span style="color: #000000;">)</span>
<span style="color: #ff4500;">$Screens</span> <span style="color: #a9a9a9;">=</span> <span style="color: #008080;">[system.windows.forms.screen]</span><span style="color: #a9a9a9;">::</span><span style="color: #000000;">AllScreens</span>            

<span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$Screen</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$Screens</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
 <span style="color: #ff4500;">$DeviceName</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$Screen</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">DeviceName</span>
 <span style="color: #ff4500;">$Width</span>  <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$Screen</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Bounds</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Width</span>
 <span style="color: #ff4500;">$Height</span>  <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$Screen</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Bounds</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Height</span>
 <span style="color: #ff4500;">$IsPrimary</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$Screen</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Primary</span>            

 <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">New-Object</span> <span style="color: #000080;">-TypeName</span> <span style="color: #8a2be2;">PSobject</span>
 <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Add-Member</span> <span style="color: #000080;">-MemberType</span> <span style="color: #8a2be2;">NoteProperty</span> <span style="color: #000080;">-Name</span> <span style="color: #8a2be2;">DeviceName</span> <span style="color: #000080;">-Value</span> <span style="color: #ff4500;">$DeviceName</span>
 <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Add-Member</span> <span style="color: #000080;">-MemberType</span> <span style="color: #8a2be2;">NoteProperty</span> <span style="color: #000080;">-Name</span> <span style="color: #8a2be2;">Width</span> <span style="color: #000080;">-Value</span> <span style="color: #ff4500;">$Width</span>
 <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Add-Member</span> <span style="color: #000080;">-MemberType</span> <span style="color: #8a2be2;">NoteProperty</span> <span style="color: #000080;">-Name</span> <span style="color: #8a2be2;">Height</span> <span style="color: #000080;">-Value</span> <span style="color: #ff4500;">$Height</span>
 <span style="color: #ff4500;">$OutputObj</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">Add-Member</span> <span style="color: #000080;">-MemberType</span> <span style="color: #8a2be2;">NoteProperty</span> <span style="color: #000080;">-Name</span> <span style="color: #8a2be2;">IsPrimaryMonitor</span> <span style="color: #000080;">-Value</span> <span style="color: #ff4500;">$IsPrimary</span>
 <span style="color: #ff4500;">$OutputObj</span>            

<span style="color: #000000;">}</span>
<span style="color: #000000;">}</span></pre>
<p>&nbsp;</p>
<p><strong>Output:</strong></p>
<p><a href="http://techibee.com/wp-content/uploads/2012/04/Get-ScreenResolution.png"><img class="aligncenter size-full wp-image-1617" title="Get-ScreenResolution" src="http://techibee.com/wp-content/uploads/2012/04/Get-ScreenResolution.png" alt="" width="427" height="118" /></a></p>
<p>Hope this helps&#8230;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://techibee.com/powershell/powershell-script-to-get-desktop-screen-resolution/1615/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

