<?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</title>
	<atom:link href="http://techibee.com/feed" rel="self" type="application/rss+xml" />
	<link>http://techibee.com</link>
	<description>A System Administrator&#039;s Blog</description>
	<lastBuildDate>Sat, 19 May 2012 17:08:40 +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: 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>Exchange 2010: How to grant &#8220;Send As&#8221; and &#8220;Send On behalf&#8221; permissions on a Distribution Group</title>
		<link>http://techibee.com/documentation/exchange-2010-how-to-grant-send-as-and-send-on-behalf-permissions-on-a-distribution-group/1645?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=exchange-2010-how-to-grant-send-as-and-send-on-behalf-permissions-on-a-distribution-group</link>
		<comments>http://techibee.com/documentation/exchange-2010-how-to-grant-send-as-and-send-on-behalf-permissions-on-a-distribution-group/1645#comments</comments>
		<pubDate>Wed, 16 May 2012 10:20:45 +0000</pubDate>
		<dc:creator>Sitaram Pamarthi</dc:creator>
				<category><![CDATA[Documentation]]></category>
		<category><![CDATA[Exchange 2010]]></category>
		<category><![CDATA[exchange 2010]]></category>

		<guid isPermaLink="false">http://techibee.com/?p=1645</guid>
		<description><![CDATA[I recently came across a need for setting &#8220;Send As&#8221; and &#8220;Send on Behalf&#8221; permissions for a group of users on  a Distribution Group(so called mailing list). While looking out for the procedure to do it in 2010 environment, I stumbled on two articles from &#8220;http://exchangeserverpro.com&#8221; which are very informative and up to the task. [...]]]></description>
			<content:encoded><![CDATA[<p>I recently came across a need for setting &#8220;Send As&#8221; and &#8220;Send on Behalf&#8221; permissions for a group of users on  a Distribution Group(so called mailing list). While looking out for the procedure to do it in 2010 environment, I stumbled on two articles from &#8220;<a href="http://exchangeserverpro.com">http://exchangeserverpro.com</a>&#8221; which are very informative and up to the task.</p>
<p>Posting them here as I felt worth sharing with my blog readers.</p>
<ul>
<li><a href="http://exchangeserverpro.com/exchange-2010-grant-send-behalf-permissions-distribution-group">Exchange 2010: How to Grant Send on Behalf Permissions for a Distribution Group</a></li>
<li><a href="http://exchangeserverpro.com/exchange-2010-send-as-permissions-distribution-group">Exchange 2010: How to Grant Send As Permissions for a Distribution Group</a></li>
</ul>
<p>Thanks to <a href="https://twitter.com/#!/exchservpro">Paul Cunningham</a> for these articles.</p>
<p>Thanks,<br />
Sitaram</p>
]]></content:encoded>
			<wfw:commentRss>http://techibee.com/documentation/exchange-2010-how-to-grant-send-as-and-send-on-behalf-permissions-on-a-distribution-group/1645/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,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" alt="" /></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,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" alt="" /></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>Internet Monitoring Software: An Admin’s Best Friend</title>
		<link>http://techibee.com/computer-security/internet-monitoring-software-an-admins-best-friend/1638?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=internet-monitoring-software-an-admins-best-friend</link>
		<comments>http://techibee.com/computer-security/internet-monitoring-software-an-admins-best-friend/1638#comments</comments>
		<pubDate>Sun, 13 May 2012 18:00:18 +0000</pubDate>
		<dc:creator>Sitaram Pamarthi</dc:creator>
				<category><![CDATA[Computer Security]]></category>

		<guid isPermaLink="false">http://techibee.com/?p=1638</guid>
		<description><![CDATA[When people think about Internet monitoring software, the first thing that often comes to mind is ‘user control’. However, Internet monitoring software does not only prevent users from visiting unproductive or potentially harmful websites. It is also a good tool to protect users while maintaining a healthy Internet connection. Internet monitoring software boosts security, increases [...]]]></description>
			<content:encoded><![CDATA[<p>When people think about Internet monitoring software, the first thing that often comes to mind is ‘user control’. However, Internet monitoring software does not only prevent users from visiting unproductive or potentially harmful websites. It is also a good tool to protect users while maintaining a healthy Internet connection. Internet monitoring software boosts security, increases efficiency and makes life easier for the administrator. Here are three main reasons explaining how:</p>
<ol start="1">
<li><strong>Security:</strong></li>
</ol>
<p>Internet monitoring software can be a powerful tool in your security arsenal. Good solutions will scan filed downloaded off the internet for viruses, ensuring that infected files are stopped before causing any damage.</p>
<p>This class of software will help to prevent users from visiting malicious sites and exposing the network to malicious attacks. Protecting users from malicious attacks is never that easy. Even blocking access to all but a few reputable sites, might not be enough because the sites can be compromised and infected with malware. Not for the first time has a reputable site been subverted to push drive-by downloads. Internet monitoring software will mitigate these risks by protecting the user on the basis of the threat itself, rather than on where the threat is expected to reside.</p>
<ol start="2">
<li><strong>Information:</strong></li>
</ol>
<p>Information is a valuable resource to any administrator. If a network is experiencing degraded performance, manually locating the cause can be time-consuming for a busy administrator.</p>
<p>A good Internet monitoring software package will allow you to generate reports that give a detailed view of those machines that are consuming a lot of bandwidth and at what time. Reporting can be drilled down to individual user level as well. By comparing reports over a period of time, the administrator will be able to tell whether there is a need for additional bandwidth or excessive consumption is due to user abuse or a malware infection or botnet.</p>
<ol start="3">
<li><strong>Control:</strong></li>
</ol>
<p>Having an Internet Usage Policy is essential for effective network management, but the policy itself is only the first step. The policy will also need to be enforced.</p>
<p>With Internet monitoring software the administrator can set rules that block / allow sites based on pre-configured categories, as well as on how reputable those sites are. The administrator can also set usage time and download quotas for specific sites, allowing for efficient bandwidth usage management and preventing excessive bandwidth use by employees.</p>
<p>&nbsp;</p>
<p>An admin can still provide network security, gather information and control users’ access without employing any Internet monitoring software, but to do so s/he would need various tools and then still need a lot of time to analyze the information and understand what’s going on.</p>
<p><em> </em></p>
<p><em>This guest post was provided by </em><em>Emmanuel Carabott</em><em> on behalf of GFI Software Ltd. GFI is a leading software developer that provides a single source for network administrators to address their network security, content security and messaging needs. Learn more about why you need </em><a href="http://www.gfi.com/internet-monitoring-software"><em>Internet monitoring software</em></a><em>. </em><em></p>
<p>All product and company names herein may be trademarks of their respective owners.</em></p>
<p><strong><span style="text-decoration: underline;"> </span></strong></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://techibee.com/computer-security/internet-monitoring-software-an-admins-best-friend/1638/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>
		<item>
		<title>Powershell: Script to enable/disable network connections in Windows</title>
		<link>http://techibee.com/powershell/powershell-script-to-enabledisable-network-connections-in-windows/1607?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-script-to-enabledisable-network-connections-in-windows</link>
		<comments>http://techibee.com/powershell/powershell-script-to-enabledisable-network-connections-in-windows/1607#comments</comments>
		<pubDate>Tue, 24 Apr 2012 08:49:57 +0000</pubDate>
		<dc:creator>Sitaram Pamarthi</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[disable windows network connection]]></category>
		<category><![CDATA[enable windows network connection]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[script to enable disable lan connection]]></category>
		<category><![CDATA[script to enable network connection]]></category>

		<guid isPermaLink="false">http://techibee.com/?p=1607</guid>
		<description><![CDATA[In one of my previous posts I talked about how to disable/enable LAN connections on a Windows 2008 Core server using command line. In this post, I am going to present you a much enhanced version of it using powershell. This powershell script helps you to disable or enable any network connection in either local [...]]]></description>
			<content:encoded><![CDATA[<p>In one of <a href="http://techibee.com/tips/command-line-to-disable-network-connection-in-windows-2008windows-7/1046">my previous posts</a> I talked about how to disable/enable LAN connections on a Windows 2008 Core server using command line. In this post, I am going to present you a much enhanced version of it using powershell. This powershell script helps you to disable or enable any network connection in either local computer or remote computer easily. You can use this script to perform this operation on multiple computers &#8212; will give usage example at the end of this post.</p>
<p>In this script I am using <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa394216%28v=vs.85%29.aspx">Win32_NetworkAdapter</a> WMI class which has methods for enabling or disabling a given network connection. By default, the script looks for network connections with the name <strong>Local Area Connection</strong> to perform disable or enable operations. If you want to perform these actions against different network connections(like HP Team#1) you can specify that using <strong>-ConnectionName </strong>parameter. The <strong>-Disable </strong>or <strong>-Enable</strong> parameters are for specifying the kind of operation you want to perform. The script will fail if you don&#8217;t find either of them. Similarly, you can use <strong>-ComputerName</strong> parameter if you want to perform this operation against remote computer. You can also provide the list of computers to this argument. <span style="color: #000000;"><span style="color: #ff0000;">I want you be more conscious while using this script against remote computer</span>. The reason behind it is, if you are attempting to disable the primary network connection in remote computer, the script may not return the success/failure status. The reason is simple, it lost the connection to remote computer because you just disabled it. You may find this script handy when you want to disable non-primary connections on remote computers. Since the primary connection is ON in this case, this can return you the status. I didn&#8217;t perform any testing against remote computers explicitly so please do testing in your test lab before trying in production.</span></p>
<p>&nbsp;</p>
<p><strong>Code : Set-NetworkConnection.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: #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;">[switch]</span><span style="color: #ff4500;">$Enable</span><span style="color: #a9a9a9;">,</span>
 <span style="color: #008080;">[switch]</span><span style="color: #ff4500;">$Disable</span><span style="color: #a9a9a9;">,</span>
 <span style="color: #008080;">[String]</span><span style="color: #ff4500;">$ConnectionName</span> <span style="color: #a9a9a9;">=</span> <span style="color: #8b0000;">"Local Area Connection"</span>
<span style="color: #000000;">)</span>            

<span style="color: #00008b;">begin</span> <span style="color: #000000;">{</span>            

<span style="color: #00008b;">if</span><span style="color: #000000;">(</span><span style="color: #a9a9a9;">-not</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$enable</span> <span style="color: #a9a9a9;">-or</span> <span style="color: #ff4500;">$disable</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
 <span style="color: #0000ff;">write-Error</span> <span style="color: #8b0000;">" You should select either of -Enable or -Disable switches. Exiting"</span>
 <span style="color: #00008b;">exit</span>
<span style="color: #000000;">}</span>            

<span style="color: #000000;">}</span>
<span style="color: #00008b;">process</span> <span style="color: #000000;">{</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;">$Computer</span> <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$Computer</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">ToUpper</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: #0000ff;">Test-Connection</span> <span style="color: #000080;">-ComputerName</span> <span style="color: #ff4500;">$Computer</span> <span style="color: #000080;">-Count</span> <span style="color: #800080;">1</span> <span style="color: #000080;">-ea</span> <span style="color: #800080;">0</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
   <span style="color: #ff4500;">$Networks</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-WmiObject</span> <span style="color: #8a2be2;">Win32_NetworkAdapter</span> <span style="color: #000080;">-ComputerName</span> <span style="color: #ff4500;">$Computer</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;">NetConnectionID</span> <span style="color: #a9a9a9;">-match</span> <span style="color: #ff4500;">$ConnectionName</span><span style="color: #000000;">}</span>
   <span style="color: #00008b;">foreach</span> <span style="color: #000000;">(</span><span style="color: #ff4500;">$Network</span> <span style="color: #00008b;">in</span> <span style="color: #ff4500;">$Networks</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;">$Enable</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
     <span style="color: #ff4500;">$retval</span>  <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$Network</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Enable</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;">$retval</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">ReturnValue</span> <span style="color: #a9a9a9;">-eq</span> <span style="color: #800080;">0</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
      <span style="color: #0000ff;">Write-host</span> <span style="color: #8b0000;">"Successfully enabled `"$($network.NetConnectionID)`" on $Computer"</span>
     <span style="color: #000000;">}</span> <span style="color: #00008b;">else</span> <span style="color: #000000;">{</span>
      <span style="color: #0000ff;">write-host</span> <span style="color: #8b0000;">"Failed to enable `"$($network.NetConnectionID)`" on $Computer"</span>
     <span style="color: #000000;">}</span>
    <span style="color: #000000;">}</span> <span style="color: #00008b;">elseif</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$Disable</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
     <span style="color: #ff4500;">$retval</span>  <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$Network</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Disable</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;">$retval</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">returnValue</span> <span style="color: #a9a9a9;">-eq</span> <span style="color: #800080;">0</span><span style="color: #000000;">)</span> <span style="color: #000000;">{</span>
      <span style="color: #0000ff;">Write-host</span> <span style="color: #8b0000;">"Successfully disabled `"$($network.NetConnectionID)`" on $Computer"</span>
     <span style="color: #000000;">}</span> <span style="color: #00008b;">else</span> <span style="color: #000000;">{</span>
      <span style="color: #0000ff;">write-host</span> <span style="color: #8b0000;">"Failed to disable `"$($network.NetConnectionID)`" on $Computer"</span>
     <span style="color: #000000;">}</span>            

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

<span style="color: #00008b;">end</span> <span style="color: #000000;">{</span><span style="color: #000000;">}</span></pre>
<p><strong>Usage Examples:</strong></p>
<blockquote><p><strong>.\Set-NetworkConnection -Enable #</strong>to enable local network connection</p>
<p><strong>.\Set-NetworkConnection -Disable #</strong>to disable local network connection</p>
<p><strong>.\Set-NetworkConnection -Disable -ConnectionName &#8220;My network2&#8243; #</strong>to disable the local network connection that has the name &#8220;My Network2&#8243;</p>
<p><strong>.\Set-NetworkConnection -ComputerName MyPC2 -Disable -ConnectionName &#8220;My network2&#8243; #</strong>to disable the network connection that has the name &#8220;My Network2&#8243; on MyPC2</p>
<p><strong>Get-Content C:\mypcs.txt | Set-NetworkConnection -Disable -ConnectionName &#8220;My Network2&#8243;</strong> #To disable the network connection name &#8220;My network2&#8243; on list of PCs in C:\mypcs.txt file</p></blockquote>
<p>Hope this helps&#8230; Happy learning&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://techibee.com/powershell/powershell-script-to-enabledisable-network-connections-in-windows/1607/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

