<?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>Everyday Nerd &#187; PowerShell</title>
	<atom:link href="http://everydaynerd.com/category/microsoft/powershell/feed" rel="self" type="application/rss+xml" />
	<link>http://everydaynerd.com</link>
	<description>Just your everyday nerd</description>
	<lastBuildDate>Mon, 21 Nov 2011 17:55:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<image>
  <link>http://everydaynerd.com</link>
  <url>http://everydaynerd.com/apple-touch-icon.png</url>
  <title>Everyday Nerd</title>
</image>
		<item>
		<title>PowerShell: Move Windows Server 2008 Cluster Group</title>
		<link>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-move-windows-server-2008-cluster-group</link>
		<comments>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-move-windows-server-2008-cluster-group#comments</comments>
		<pubDate>Mon, 21 Nov 2011 17:55:13 +0000</pubDate>
		<dc:creator>Nerd</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://everydaynerd.com/?p=1680</guid>
		<description><![CDATA[Where I work, we were a little behind finally getting to Windows Server 2008 R2.  Our Exchange Servers were running on Server 2003 R2 until recently.  Windows clustering is quite different on 2k8 vs. 2k3.  I wrote this function to &#8230; <a class="more-link" href="http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-move-windows-server-2008-cluster-group">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/exchange/exchange-2007-ccr-%e2%80%93-move-file-share-witness' rel='bookmark' title='Exchange 2007 CCR – Move File Share Witness'>Exchange 2007 CCR – Move File Share Witness</a></li>
<li><a href='http://everydaynerd.com/microsoft/windows-server-2008-rc1-released' rel='bookmark' title='Windows Server 2008 RC1 Released'>Windows Server 2008 RC1 Released</a></li>
<li><a href='http://everydaynerd.com/microsoft/windows-server-2008-its-rtm' rel='bookmark' title='Windows Server 2008 &#8211; It&#8217;s RTM!'>Windows Server 2008 &#8211; It&#8217;s RTM!</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Where I work, we were a little behind finally getting to Windows Server 2008 R2.  Our Exchange Servers were running on Server 2003 R2 until recently.  Windows clustering is quite different on 2k8 vs. 2k3.  I wrote this function to move the Windows cluster group &#8220;Cluster Group&#8221; (quorum) to the other node of the cluster.  I know it&#8217;s not that difficult to do this, but it saves a few extra keystrokes.</p>
<pre class="brush: powershell; light: false; title: ; toolbar: true; notranslate">
Function Invoke-WindowsClusterFailover
{
	#Requires -version 2
	[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact=&quot;High&quot;)]
	param()
	Write-Verbose &quot;Checking to see if $($env:computername) is a Clustered Exchange Server&quot;
	Get-ClusteredMailboxServerStatus -ErrorAction SilentlyContinue | Out-Null
	If ($? -eq $False)
	{
		Write-Verbose &quot;$($env:computername) is not a clustered Exchange Server - Exiting&quot;
		Throw &quot;$($env:computername) is not a clustered Exchange Server&quot;
	}
	Else
	{
		Write-Verbose &quot;$($env:computername) is a Clustered Exchange Server&quot;
		If (((Get-WmiObject Win32_OperatingSystem).Caption).ToString() -like &quot;*2008*&quot;)
		{
			Write-Verbose &quot;$($env:computername) is a Windows Server 2008 or later&quot;
			Write-Verbose &quot;Loading Windows Failover Cluster PowerShell Module&quot;
			Import-Module FailoverClusters
		}
		Else
		{
			Write-Verbose &quot;$($env:computername) is not Windows Server 2008 or later&quot;
			Write-Verbose &quot;$((Get-WmiObject Win32_OperatingSystem).Caption) does not support the Powershell FailoverCluster Module - Exiting&quot;
			Throw &quot;$((Get-WmiObject Win32_OperatingSystem).Caption) does not support the Powershell FailoverCluster Module&quot;
		}
		Write-Verbose &quot;Getting Windows Cluster Name&quot;
		$ClusterName = (Get-Cluster).Name
		Write-Verbose &quot;Checking ShouldContinue if OK to proceed&quot;
		if($PSCmdlet.ShouldProcess(&quot;$($ClusterName)&quot;, &quot;Failover Windows Cluster&quot;))
		{
			Write-Verbose &quot;Moving Windows Cluster Group&quot;
			Get-ClusterGroup &quot;Cluster Group&quot; | Move-ClusterGroup
		}
		Write-Verbose &quot;End&quot;
	}
				.SYNOPSIS
		Moves the Windows cluster &quot;Cluster Group&quot; to the other node of the cluster

		.DESCRIPTION
		Moves the Windows cluster &quot;Cluster Group&quot; to the other node of the cluster.  This requires
		Windows Server 2008 or later.  This function supports &quot;Should Continue&quot; so it prompts the
		user to continue at the &quot;dangerous&quot; portion of the function (Move-ClusterGroup).  If you
		don't want the should continue prompt, you can use the  param.

		.NOTES
		Function Name: Invoke-WindowsClusterFailover
		Author: Dan Burgess
		Email: nerd@everydaynerd.com
		Script Requires:  Powershell 2.0 or higher; Windows Server 2008 or later
	#&gt;
}
</pre>
<p>I really enjoyed using the &#8220;SupportsShouldProcess&#8221; feature of CmdletBinding!  Expand the code above, and double click to select all.</p>
<p>Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/exchange/exchange-2007-ccr-%e2%80%93-move-file-share-witness' rel='bookmark' title='Exchange 2007 CCR – Move File Share Witness'>Exchange 2007 CCR – Move File Share Witness</a></li>
<li><a href='http://everydaynerd.com/microsoft/windows-server-2008-rc1-released' rel='bookmark' title='Windows Server 2008 RC1 Released'>Windows Server 2008 RC1 Released</a></li>
<li><a href='http://everydaynerd.com/microsoft/windows-server-2008-its-rtm' rel='bookmark' title='Windows Server 2008 &#8211; It&#8217;s RTM!'>Windows Server 2008 &#8211; It&#8217;s RTM!</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-move-windows-server-2008-cluster-group/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell: Get-Uptime for Computer(s)</title>
		<link>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-get-uptime-for-computers</link>
		<comments>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-get-uptime-for-computers#comments</comments>
		<pubDate>Fri, 18 Nov 2011 20:53:04 +0000</pubDate>
		<dc:creator>Nerd</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://everydaynerd.com/?p=1673</guid>
		<description><![CDATA[I needed to check the server uptime for multiple servers, and well, I wanted to do it in PowerShell.  I found a sample from MSDN, and modified it, and threw it into a function. Here&#8217;s an alternative to this function &#8230; <a class="more-link" href="http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-get-uptime-for-computers">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-move-windows-server-2008-cluster-group' rel='bookmark' title='PowerShell: Move Windows Server 2008 Cluster Group'>PowerShell: Move Windows Server 2008 Cluster Group</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-drive-space-info-from-multiple-systems' rel='bookmark' title='PowerShell: Drive Space Info from multiple systems'>PowerShell: Drive Space Info from multiple systems</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-change-ps-window-size-on-the-fly' rel='bookmark' title='PowerShell: Change PS Window Size on the fly'>PowerShell: Change PS Window Size on the fly</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I needed to check the server uptime for multiple servers, and well, I wanted to do it in PowerShell. <img src='http://everydaynerd.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   I found a sample from <a href="http://msdn.microsoft.com/en-us/library/aa394591(VS.85).aspx" target="_blank">MSDN</a>, and modified it, and threw it into a function.</p>
<pre class="brush: powershell; light: false; title: ; toolbar: true; notranslate">
Function Get-Uptime
{
	#Requires -version 2
	[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact=&quot;High&quot;)]
	Param(
	[parameter(Mandatory=$false,HelpMessage=&quot;Computer Name(s)&quot;,ValueFromPipeline=$true)]
	[object[]]$ComputerName = &quot;.&quot;
	)
	PROCESS
	{
		$WmiOS = Get-WMIObject -class Win32_OperatingSystem -computer $ComputerName
		Function ConvertWMIDateToDateTime($BootTime)
		{
			[System.Management.ManagementDateTimeconverter]::ToDateTime($BootTime)
		}
		Function GetUptime($ComputerName)
		{
			$BootTime = $WmiOS.LastBootUpTime
			$LastBootUpTime = ConvertWMIDateToDateTime($BootTime)
			$Uptime = (Get-Date) - $lastBootUpTime
			$days = $Uptime.Days
			$hours = $Uptime.Hours
			$min = $uptime.Minutes
			$sec = $uptime.Seconds
			[console]::ForegroundColor = &quot;Green&quot;
			&quot;$($ComputerName) has been up for: {0} days, {1} hours, {2} minutes and {3} seconds&quot; -f $days,$hours,$min,$sec
			[console]::ResetColor()
		}
		GetUptime $ComputerName
	}
	&lt;#
		.SYNOPSIS
		Gets uptime of a system via WMI

		.DESCRIPTION
		Get-Uptime uses WMI (specificaly Win32_ComputerSystem) to get the uptime of a system.
		The core component of the script was found at http://msdn.microsoft.com/en-us/library/aa394591(VS.85).aspx
		and addapted with additional functionality.

		.EXAMPLE
		PS c:\&gt; Get-UpTime SERVER01
		SERVER01 has been up for: 355 days, 23 hours, 59 minutes and 59 seconds

		.EXAMPLE
		PS c:\&gt; Get-ExchangeServer | Get-Uptime
		SERVER01 has been up for: 355 days, 23 hours, 59 minutes and 59 seconds
		SERVER02 has been up for: 355 days, 23 hours, 59 minutes and 59 seconds
		SERVER03 has been up for: 355 days, 23 hours, 59 minutes and 59 seconds
		SERVER04 has been up for: 355 days, 23 hours, 59 minutes and 59 seconds

		.LINK
		Script Posted to:

http://everydaynerd.com

		Adapted from sample posted at:

http://msdn.microsoft.com/en-us/library/aa394591(VS.85).aspx

		.NOTES
		Function Name : Get-UpTime
		Author: Dan Burgess
		Email: nerd@everydaynerd.com
		Script Requires:  Powershell 2.x or higher
	#&gt;
}
</pre>
<p>Here&#8217;s an alternative to this function that outputs to a powershell object &#8211; rather than just writing to the screen. (Thanks for the encouragement Jeffery)</p>
<pre class="brush: powershell; light: false; title: ; toolbar: true; notranslate">
Function Get-Uptime
{
	#Requires -version 2
	[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact=&quot;High&quot;)]
	Param(
	[parameter(Mandatory=$true,HelpMessage=&quot;Computer Name(s)&quot;,ValueFromPipeline=$true)]
	[object[]]$ComputerName
	)
	PROCESS
	{
		$System = Get-WMIObject -class Win32_OperatingSystem -computer $ComputerName
		Function GetUptime($ComputerName)
		{
			$Bootup = $System.LastBootUpTime
			$LastBootUpTime = $System.ConvertToDateTime($System.LastBootUpTime)
			$now = Get-Date
			$Uptime = $now - $lastBootUpTime
			$NewObjectProperties = @{
				ComputerName=$ComputerName
				Days=$Uptime.Days;`
				Hours=$Uptime.Hours;`
				Minutes=$Uptime.Minutes;`
				Seconds=$Uptime.Seconds;`
				}
			New-Object psobject -Property $NewObjectProperties
		}
		$Results = GetUptime $ComputerName
		$Results | Select ComputerName, Days, Hours, Minutes, Seconds
	}
	&lt;#
		.SYNOPSIS
		Gets uptime of a system via WMI

		.DESCRIPTION
		Get-Uptime uses WMI (specificaly Win32_ComputerSystem) to get the uptime of a system.
		The core component of the script was found at http://msdn.microsoft.com/en-us/library/aa394591(VS.85).aspx
		and addapted with additional functionality.

		.EXAMPLE
		PS c:\&gt; Get-UpTime server01
		ComputerName : {server01}
		Days         : 27
		Hours        : 2
		Minutes      : 21
		Seconds      : 26

		.EXAMPLE
		PS c:\&gt; Get-ExchangeServer | Get-Uptime | ft -AutoSize
		ComputerName Days Hours Minutes Seconds
		------------ ---- ----- ------- -------
		{server01}    27     2      15      49
		{server02}   130     6      40      23

		.LINK
		Script Posted to:

http://everydaynerd.com

		Adapted from sample posted at:

http://msdn.microsoft.com/en-us/library/aa394591(VS.85).aspx

		.NOTES
		Function Name : Get-UpTime
		Author: Dan Burgess
		Email: nerd@everydaynerd.com
		Script Requires:  Powershell 2.x or higher
	#&gt;
}
</pre>
<p>Happy PowerShelling!</p>
<p>Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-move-windows-server-2008-cluster-group' rel='bookmark' title='PowerShell: Move Windows Server 2008 Cluster Group'>PowerShell: Move Windows Server 2008 Cluster Group</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-drive-space-info-from-multiple-systems' rel='bookmark' title='PowerShell: Drive Space Info from multiple systems'>PowerShell: Drive Space Info from multiple systems</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-change-ps-window-size-on-the-fly' rel='bookmark' title='PowerShell: Change PS Window Size on the fly'>PowerShell: Change PS Window Size on the fly</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-get-uptime-for-computers/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PowerShell: Drive Space Info from multiple systems</title>
		<link>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-drive-space-info-from-multiple-systems</link>
		<comments>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-drive-space-info-from-multiple-systems#comments</comments>
		<pubDate>Wed, 28 Sep 2011 18:24:13 +0000</pubDate>
		<dc:creator>Nerd</dc:creator>
				<category><![CDATA[Exchange]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://everydaynerd.com/?p=1650</guid>
		<description><![CDATA[With PowerShell 2 came Powershell remoting and jobs, both of which are REALLY cool!  I&#8217;m going to show you two ways to get drive space info from multiple systems, first with a normal foreach loop, and then with remoting (which &#8230; <a class="more-link" href="http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-drive-space-info-from-multiple-systems">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-get-uptime-for-computers' rel='bookmark' title='PowerShell: Get-Uptime for Computer(s)'>PowerShell: Get-Uptime for Computer(s)</a></li>
<li><a href='http://everydaynerd.com/how-to/easy-hyperlink-trick-for-windows-even-if-it-has-a-space-in-the-unc-path' rel='bookmark' title='Easy hyperlink trick for Windows (Even if it has a space in the UNC path)'>Easy hyperlink trick for Windows (Even if it has a space in the UNC path)</a></li>
<li><a href='http://everydaynerd.com/microsoft/create-multiple-rdp-files-with-powershell' rel='bookmark' title='Create multiple RDP files with Powershell'>Create multiple RDP files with Powershell</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>With PowerShell 2 came Powershell remoting and jobs, both of which are REALLY cool!  I&#8217;m going to show you two ways to get drive space info from multiple systems, first with a normal foreach loop, and then with remoting (which is basically a remote job).  Both methods use WMI class Win32_LogicalDisk to query the drives for information.</p>
<p>First, the old fashion foreach loop.  Notice the &#8220;Process&#8221; section &#8211; this in essence does a foreach of the $Identity &#8211; notice that in the parameter that the $Identity has  [object[]] in front of it.  Two things about this:  One, [] denotes an array, versus a single object.  Two, it&#8217;s object, instead of string, int or other data type.  Object allows the parameter to be just a string &#8211; a computer name (&#8220;SERVER01&#8243;), a string array (&#8220;SERVER01&#8243;, &#8220;SERVER02&#8243;), or even the identity from other objects (Get-ExchangeServer | GetDriveSpace).  I&#8217;ll be posting more in the future about parameters, and advanced functions (cmdletbinding).</p>
<pre class="brush: powershell; light: false; title: ; toolbar: true; notranslate">
Function GetDriveSpace
{
	[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact=&quot;Low&quot;)]
	param (
	[parameter(Mandatory=$true,HelpMessage=&quot;ComputerName(s)&quot;,ValueFromPipeline=$true)]
	[Object[]]$Identity
	)
	Process
	{
		$Name = (Get-WmiObject -ComputerName $Identity win32_computersystem  | Select Name).Name.ToString()
		$drives = Get-WmiObject -ComputerName $Identity Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3}

		foreach($drive in $drives)
		{
			$NewObjectProperties = @{
				ComputerName=$Name;`
				DriveLetter=$drive.DeviceID;`
				Label=($drive.VolumeName);`
				DriveSize=($drive.Size/1gb).ToString(&quot;0.00&quot;);`
				FreeSpaceMB=($drive.freespace/1GB).tostring(&quot;0.00&quot;);`
				PercentFree=((($drive.freespace/1GB)/($drive.size/1GB))*100).tostring(&quot;0.00&quot;)`
			}
			New-Object psobject -Property $NewObjectProperties
		}
	}

	GetDriveSpace -Identity SERVER01

		Returns Drive Space Info for SERVER01

		.EXAMPLE
		PS] C:\&gt;Get-MailboxServer | GetDriveSpace | FT

		Returns Drive Space Info for Exchange Mailbox Servers

		.EXAMPLE
		PS] C:\&gt;GetDriveSpace -Identity SERVER01, SERVER02 | FT -AutoSize

		Returns Drive Space Info for SERVER01 &amp; SERVER02

		.NOTES
		Function Name : GetDriveSpace
		Author : Dan Burgess
		Email: nerd@everydaynerd.com
		Script Requires:  Powershell 2.0 or higher
	#&gt;
}
</pre>
<p>Now, lets do the same thing, but this time with PowerShell remoting.  As before, the function is utilizing  CmdletBinding, Parameter, with a single param [object[]]$Identity, and the Process block, but an End block as well.  In the Process block, each server passed in the parameter has a remote job started with the Invoke-Command cmdlet, passing the script block with the code to query WMI to return the disk space information.  Note the -AsJob switch &#8211; this allows the invoke-command to work in the background, instead of waiting on the job to finish.  The End block then checks all the jobs, and waits till none of the jobs have a status of &#8220;Running&#8221; before issuing a &#8220;Receive-Job&#8221;.  This gathers all the returned values from each job that ran.  The -Keep leaves a copy of the results in the job queue &#8211; if receive-job is run with out this, the results are removed from the job status.</p>
<pre class="brush: powershell; light: false; title: ; toolbar: true; notranslate">
Function GetDriveSpace-Remoting
{
	[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact=&quot;Low&quot;)]
	param (
	[parameter(Mandatory=$true,HelpMessage=&quot;ComputerName(s)&quot;,ValueFromPipeline=$true)]
	[Object[]]$Identity
	)
	Process
	{
		Invoke-Command -ComputerName $Identity -ScriptBlock {$drives = Get-WmiObject Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3}
			foreach($drive in $drives)
			{
				$NewObjectProperties = @{
					DriveLetter=$drive.DeviceID;`
					Label=($drive.VolumeName);`
					DriveSizeMB=($drive.Size/1gb).ToString(&quot;0.00&quot;);`
					FreeSpaceMB=($drive.freespace/1GB).tostring(&quot;0.00&quot;);`
					PercentFree=((($drive.freespace/1GB)/($drive.size/1GB))*100).tostring(&quot;0.00&quot;)`
				}
				New-Object psobject -Property $NewObjectProperties
			}
		} -SessionOption (New-PSSessionOption -NoMachineProfile) -AsJob

	}
	End
	{
		While (Get-Job -State &quot;Running&quot;)
		{
			$i = ((Get-Job).Count) - ((Get-Job -State &quot;Running&quot;).count)
			$Progress = [int][Math]::Ceiling(($i / ((Get-Job).Count) * 100))
			Write-Progress -Activity &quot;Waiting on $(((Get-Job -State &quot;Running&quot;).count)) Jobs to finish&quot; -PercentComplete $progress -Status &quot;$($progress)% Complete&quot; -Id 1;
		}
		$Results = Get-Job | % {Receive-Job $_ }
		$Results
	}

	GetDriveSpace-Remoting -Identity SERVER01

		Returns Drive Space Info for SERVER01

		.EXAMPLE
		PS] C:\&gt;Get-MailboxServer | GetDriveSpace-Remoting | FT

		Returns Drive Space Info for Exchange Mailbox Servers

		.EXAMPLE
		PS] C:\&gt;GetDriveSpace-Remoting -Identity SERVER01, SERVER02 | FT -AutoSize

		Returns Drive Space Info for SERVER01 &amp; SERVER02

		.NOTES
		Function Name : GetDriveSpace-Remoting
		Author : Dan Burgess
		Email: nerd@everydaynerd.com
		Script Requires:  Powershell 2.0 or higher and WinRM enabled on remote hosts
	#&gt;
}
</pre>
<p>Both methods work, but in my tests, the remote function was MUCH faster when pulling from multiple systems.  For a list of 48 systems, the normal foreach loop took 30 seconds, while the remote function only took 5 seconds!!!</p>
<p>Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-get-uptime-for-computers' rel='bookmark' title='PowerShell: Get-Uptime for Computer(s)'>PowerShell: Get-Uptime for Computer(s)</a></li>
<li><a href='http://everydaynerd.com/how-to/easy-hyperlink-trick-for-windows-even-if-it-has-a-space-in-the-unc-path' rel='bookmark' title='Easy hyperlink trick for Windows (Even if it has a space in the UNC path)'>Easy hyperlink trick for Windows (Even if it has a space in the UNC path)</a></li>
<li><a href='http://everydaynerd.com/microsoft/create-multiple-rdp-files-with-powershell' rel='bookmark' title='Create multiple RDP files with Powershell'>Create multiple RDP files with Powershell</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-drive-space-info-from-multiple-systems/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell: Change PS Window Size on the fly</title>
		<link>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-change-ps-window-size-on-the-fly</link>
		<comments>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-change-ps-window-size-on-the-fly#comments</comments>
		<pubDate>Wed, 28 Sep 2011 10:00:34 +0000</pubDate>
		<dc:creator>Nerd</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://everydaynerd.com/?p=1637</guid>
		<description><![CDATA[First, my apologies for not posting ANYTHING to EverydayNerd since April 25, but hey, this is just for fun, and I DO have a day job I am going to be posting a LOT of PowerShell stuff here, as it &#8230; <a class="more-link" href="http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-change-ps-window-size-on-the-fly">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://everydaynerd.com/software/free/free-e-book-powershell' rel='bookmark' title='Free E-Book: PowerShell'>Free E-Book: PowerShell</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-move-windows-server-2008-cluster-group' rel='bookmark' title='PowerShell: Move Windows Server 2008 Cluster Group'>PowerShell: Move Windows Server 2008 Cluster Group</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-get-uptime-for-computers' rel='bookmark' title='PowerShell: Get-Uptime for Computer(s)'>PowerShell: Get-Uptime for Computer(s)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>First, my apologies for not posting ANYTHING to EverydayNerd since April 25, but hey, this is just for fun, and I DO have a day job <img src='http://everydaynerd.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I am going to be posting a LOT of PowerShell stuff here, as it has, over the last 6 months, become my best friend at the office! Thanks to <a href="http://blogs.technet.com/b/gary/" target="_blank">Gary Siepser</a>, I have gone from writing super simple scripts, to now, well trust me, it’s a day/night difference.</p>
<p>So I work on a laptop, but also dock, and when I un-dock my resolution changes – enough that I have scroll bars in my PowerShell window. This was really annoying, so I wrote a quick function that will change the window size on the fly.</p>
<p>I put these functions into my PowerShell profile, so I can call them whenever I need to change my PS window size. Works like a charm!  If you don&#8217;t know how to edit our PowerShell profile, just enter this in your shell:  notepad $Profile</p>
<p>Hope this helps, and stay tuned for more PowerShell goodies!</p>
<p>Source Code:</p>
<pre escaped="true">
<pre class="brush: powershell; light: false; title: ; toolbar: true; notranslate">
Function Set-Wide
{
	$aff = (Get-Host).UI.RawUI
	$bff = $aff.BufferSize
	$bff.Width = 170
	$bff.Height = 9000
	$aff.BufferSize = $bff
	$wff = $aff.WindowSize
	$wff.Width = 170
	$wff.Height = 60
	$aff.WindowSize = $wff
}

Function Set-Small
{
	$aff = (Get-Host).UI.RawUI
	$wff = $aff.WindowSize
	$wff.Width = 90
	$wff.Height = 45
	$aff.WindowSize = $wff
	$bff = $aff.BufferSize
	$bff.Width = 90
	$bff.Height = 9000
	$aff.BufferSize = $bff
}
</pre>
<p>Related posts:<ol>
<li><a href='http://everydaynerd.com/software/free/free-e-book-powershell' rel='bookmark' title='Free E-Book: PowerShell'>Free E-Book: PowerShell</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-move-windows-server-2008-cluster-group' rel='bookmark' title='PowerShell: Move Windows Server 2008 Cluster Group'>PowerShell: Move Windows Server 2008 Cluster Group</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-get-uptime-for-computers' rel='bookmark' title='PowerShell: Get-Uptime for Computer(s)'>PowerShell: Get-Uptime for Computer(s)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-change-ps-window-size-on-the-fly/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exchange PowerShell Script: Get Mailbox Count by Database</title>
		<link>http://everydaynerd.com/microsoft/software-microsoft/powershell/exchange-powershell-script-get-mailbox-count-by-database</link>
		<comments>http://everydaynerd.com/microsoft/software-microsoft/powershell/exchange-powershell-script-get-mailbox-count-by-database#comments</comments>
		<pubDate>Sat, 26 Mar 2011 17:20:55 +0000</pubDate>
		<dc:creator>Nerd</dc:creator>
				<category><![CDATA[Exchange]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://everydaynerd.com/microsoft/software-microsoft/powershell/exchange-powershell-script-get-mailbox-count-by-database</guid>
		<description><![CDATA[&#160; Here’s a PowerShell script that does a quick count of mailboxes on each database of a server, or all servers – depending if you specify the server name as a script parameter. ** Updated:&#160; I made some improvements to &#8230; <a class="more-link" href="http://everydaynerd.com/microsoft/software-microsoft/powershell/exchange-powershell-script-get-mailbox-count-by-database">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-find-whitespace-on-all-exchange-2007-servers' rel='bookmark' title='Script to Find Whitespace on all Exchange 2007 Servers'>Script to Find Whitespace on all Exchange 2007 Servers</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-get-time-of-exchange-last-online-defrag' rel='bookmark' title='Script: Get time of Exchange last online defrag'>Script: Get time of Exchange last online defrag</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-script-display-exchange-2007-queue-by-site' rel='bookmark' title='Powershell Script: Display Exchange 2007 Queue by Site'>Powershell Script: Display Exchange 2007 Queue by Site</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://everydaynerd.com/wp-content/uploads/2010/07/exchange2k7.png">&nbsp;<img src="http://everydaynerd.com/wp-content/uploads/2011/03/windows_powershell_icon-e1301251108185.png"></p>
<p>Here’s a PowerShell script that does a quick count of mailboxes on each database of a server, or all servers – depending if you specify the server name as a script parameter.</p>
<p>** Updated:&nbsp; I made some improvements to the script, and have posted the updated code.&nbsp; One notable items is that I separated the count of mailboxes and disconnected mailboxes.&nbsp; Previously, the count included both mailboxes and disconnected mailboxes.&nbsp; This may skew the numbers a bit, depending on what&nbsp; you are looking for.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #008000">#=================================================================================================</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #008000"># NAME: Get-MailboxCountPerDatabase.ps1</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #008000">#</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #008000"># AUTHOR:  Dan B.</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span> <span style="color: #008000"># EMAIL:   Nerd@EverydayNerd.com </span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> <span style="color: #008000"># DATE:    03/27/2011</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> <span style="color: #008000"># Version: 1.0</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span> <span style="color: #008000">#</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #008000"># COMMENT: Script to return the count of mailboxes on each server by database</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> <span style="color: #008000">#</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #008000">#=================================== Change Log ==================================================</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span> <span style="color: #008000"># Version 1.0</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> <span style="color: #008000"># -Initial script</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> <span style="color: #008000"># -Changed output to an array instead of just write-host</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span> <span style="color: #008000"># -Added total count to single server</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #008000">#</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> <span style="color: #008000">#=================================================================================================</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum18">  18:</span> <span style="color: #008000"># Script Paramaters to allow server name to be typed after the script name.   If no Param, all servers are returned</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum19">  19:</span>  </pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum20">  20:</span> <span style="color: #0000ff">param</span>([string] $Param )     </pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum21">  21:</span>  </pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum22">  22:</span> $Results = @()</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum23">  23:</span> $CountMB = 0</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum24">  24:</span>  </pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum25">  25:</span> <span style="color: #0000ff">if</span>(!$<span style="color: #0000ff">param</span>)</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum26">  26:</span>     {</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum27">  27:</span>         $Servers = Get-ExchangeServer | Where {$_.ServerRole <span style="color: #cc6633">-eq</span> <span style="color: #006080">"Mailbox"</span>} | Sort Name</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum28">  28:</span>  </pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum29">  29:</span>         Foreach($Server <span style="color: #0000ff">in</span> $Servers)</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum30">  30:</span>             {</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum31">  31:</span>                 $dbs = Get-MailboxDatabase -server $Server | Sort Name</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum32">  32:</span>                 </pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum33">  33:</span>                 <span style="color: #0000ff">foreach</span>($db <span style="color: #0000ff">in</span> $dbs)</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum34">  34:</span>                     {</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum35">  35:</span>                         $mb = Get-MailboxStatistics -Database $db | Where {$_.DisconnectDate <span style="color: #cc6633">-eq</span> $null -and $_.ObjectClass <span style="color: #cc6633">-eq</span> <span style="color: #006080">'Mailbox'</span>} | Measure-Object</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum36">  36:</span>                         $mbdis = Get-MailboxStatistics -Database $db | Where {$_.DisconnectDate <span style="color: #cc6633">-ne</span> $null -and $_.ObjectClass <span style="color: #cc6633">-eq</span> <span style="color: #006080">'Mailbox'</span>} | Measure-Object</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum37">  37:</span>                         </pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum38">  38:</span>                         Write-Host <span style="color: #006080">"$($Server) `t $($db.name)`t $($a.count)"</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum39">  39:</span>                         </pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum40">  40:</span>                         $Obj = New-Object PSObject</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum41">  41:</span>                         $Obj | Add-Member NoteProperty -Name <span style="color: #006080">"Server"</span> -Value $Server</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum42">  42:</span>                         $Obj | Add-Member NoteProperty -Name <span style="color: #006080">"Database"</span> -Value $db.Name</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum43">  43:</span>                         $Obj | Add-Member NoteProperty -Name <span style="color: #006080">"Mailboxes"</span> -Value $mb.count</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum44">  44:</span>                         $Obj | Add-Member NoteProperty -Name <span style="color: #006080">"Disconnected Mailboxes"</span> -Value $mbdis.count</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum45">  45:</span>                         $Results += $Obj</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum46">  46:</span>                     }</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum47">  47:</span>             }</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum48">  48:</span>     }</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum49">  49:</span> <span style="color: #0000ff">else</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum50">  50:</span>     {</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum51">  51:</span>     $server = $<span style="color: #0000ff">param</span></pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum52">  52:</span>         $dbs = Get-MailboxDatabase -server $Server | Sort Name</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum53">  53:</span>  </pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum54">  54:</span>         <span style="color: #0000ff">foreach</span>($db <span style="color: #0000ff">in</span> $dbs)</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum55">  55:</span>             {</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum56">  56:</span>                 $mb = Get-MailboxStatistics -Database $db | Where {$_.DisconnectDate <span style="color: #cc6633">-eq</span> $null -and $_.ObjectClass <span style="color: #cc6633">-eq</span> <span style="color: #006080">'Mailbox'</span>} | Measure-Object</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum57">  57:</span>                 $mbdis = Get-MailboxStatistics -Database $db | Where {$_.DisconnectDate <span style="color: #cc6633">-ne</span> $null -and $_.ObjectClass <span style="color: #cc6633">-eq</span> <span style="color: #006080">'Mailbox'</span>} | Measure-Object</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum58">  58:</span>  </pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum59">  59:</span>                 $Obj = New-Object PSObject</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum60">  60:</span>                 $Obj | Add-Member NoteProperty -Name <span style="color: #006080">"Server"</span> -Value $Server</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum61">  61:</span>                 $Obj | Add-Member NoteProperty -Name <span style="color: #006080">"Database"</span> -Value $db.Name</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum62">  62:</span>                 $Obj | Add-Member NoteProperty -Name <span style="color: #006080">"Mailboxes"</span> -Value $mb.count</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum63">  63:</span>                 $Obj | Add-Member NoteProperty -Name <span style="color: #006080">"Disconnected Mailboxes"</span> -Value $mbdis.count</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum64">  64:</span>                 $Results += $Obj</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum65">  65:</span>                 $countmb += $mb.count</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum66">  66:</span>                 </pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum67">  67:</span>             }</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum68">  68:</span>         Write-Host</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum69">  69:</span>         Write-Host <span style="color: #006080">"$($Server) has a total of $($CountMB) mailboxes"</span> -ForegroundColor Green</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum70">  70:</span>     }</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum71">  71:</span>  </pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum72">  72:</span> $Results | FT -AutoSize</pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum73">  73:</span>  </pre>
<p><!--CRLF-->
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum74">  74:</span> <span style="color: #008000">#===================================== End of Script ==============================================</span></pre>
<p><!--CRLF--></div>
</div>
<p>Script can be downloaded here:&nbsp; <a href="http://everydaynerd.com/files/Get-MailboxCountPerDatabase.ps1" target="_blank">Get-MailboxCountPerDatabase.ps1</a></p>
<p>Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-find-whitespace-on-all-exchange-2007-servers' rel='bookmark' title='Script to Find Whitespace on all Exchange 2007 Servers'>Script to Find Whitespace on all Exchange 2007 Servers</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-get-time-of-exchange-last-online-defrag' rel='bookmark' title='Script: Get time of Exchange last online defrag'>Script: Get time of Exchange last online defrag</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-script-display-exchange-2007-queue-by-site' rel='bookmark' title='Powershell Script: Display Exchange 2007 Queue by Site'>Powershell Script: Display Exchange 2007 Queue by Site</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://everydaynerd.com/microsoft/software-microsoft/powershell/exchange-powershell-script-get-mailbox-count-by-database/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Script: Get time of Exchange last online defrag</title>
		<link>http://everydaynerd.com/microsoft/software-microsoft/powershell/script-get-time-of-exchange-last-online-defrag</link>
		<comments>http://everydaynerd.com/microsoft/software-microsoft/powershell/script-get-time-of-exchange-last-online-defrag#comments</comments>
		<pubDate>Thu, 19 Mar 2009 20:18:00 +0000</pubDate>
		<dc:creator>Nerd</dc:creator>
				<category><![CDATA[Exchange]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://nerd45.wordpress.com/2009/03/19/script-get-time-of-exchange-last-online-defrag</guid>
		<description><![CDATA[digging through the Application log can be a real pain sometimes.  Last night, I was asked by a Microsoft Engineer to give me the last online defrag of a server that we had a case opened on.  So, instead of &#8230; <a class="more-link" href="http://everydaynerd.com/microsoft/software-microsoft/powershell/script-get-time-of-exchange-last-online-defrag">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-find-whitespace-on-all-exchange-2007-servers' rel='bookmark' title='Script to Find Whitespace on all Exchange 2007 Servers'>Script to Find Whitespace on all Exchange 2007 Servers</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-script-display-exchange-2007-queue-by-site' rel='bookmark' title='Powershell Script: Display Exchange 2007 Queue by Site'>Powershell Script: Display Exchange 2007 Queue by Site</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/exchange-powershell-script-get-mailbox-count-by-database' rel='bookmark' title='Exchange PowerShell Script: Get Mailbox Count by Database'>Exchange PowerShell Script: Get Mailbox Count by Database</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>digging through the Application log can be a real pain sometimes.  Last night, I was asked by a Microsoft Engineer to give me the last online defrag of a server that we had a case opened on.  So, instead of opening up the Event Viewer, I went to Powershell:</p>
<div id="codeSnippetWrapper" style="border-right:silver 1px solid;border-top:silver 1px solid;font-size:8pt;overflow:auto;border-left:silver 1px solid;width:97.5%;cursor:text;direction:ltr;max-height:200px;line-height:12pt;border-bottom:silver 1px solid;font-family:'Courier New', courier, monospace;background-color:#f4f4f4;text-align:left;margin:20px 0 10px;padding:4px;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;direction:ltr;line-height:12pt;font-family:'Courier New', courier, monospace;background-color:#f4f4f4;text-align:left;border-style:none;margin:0;padding:0;"><span style="color:#008000;"># Script to return the date and time of the last online defrag of each Exchange 2007 Database</span><span style="color:#008000;"># Highly recommended to run this locally on the Exchange server, not remotely.</span><span style="color:#008000;"># Written by Dan Burgess</span><span style="color:#008000;"># nerd@EverydayNerd.com</span>

$servername = read-host <span style="color:#006080;">"Enter Exchange Mailbox Server Name"</span>$db = Get-StorageGroup -Server $servername | Get-MailboxDatabase

<span style="color:#0000ff;">foreach</span> ($objItem <span style="color:#0000ff;">in</span> $db)    {        $EventLogs = get-EventLog -Logname Application| Where-Object {$_.EventID <span style="color:#cc6633;">-eq</span> 703 -or $_.EventID <span style="color:#cc6633;">-eq</span> 701 -and $_.source <span style="color:#cc6633;">-eq</span> <span style="color:#006080;">'ESE'</span> } | Where-Object {$_.ReplacementStrings <span style="color:#cc6633;">-like</span> $objItem.EdbFilePath} | select-object -first 1        write-host <span style="color:#006080;">' Mailbox store: '</span> $objItem.Identity        write-host <span style="color:#006080;">' Last Defrag completed: '</span> $EventLogs.TimeGenerated        write-host <span style="color:#006080;">' '</span>    }</pre>
<p></div>
</p>
<p>Works like a charm!  Next time you need to extract info from a computers log files, edit this script to match the EventID that you need, and slap it in Powershell!  Happy scripting!</p>
<p>Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-find-whitespace-on-all-exchange-2007-servers' rel='bookmark' title='Script to Find Whitespace on all Exchange 2007 Servers'>Script to Find Whitespace on all Exchange 2007 Servers</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-script-display-exchange-2007-queue-by-site' rel='bookmark' title='Powershell Script: Display Exchange 2007 Queue by Site'>Powershell Script: Display Exchange 2007 Queue by Site</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/exchange-powershell-script-get-mailbox-count-by-database' rel='bookmark' title='Exchange PowerShell Script: Get Mailbox Count by Database'>Exchange PowerShell Script: Get Mailbox Count by Database</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://everydaynerd.com/microsoft/software-microsoft/powershell/script-get-time-of-exchange-last-online-defrag/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell Script: Display Exchange 2007 Queue by Site</title>
		<link>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-script-display-exchange-2007-queue-by-site</link>
		<comments>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-script-display-exchange-2007-queue-by-site#comments</comments>
		<pubDate>Wed, 18 Mar 2009 17:23:00 +0000</pubDate>
		<dc:creator>Nerd</dc:creator>
				<category><![CDATA[Exchange]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://nerd45.wordpress.com/2009/03/18/powershell-script-display-exchange-2007-queue-by-site</guid>
		<description><![CDATA[Working in a multi site Exchange 2007 environment can be cumbersome when trying to view queue information on the Hub servers.  I wrote this script to simplify this process. The script queries the Exchange 2007 organization, finds the servers with &#8230; <a class="more-link" href="http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-script-display-exchange-2007-queue-by-site">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-find-whitespace-on-all-exchange-2007-servers' rel='bookmark' title='Script to Find Whitespace on all Exchange 2007 Servers'>Script to Find Whitespace on all Exchange 2007 Servers</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/exchange-powershell-script-get-mailbox-count-by-database' rel='bookmark' title='Exchange PowerShell Script: Get Mailbox Count by Database'>Exchange PowerShell Script: Get Mailbox Count by Database</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-get-time-of-exchange-last-online-defrag' rel='bookmark' title='Script: Get time of Exchange last online defrag'>Script: Get time of Exchange last online defrag</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Working in a multi site Exchange 2007 environment can be cumbersome when trying to view queue information on the Hub servers.  I wrote this script to simplify this process.  <br />The script queries the Exchange 2007 organization, finds the servers with the Hub Transport Roles, and grouping them into sites (you will have to define the sites yourself, based on your organizational configuration).  You can find the sites for your organization by entering this command:
<div id="codeSnippetWrapper" style="border-right:silver 1px solid;border-top:silver 1px solid;font-size:8pt;overflow:auto;border-left:silver 1px solid;width:97.5%;cursor:text;direction:ltr;max-height:200px;line-height:12pt;border-bottom:silver 1px solid;font-family:'Courier New',courier,monospace;background-color:#f4f4f4;text-align:left;margin:20px 0 10px;padding:4px;">
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;direction:ltr;line-height:12pt;font-family:'Courier New',courier,monospace;background-color:#f4f4f4;text-align:left;border-style:none;margin:0;padding:0;">Get-ExchangeServer | Where { $_.isHubTransportServer <span style="color:#cc6633;">-eq</span> $true } | sort name</pre>
</div>
<p>This will output a table of all the Hub Transport servers and list the Site for each.  Take these site names, and change the script with your values.  You can also modify the variable names to match each site’s name.</p>
<p>Script:</p>
<div id="codeSnippetWrapper" style="border-right:silver 1px solid;border-top:silver 1px solid;font-size:8pt;overflow:auto;border-left:silver 1px solid;width:97.5%;cursor:text;direction:ltr;max-height:200px;line-height:12pt;border-bottom:silver 1px solid;font-family:'Courier New', courier, monospace;background-color:#f4f4f4;text-align:left;margin:20px 0 10px;padding:4px;"> 
<pre style="font-size:8pt;overflow:visible;width:100%;color:black;direction:ltr;line-height:12pt;font-family:'Courier New', courier, monospace;background-color:#f4f4f4;text-align:left;border-style:none;margin:0;padding:0;"><span style="color:#008000;"># Exchange 2007 Powershell Script</span><span style="color:#008000;"># Script to display queue information of Hub Transport Servers</span><span style="color:#008000;"># Dynamicly selects Exchange Hub Transport Servers from Exchange 2007 Organization</span><span style="color:#008000;"># Selects server's location by Site</span><span style="color:#008000;"># Output queue information</span><span style="color:#008000;"># Writen by Dan Burgess</span><span style="color:#008000;"># nerd@EverydayNerd.com</span>

cls

<span style="color:#008000;"># Set variables</span>$last = <span style="color:#006080;">"begin"</span>$choice = <span style="color:#006080;">'start'</span>

<span style="color:#008000;"># Dynamicly set variables for each site's hub transport servers, and sort by server name</span>$usa = Get-ExchangeServer | where { $_.isHubTransportServer <span style="color:#cc6633;">-eq</span> $true -and $_.Site <span style="color:#cc6633;">-like</span> <span style="color:#006080;">'*USA*'</span> } | sort name $eur = Get-ExchangeServer | Where { $_.isHubTransportServer <span style="color:#cc6633;">-eq</span> $true -and $_.Site <span style="color:#cc6633;">-like</span> <span style="color:#006080;">'*EUR*'</span> } | sort name $chi = Get-ExchangeServer | Where { $_.isHubTransportServer <span style="color:#cc6633;">-eq</span> $true -and $_.Site <span style="color:#cc6633;">-like</span> <span style="color:#006080;">'*CHI*'</span> } | sort name $aus = Get-ExchangeServer | Where { $_.isHubTransportServer <span style="color:#cc6633;">-eq</span> $true -and $_.Site <span style="color:#cc6633;">-like</span> <span style="color:#006080;">'*AUS*'</span> } | sort name $afr = Get-ExchangeServer | Where { $_.isHubTransportServer <span style="color:#cc6633;">-eq</span> $true -and $_.Site <span style="color:#cc6633;">-like</span> <span style="color:#006080;">'*AFR*'</span> } | sort name $allhub = Get-ExchangeServer | Where { $_.isHubTransportServer <span style="color:#cc6633;">-eq</span> $true } | sort name

<span style="color:#008000;"># Start WHILE loop, that allows the user to repeat or select the choice selection instead of exiting the script after completion</span><span style="color:#0000ff;">while</span> ($choice <span style="color:#cc6633;">-ne</span> <span style="color:#006080;">'x'</span>){write-host <span style="color:#006080;">""</span>write-host <span style="color:#006080;">"0 - All Sites"</span> -foregroundcolor Yellowwrite-host <span style="color:#006080;">"1 - America (USA)"</span> -foregroundcolor Yellowwrite-host <span style="color:#006080;">"2 - Europe (EUR)"</span> -foregroundcolor Yellowwrite-host <span style="color:#006080;">"3 - China (CHI)"</span> -foregroundcolor Yellowwrite-host <span style="color:#006080;">"4 - Austrialia (AUS)"</span> -foregroundcolor Yellowwrite-host <span style="color:#006080;">"5 - Africa (AFR)"</span> -foregroundcolor Yellowwrite-host <span style="color:#006080;">"6 - All Queue with messages higher than 10"</span> -foregroundcolor Greenwrite-host <span style="color:#006080;">"X - Exit"</span> -foregroundcolor Redwrite-host <span style="color:#006080;">""</span>

<span style="color:#008000;"># If statement to see check if first selection, or sequencial</span><span style="color:#0000ff;">if</span>($last <span style="color:#cc6633;">-eq</span> <span style="color:#006080;">"begin"</span>)    {        [console]::ForegroundColor = <span style="color:#006080;">"Green"</span>        $choice = read-host <span style="color:#006080;">"Select site to check Hub Queue's"</span>        [console]::ResetColor()    }<span style="color:#0000ff;">else</span>    {        [console]::ForegroundColor = <span style="color:#006080;">"Green"</span>        $choice = read-host <span style="color:#006080;">"Select site to check Hub Queue's (Press Enter to repeat your last selection)"</span>        [console]::ResetColor()        }

    <span style="color:#0000ff;">switch</span> ($choice)        {            0 { $hub = $allhub }            1 { $hub = $usa }            2 { $hub = $eur }            3 { $hub = $chi }            4 { $hub = $aus }            5 { $hub = $afr }            6 { $hub = $allhub }            x {  }            <span style="color:#0000ff;">default</span> { $choice = $last }        }

<span style="color:#008000;"># For each server in the site selected, get the queue information, and list as a table</span>    <span style="color:#0000ff;">if</span>($choice <span style="color:#cc6633;">-eq</span> <span style="color:#006080;">"6"</span>)        {        <span style="color:#006080;">"Begin Hub List"</span> &gt; HubQueueOutput.txt        <span style="color:#006080;">"--------------------------------------"</span> &gt;&gt; HubQueueOutput.txt        <span style="color:#0000ff;">foreach</span> ( $server <span style="color:#0000ff;">in</span> $hub )            {                get-exchangeserver $server -erroraction silentlycontinue | get-queue -erroraction silentlycontinue | where {$_.MessageCount <span style="color:#cc6633;">-gt</span> 10 } &gt;&gt; HubQueueOutput.txt            }        <span style="color:#006080;">"--------------------------------------"</span> &gt;&gt; HubQueueOutput.txt        <span style="color:#006080;">"End Hub List"</span> &gt;&gt; HubQueueOutput.txt        more HubQueueOutput.txt        }        <span style="color:#0000ff;">elseif</span>($choice <span style="color:#cc6633;">-ne</span> <span style="color:#006080;">"x"</span>)        {        <span style="color:#006080;">"Begin Hub List"</span> &gt; HubQueueOutput.txt        <span style="
color:#006080;">"--------------------------------------"</span> &gt;&gt; HubQueueOutput.txt        <span style="color:#0000ff;">foreach</span> ( $server <span style="color:#0000ff;">in</span> $hub )            {                get-exchangeserver $server -erroraction silentlycontinue | get-queue -erroraction silentlycontinue &gt;&gt; HubQueueOutput.txt            }        <span style="color:#006080;">"--------------------------------------"</span> &gt;&gt; HubQueueOutput.txt        <span style="color:#006080;">"End Hub List"</span> &gt;&gt; HubQueueOutput.txt        more HubQueueOutput.txt        }    <span style="color:#0000ff;">else</span>        {            write-host <span style="color:#006080;">""</span>            write-host <span style="color:#006080;">"Script exiting"</span> -foregroundcolor DarkCyan            write-host <span style="color:#006080;">""</span>            write-host <span style="color:#006080;">"Have a nice day..."</span>            write-host <span style="color:#006080;">""</span>            write-host <span style="color:#006080;">""</span>        }$last = $choice    <span style="color:#008000;"># Go back to begining of WHILE loop, and do it again!    </span>}</pre>
<p></div>
<p>Of course this has to be ran on a machine that hat the Exchange 2007 Powershell installed.  Hope this helps, and saves time!</p>
<p>Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-find-whitespace-on-all-exchange-2007-servers' rel='bookmark' title='Script to Find Whitespace on all Exchange 2007 Servers'>Script to Find Whitespace on all Exchange 2007 Servers</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/exchange-powershell-script-get-mailbox-count-by-database' rel='bookmark' title='Exchange PowerShell Script: Get Mailbox Count by Database'>Exchange PowerShell Script: Get Mailbox Count by Database</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-get-time-of-exchange-last-online-defrag' rel='bookmark' title='Script: Get time of Exchange last online defrag'>Script: Get time of Exchange last online defrag</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-script-display-exchange-2007-queue-by-site/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Script to Find Whitespace on all Exchange 2007 Servers</title>
		<link>http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-find-whitespace-on-all-exchange-2007-servers</link>
		<comments>http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-find-whitespace-on-all-exchange-2007-servers#comments</comments>
		<pubDate>Fri, 23 Jan 2009 17:53:00 +0000</pubDate>
		<dc:creator>Nerd</dc:creator>
				<category><![CDATA[Exchange]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://nerd45.wordpress.com/2009/01/23/script-to-find-whitespace-on-all-exchange-2007-servers</guid>
		<description><![CDATA[As an Exchange Admin, I’m sure you have had the need to find out how much whitespace is in each of your Exchange databases.  This can be a real pain to do, crawling through the Event Log, looking for Event &#8230; <a class="more-link" href="http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-find-whitespace-on-all-exchange-2007-servers">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-get-time-of-exchange-last-online-defrag' rel='bookmark' title='Script: Get time of Exchange last online defrag'>Script: Get time of Exchange last online defrag</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-script-display-exchange-2007-queue-by-site' rel='bookmark' title='Powershell Script: Display Exchange 2007 Queue by Site'>Powershell Script: Display Exchange 2007 Queue by Site</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/exchange-powershell-script-get-mailbox-count-by-database' rel='bookmark' title='Exchange PowerShell Script: Get Mailbox Count by Database'>Exchange PowerShell Script: Get Mailbox Count by Database</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>As an Exchange Admin, I’m sure you have had the need to find out how much whitespace is in each of your Exchange databases.  This can be a real pain to do, crawling through the Event Log, looking for Event ID 1221.  This script will query all Exchange 2007 Mailbox servers, crawl through the Event logs, and return the Whitespace for every Database you have.  This information can also be exported to a SQL database, if you un-comment the appropriate lines.</p>
<p>Hope this makes your job easier!</p>
<p><strong>*** Special thanks to my co-worker Stephen M for writing this script, and suggesting that I post it to ExchangeStyle.EverydayNerd.com – Thanks!</strong></p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;"># Script: Get-WhiteSpace.ps1 will return the Whitespace on every Mailbox Server in an Exchange 2007 Environment</span><span style="color:#008000;"># Author: EverydayNerd.com</span><span style="color:#008000;"># Contact: Nerd [at] everydaynerd.com</span>

<span style="color:#008000;"># Uncomment to write to a database                              </span>

<span style="color:#008000;">#$db = “Enter Server Name Here”</span><span style="color:#008000;">#$catalog = “Enter Database Catalog Here”</span><span style="color:#008000;">#$conn = New-Object System.Data.SqlClient.SqlConnection("Data Source=$db; Initial Catalog=$catalog; Integrated Security=SSPI")</span><span style="color:#008000;">#$conn.Open()</span>

$WmidtQueryDT = [System.Management.ManagementDateTimeConverter]::ToDmtfDateTime([DateTime]::UtcNow.AddDays(-1))$servers = Get-ExchangeServer | Where{$_.ServerRole <span style="color:#cc6633;">-eq</span> <span style="color:#006080;">'None'</span> -or $_.ServerRole <span style="color:#cc6633;">-like</span> <span style="color:#006080;">'*Mailbox*'</span>} | sort name<span style="color:#0000ff;">foreach</span> ($server <span style="color:#0000ff;">in</span> $servers){Write-Host $serverGet-WmiObject -computer $server -query (<span style="color:#006080;">"Select * from Win32_NTLogEvent Where Logfile='Application' and Eventcode = '1221' and TimeWritten &gt;='"</span> + $WmidtQueryDT + <span style="color:#006080;">"'"</span>) |ForEach-Object{                $time = [System.Management.ManagementDateTimeConverter]::ToDateTime($_.TimeGenerated).ToString()                $date = $time.split(<span style="color:#006080;">"' '"</span>)                $writedate = $date[0]                $mbnamearray = $_.message.split(<span style="color:#006080;">"' '"</span>)                $store = $mbnamearray[2]                $store = $store -replace <span style="color:#006080;">'"'</span>, <span style="color:#006080;">''</span>                $size = [math]::round(($mbnamearray[4]/1024),4)                $search = $server.ToString() + <span style="color:#006080;">"\" + $store.ToString()

                                $test = Get-ExchangeServer $server                                If ($server.ServerRole -eq 'None'){                                                $root =[ADSI]'LDAP://RootDSE'                                                $cfConfigRootpath = "</span>LDAP://<span style="color:#006080;">" + $root.ConfigurationNamingContext.tostring()                                                $configRoot = [ADSI]$cfConfigRootpath                                                $searcher = New-Object DirectoryServices.DirectorySearcher($configRoot)                                                $searcher.Filter = '(&amp;(objectCategory=msExchExchangeServer)(cn=' + $Server + '))'                                                $searchres = $searcher.FindOne()                                                $snServerEntry = New-Object System.DirectoryServices.directoryentry                                                $snServerEntry = $searchres.GetDirectoryEntry()

                                                $adsiServer = [ADSI]('LDAP://' + $snServerEntry.DistinguishedName)                                                $dfsearcher = new-object System.DirectoryServices.DirectorySearcher($adsiServer)                                                $dfsearcher.Filter = "</span>(objectCategory=msExchPrivateMDB)<span style="color:#006080;">"                                                $srSearchResults = $dfsearcher.FindAll()                                                foreach ($srSearchResult in $srSearchResults){                                                                $msMailStore = $srSearchResult.GetDirectoryEntry()                                                                $srnamearray = $_.message.split("</span><span style="color:#006080;">'\'")                                                                $srstore = $mbnamearray[2]                                                                $srstore = $srstore -replace '</span><span style="color:#006080;">"',''                                                                If ($srstore.ToString() -like $store.ToString()){                                                                $EDBFile = $msMailStore.msExchEDBFile                                                                $EDBFilePath = "</span>\\<span style="color:#006080;">" + $server.ToString() + "</span>\<span style="color:#006080;">" + $EDBFile.ToString()                                                                $EDBFilePath = $EDBFilePath -replace ':', '$'                                                                $EDBFileSize = Get-Item $EDBFilePath.ToString() | select Length                                                                }                                                }                                }                                Else{                                                $EDBFile = Get-MailboxDatabase -Identity $search | select EDBFilePath                                                $EDBFile = $EDBFile -replace '@{EdbFilePath=', ''                                                $EDBFile = $EDBFile -replace '}', ''                                                $EDBFile = $EDBFile -replace ':', '$'                                                $EDBFilePath = "</span>\\<span style="color:#006080;">" + $server.ToString() + "</span>\<span style="color:#006080;">" + $EDBFile.ToString()                                                $EDBFileSize = Get-Item $EDBFilePath.ToString() | select Length                                                }

                                $EDBFileSize = $EDBFileSize -replace '@{Length=', ''                                $EDBFileSize = $EDBFileSize -replace '}', ''                                $EDBFileSize = [math]::round(((($EDBFileSize/1024)/1024)/1024),2)

# Uncomment to write to a database                                              #$cmd = $conn.CreateCommand()                #$cmd.CommandText ="</span>INSERT EventLog1221 VALUES (<span style="color:#006080;">'$writedate'</span>, <span style="color:#006080;">'$server'</span>, <span style="color:#006080;">'$store'</span>, <span style="color:#006080;">'$size'</span>, <span style="color:#006080;">'$EDBFileSize'</span>)"                <s
pan style="color:#008000;">#$cmd.ExecuteNonQuery()</span>

                Write-Host $writedate $server $store $size $EDBFileSize                }}<span style="color:#008000;"># Uncomment to write to a database                              </span><span style="color:#008000;">#$conn.Close()</span></pre>
<p></div>
<p>Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-get-time-of-exchange-last-online-defrag' rel='bookmark' title='Script: Get time of Exchange last online defrag'>Script: Get time of Exchange last online defrag</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-script-display-exchange-2007-queue-by-site' rel='bookmark' title='Powershell Script: Display Exchange 2007 Queue by Site'>Powershell Script: Display Exchange 2007 Queue by Site</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/exchange-powershell-script-get-mailbox-count-by-database' rel='bookmark' title='Exchange PowerShell Script: Get Mailbox Count by Database'>Exchange PowerShell Script: Get Mailbox Count by Database</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-find-whitespace-on-all-exchange-2007-servers/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Save Password in .RDP File</title>
		<link>http://everydaynerd.com/microsoft/save-password-in-rdp-file</link>
		<comments>http://everydaynerd.com/microsoft/save-password-in-rdp-file#comments</comments>
		<pubDate>Fri, 23 Jan 2009 17:51:06 +0000</pubDate>
		<dc:creator>Nerd</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://everydaynerd.com/microsoft/save-password-in-rdp-file</guid>
		<description><![CDATA[I shared with you how to create multiple .rdp files with Powershell, and now, I want to show&#160; you how to make your job even easier!&#160; I&#160; ran across this blog, and downloaded his RDP password Hash program.&#160; It got &#8230; <a class="more-link" href="http://everydaynerd.com/microsoft/save-password-in-rdp-file">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://everydaynerd.com/scripts/save-hashed-password-in-rdp-file' rel='bookmark' title='Save Hashed Password in RDP file'>Save Hashed Password in RDP file</a></li>
<li><a href='http://everydaynerd.com/microsoft/create-multiple-rdp-files-with-powershell' rel='bookmark' title='Create multiple RDP files with Powershell'>Create multiple RDP files with Powershell</a></li>
<li><a href='http://everydaynerd.com/security/change-windows-forgotten-password-with-konboot' rel='bookmark' title='Change Windows forgotten password with KonBoot'>Change Windows forgotten password with KonBoot</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I shared with you how to <a href="http://everydaynerd.com/microsoft/create-multiple-rdp-files-with-powershell" target="_blank">create multiple .rdp files with Powershell</a>, and now, I want to show&#160; you how to make your job even easier!&#160; I&#160; ran across <a href="http://www.remkoweijnen.nl/blog/2007/10/18/how-rdp-passwords-are-encrypted/" target="_blank">this blog</a>, and downloaded his RDP password Hash program.&#160; It got me thinking, I could make my job easier by saving the password in a hashed format in each RDP file that my Powershell script creates!</p>
<p><em><font color="#ff0000">** Note:&#160; Please see my <a href="http://everydaynerd.com/microsoft/save-password-in-rdp-file" target="_blank">original post</a> about this if you have questions of the files needed, and folder structure.</font></em></p>
<p>First, I modified the .CSV file, adding a new column “PASS” – in that column, add the hashed password created from <a href="http://www.remkoweijnen.nl/blog/2007/10/18/how-rdp-passwords-are-encrypted/" target="_blank">remkoweijnen.nl</a>’s password hash program [<a href="http://everydaynerd.com/files/rdp_password_hash.zip" target="_blank">DOWNLOAD</a>]</p>
<p>Then I modified my Powershell script, adding in the password to script, so it’s added to the .RDP file.</p>
<p>No more typing in passwords to connect to servers.&#160; Also, the nice thing is, if you have to change the password, just modify the hash file in the .CSV file, and re-run the Powershell script!</p>
<p>Here is the modified Powershell Script:</p>
<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">$List = Import-CSV RDPLIST.CSV
$resolutions = (<span style="color: #006080">&quot;Console&quot;</span>,<span style="color: #006080">&quot;Cullscreen&quot;</span>,<span style="color: #006080">&quot;Widescreen&quot;</span>,<span style="color: #006080">&quot;Docked&quot;</span>)
ForEach($Entry <span style="color: #0000ff">in</span> $List) {
  ForEach($resolution <span style="color: #0000ff">in</span> $resolutions) {
    <span style="color: #008000"># Prepend the destination directory info for RDP files</span>
    $Dir = <span style="color: #006080">&quot;..\&quot; + $resolution + &quot;</span>\<span style="color: #006080">&quot; + $Entry.Directory

    # Create new folder
    New-Item -Path $Dir -ItemType Directory -Force

    # Build the file name
    $FileName = $Dir + &quot;</span>\<span style="color: #006080">&quot; + $Entry.ServerName + &quot;</span>.RDP<span style="color: #006080">&quot;

    # Remove the old file
    Remove-Item $FileName -Force

    # Begin building RDP file
    $temp = &quot;</span>`nfull address:s:<span style="color: #006080">&quot; + $Entry.IP 

    switch ($resolution) {

      &quot;</span>Console<span style="color: #006080">&quot; {
        $temp += &quot;</span>`nscreen mode id:i:1<span style="color: #006080">&quot;
        $temp += &quot;</span>`ndesktopwidth:i:1024<span style="color: #006080">&quot;
        $temp += &quot;</span>`ndesktopheight:i:768<span style="color: #006080">&quot;
        $temp += &quot;</span>`nusername:s:<span style="color: #006080">&quot; + $Entry.USER
        $temp += &quot;</span>`npassword 51:b:<span style="color: #006080">&quot; + $Entry.PASS
        $temp += &quot;</span>`nadministrative session:i:1<span style="color: #006080">&quot;
      }

      &quot;</span>Fullscreen<span style="color: #006080">&quot; {
        $temp += &quot;</span>`nscreen mode id:i:2<span style="color: #006080">&quot;
        $temp += &quot;</span>`nusername:s:<span style="color: #006080">&quot; + $Entry.USER
        $temp += &quot;</span>`npassword 51:b:<span style="color: #006080">&quot; + $Entry.PASS
      }

      &quot;</span>Widescreen<span style="color: #006080">&quot; {
        $temp += &quot;</span>`nscreen mode id:i:1<span style="color: #006080">&quot;
        $temp += &quot;</span>`ndesktopwidth:i:1152<span style="color: #006080">&quot;
        $temp += &quot;</span>`ndesktopheight:i:720<span style="color: #006080">&quot;
        $temp += &quot;</span>`nusername:s:<span style="color: #006080">&quot; + $Entry.USER
        $temp += &quot;</span>`npassword 51:b:<span style="color: #006080">&quot; + $Entry.PASS
      }

      &quot;</span>Docked<span style="color: #006080">&quot; {
        $temp += &quot;</span>`nscreen mode id:i:1<span style="color: #006080">&quot;
        $temp += &quot;</span>`ndesktopwidth:i:1152<span style="color: #006080">&quot;
        $temp += &quot;</span>`ndesktopheight:i:864<span style="color: #006080">&quot;
        $temp += &quot;</span>`nusername:s:<span style="color: #006080">&quot; + $Entry.USER
        $temp += &quot;</span>`npassword 51:b:&quot; + $Entry.PASS
      }
    }
    $temp | out-file $FileName
    write-host $temp
    get-content template_bottom.txt &gt;&gt; $FileName
  }
}</pre>
</div>
<p>Related posts:<ol>
<li><a href='http://everydaynerd.com/scripts/save-hashed-password-in-rdp-file' rel='bookmark' title='Save Hashed Password in RDP file'>Save Hashed Password in RDP file</a></li>
<li><a href='http://everydaynerd.com/microsoft/create-multiple-rdp-files-with-powershell' rel='bookmark' title='Create multiple RDP files with Powershell'>Create multiple RDP files with Powershell</a></li>
<li><a href='http://everydaynerd.com/security/change-windows-forgotten-password-with-konboot' rel='bookmark' title='Change Windows forgotten password with KonBoot'>Change Windows forgotten password with KonBoot</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://everydaynerd.com/microsoft/save-password-in-rdp-file/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Auto Grow DPM Protection Groups by Percentage Thresholds</title>
		<link>http://everydaynerd.com/microsoft/software-microsoft/powershell/auto-grow-dpm-protection-groups-by-percentage-thresholds</link>
		<comments>http://everydaynerd.com/microsoft/software-microsoft/powershell/auto-grow-dpm-protection-groups-by-percentage-thresholds#comments</comments>
		<pubDate>Tue, 20 Jan 2009 19:04:00 +0000</pubDate>
		<dc:creator>Nerd</dc:creator>
				<category><![CDATA[DPM]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://nerd45.wordpress.com/2009/01/20/auto-grow-dpm-protection-groups-by-percentage-thresholds</guid>
		<description><![CDATA[Managing many DPM servers can turn into quite a time consuming activity, especially when it comes to allocating more disk space to Data Sources.  The Ctrl-P DPM blog has a real simple auto-grow script on their site, but I personally &#8230; <a class="more-link" href="http://everydaynerd.com/microsoft/software-microsoft/powershell/auto-grow-dpm-protection-groups-by-percentage-thresholds">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-remove-all-datasources-in-inactive-protection' rel='bookmark' title='Script to remove all datasources in Inactive Protection'>Script to remove all datasources in Inactive Protection</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-%e2%80%93-create-recovery-points' rel='bookmark' title='Script – Create Recovery Points'>Script – Create Recovery Points</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/dpm/fix-error-3114-error-30216' rel='bookmark' title='Fix Error 3114 &amp; Error 30216'>Fix Error 3114 &amp; Error 30216</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Managing many DPM servers can turn into quite a time consuming activity, especially when it comes to allocating more disk space to Data Sources.  The Ctrl-P DPM blog has a real simple auto-grow script on their site, but I personally have had issues with it, as have many others on the Net.  It is also rather lacking in “bells and whistles” but for an everyday DPM admin, it sure would make life easier.  In my quest for ways to make my job easier, I found this absolutely AWESOME script that Owen Clashing <a href="http://oclashing.spaces.live.com/blog/cns!41A7CD6191124074!258.entry">wrote on his blog</a>.</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;">#This DPM powershell script helps automate the growing of replica and shadow copy volumes which need to be grown.</span><span style="color:#0000ff;">param</span>([string] $DPMServerName, [string] $Mode, [int] $ReplicaThreshold, [int] $ReplicaGrowBy, [int] $RecoveryPointThreshold, [int] $RecoveryPointGrowBy) 

<span style="color:#008000;">###### Define variables for default values</span>$DefaultDPMServerName         = $env:COMPUTERNAME  <span style="color:#008000;"># Assumes that the current computer is the DPM server</span>$DefaultMode                 = <span style="color:#006080;">"A"</span>$DefaultReplicaThreshold     = 90$DefaultReplicaGrowBy         = 5$DefaultShadowCopyThreshold = 90$DefaultShadowCopyGrowBy     = 5<span style="color:#008000;">######</span>

<span style="color:#0000ff;">function</span> Usage(){    write-host    write-host <span style="color:#006080;">"Usage::"</span>    write-host <span style="color:#006080;">"AutoGrowByPercentWithDefaults.ps1"</span>    write-host <span style="color:#006080;">"AutoGrowByPercentWithDefaults.ps1 -DPMServerName [DPMServername] -Mode [A|C]"</span>    write-host    write-host <span style="color:#006080;">"Run 'AutoGrowByPercentWithDefaults.ps1 -detailed' for detailed help"</span>    write-host    write-host}

<span style="color:#0000ff;">if</span>((<span style="color:#006080;">"-?"</span>,<span style="color:#006080;">"-help"</span>) -contains $args[0]){    Usage    exit 0}

<span style="color:#0000ff;">if</span>((<span style="color:#006080;">"-detailed"</span>) -contains $args[0]){    write-host    write-host <span style="color:#006080;">"Detailed Help :  Use this script to automatically grow the replica and recovery point volume sizes"</span>    write-host <span style="color:#006080;">"Parameters:"</span>    write-host <span style="color:#006080;">"-DPMServerName [DPMServername] :: The name of the DPM server that is being targetted"</span>    write-host <span style="color:#006080;">"-Mode [A|C] :: A - Audit only (make no disk allocation changes); C - Change disk allocations"</span>    write-host <span style="color:#006080;">"-ReplicaThreshold [Replica Threshold %] :: Percentage usage above which disk space allocation for the replica volume will be triggered"</span>    write-host <span style="color:#006080;">"-ReplicaGrowBy [Replica Grow By %] :: Percentage by which to grow the replica volume"</span>    write-host <span style="color:#006080;">"-RecoveryPointThreshold [Recovery Point Threshold %] :: Percentage usage above which disk space allocation for the recovery point volume will be triggered"</span>    write-host <span style="color:#006080;">"-RecoveryPointGrowBy [Recovery Point Grow By %] :: Percentage by which to grow the recovery point volume"</span>    write-host <span style="color:#006080;">"Current default values:"</span>    write-host <span style="color:#006080;">"-DPMServerName $DefaultDPMServerName"</span>    write-host <span style="color:#006080;">"-Mode $DefaultMode"</span>    write-host <span style="color:#006080;">"-ReplicaThreshold $DefaultReplicaThreshold"</span>    write-host <span style="color:#006080;">"-ReplicaGrowBy $DefaultReplicaGrowBy"</span>    write-host <span style="color:#006080;">"-RecoveryPointThreshold $DefaultShadowCopyThreshold"</span>    write-host <span style="color:#006080;">"-RecoveryPointGrowBy $DefaultShadowCopyGrowBy"</span>    write-host     exit 0}

<span style="color:#0000ff;">if</span>(!$DPMServerName){    $DPMServerName = $DefaultDPMServerName}

<span style="color:#0000ff;">if</span>(!$Mode){    $Mode = $DefaultMode}<span style="color:#0000ff;">else</span>{    <span style="color:#0000ff;">if</span> (($Mode <span style="color:#cc6633;">-ne</span> <span style="color:#006080;">"A"</span>) -or ($Mode <span style="color:#cc6633;">-ne</span> <span style="color:#006080;">"C"</span>))    {        Usage        exit 0    }}

<span style="color:#0000ff;">if</span>(!$ReplicaThreshold){    $ReplicaThreshold = $DefaultReplicaThreshold}

<span style="color:#0000ff;">if</span>(!$ReplicaGrowBy){    $ReplicaGrowBy = $DefaultReplicaGrowBy}

<span style="color:#008000;"># Note the inconsistency in the naming - Object model name Shadow Copy, GUI name Recovery Point</span><span style="color:#008000;"># We use the GUI names in naming the parameters to keep it familiar for the casual user.</span><span style="color:#0000ff;">if</span>(!$RecoveryPointThreshold){    $ShadowCopyThreshold = $DefaultShadowCopyThreshold}<span style="color:#0000ff;">else</span>{    $ShadowCopyThreshold = $RecoveryPointThreshold}

<span style="color:#0000ff;">if</span>(!$RecoveryPointGrowBy){    $ShadowCopyGrowBy = $DefaultShadowCopyGrowBy}<span style="color:#0000ff;">else</span>{    $ShadowCopyThreshold = $RecoveryPointGrowBy}

<span style="color:#0000ff;">switch</span> ($Mode){    <span style="color:#006080;">"A"</span>     {        $ChangeHighlightColor = <span style="color:#006080;">"Green"</span>        write-host <span style="color:#006080;">"In audit mode - No changes will be made to the disk allocations"</span> -foregroundcolor $ChangeHighlightColor    }    <span style="color:#006080;">"C"</span>     {        $ChangeHighlightColor = <span style="color:#006080;">"Red"</span>        write-host <span style="color:#006080;">"In change mode - Changes will be made to the disk allocations"</span> -foregroundcolor $ChangeHighlightColor    }}

$dpmserver = Connect-DPMServer $DPMServerName

<span style="color:#0000ff;">if</span>(!$dpmserver){    write-error <span style="color:#006080;">"Unable to connect to $dpmservername"</span>    exit 1}

$PGList = @(Get-ProtectionGroup $DPMServerName)

<span style="color:#0000ff;">foreach</span>($PG <span style="color:#0000ff;">in</span> $PGList){     <span style="color:#008000;"># Use a modifiable protection group only if we are in change mode</span>    <span style="color:#008000;"># A non-modifiable protection group object is significantly faster</span>    <span style="color:#0000ff;">if</span> ($Mode <span style="color:#cc6633;">-eq</span> <span style="color:#006080;">"C"</span>)    {        $MPG = Get-ModifiableProtectionGroup $PG    }    <span style="color:#0000ff;">else</span>    {<br
 />        $MPG = $PG    }

    $dslist=@(get-datasource $MPG)    <span style="color:#0000ff;">foreach</span> ($ds <span style="color:#0000ff;">in</span> $dslist)    {        $ReplicaUsedPercent = ($ds.ReplicaUsedSpace/$ds.ReplicaSize)        $ShadowCopyUsedPercent = ($ds.ShadowCopyUsedSpace/$ds.ShadowCopyAreaSize)        <span style="color:#006080;">"------------------------------------------------------------------------"</span>        <span style="color:#008000;">#"Protection Group: $PG.Name"</span>        <span style="color:#006080;">"$ds"</span>

        <span style="color:#008000;"># $ds.ReplicaSize = -1 when there is no replica component to the backup</span>        <span style="color:#008000;"># Only process if there is replica disk space allocated</span>        <span style="color:#0000ff;">if</span> ($ds.ReplicaSize <span style="color:#cc6633;">-ne</span> -1)        {            <span style="color:#006080;">"Replica Used %                 : {0:P2}"</span> -f $ReplicaUsedPercent

            <span style="color:#0000ff;">if</span>($ReplicaUsedPercent <span style="color:#cc6633;">-gt</span> $ReplicaThreshold/100)            {                $ReplicaGrowByActual = ($ReplicaGrowBy/100)*$ds.ReplicaSize                $NewReplicaSize = $ds.ReplicaSize + $ReplicaGrowByActual                <span style="color:#006080;">"Replica Grow %                 : {0:P2}"</span> -f $($ReplicaGrowBy/100)                write-host $(<span style="color:#006080;">"Replica Grow Actual (GB)       : {0:N2}"</span> -f $($ReplicaGrowByActual/1GB)) -foregroundcolor $ChangeHighlightColor                <span style="color:#006080;">"Replica New Total (GB)         : {0:N2}"</span> -f $($NewReplicaSize/1GB)

                <span style="color:#0000ff;">if</span> ($Mode <span style="color:#cc6633;">-eq</span> <span style="color:#006080;">"C"</span>)                {                    Set-DatasourceDiskAllocation -Manual -Datasource $ds -ProtectionGroup $MPG -ReplicaArea $NewReplicaSize                }            }            <span style="color:#0000ff;">else</span>            {                <span style="color:#006080;">"Replica Grow %                 : 0.00 %"</span>                <span style="color:#006080;">"Replica Grow Actual (GB)       : 0.00"</span>                <span style="color:#006080;">"Replica New Total (GB)         : {0:N2}"</span> -f $(($ds.ReplicaSize)/1GB)            }        }        <span style="color:#0000ff;">else</span>        {            <span style="color:#006080;">"No disk space allocated for replica"</span>        }

        <span style="color:#008000;"># $ds.ShadowCopyAreaSize = -1 when there is no shadow copy component to the backup</span>        <span style="color:#008000;"># Only process if there is shadow copy disk space allocated</span>        <span style="color:#0000ff;">if</span> ($ds.ShadowCopyAreaSize <span style="color:#cc6633;">-ne</span> -1)        {            <span style="color:#006080;">"Recovery Point Used %          : {0:P2}"</span> -f $ShadowCopyUsedPercent

            <span style="color:#0000ff;">if</span>($ShadowCopyUsedPercent <span style="color:#cc6633;">-gt</span> $ShadowCopyThreshold/100)            {                $ShadowCopyGrowByActual = ($ShadowCopyGrowBy/100)*$ds.ShadowCopyAreaSize                $NewShadowCopySize = $ds.ShadowCopyAreaSize + $ShadowCopyGrowByActual                <span style="color:#006080;">"Recovery Point Grow %          : {0:P2}"</span> -f $($ShadowCopyGrowBy/100)                write-host $(<span style="color:#006080;">"Recovery Point Grow Actual (GB): {0:N2}"</span> -f $($ShadowCopyGrowByActual/1GB)) -foregroundcolor $ChangeHighlightColor                <span style="color:#006080;">"Recovery Point New Total (GB)  : {0:N2}"</span> -f $($NewShadowCopySize/1GB)

                <span style="color:#0000ff;">if</span> ($Mode <span style="color:#cc6633;">-eq</span> <span style="color:#006080;">"C"</span>)                {                    Set-DatasourceDiskAllocation -Manual -Datasource $ds -ProtectionGroup $MPG -ShadowCopyArea $NewShadowCopySize                }            }            <span style="color:#0000ff;">else</span>            {                <span style="color:#006080;">"Recovery Point Grow %          : 0.00 %"</span>                <span style="color:#006080;">"Recovery Point Grow Actual (GB): 0.00"</span>                <span style="color:#006080;">"Recovery Point New Total (GB)  : {0:N2}"</span> -f $($ds.ShadowCopyAreaSize/1GB)            }        }        <span style="color:#0000ff;">else</span>        {            <span style="color:#006080;">"No disk space allocated for recovery point"</span>        }    }

     <span style="color:#008000;"># Update the protection group if we are in change mode</span>    <span style="color:#0000ff;">if</span> ($Mode <span style="color:#cc6633;">-eq</span> <span style="color:#006080;">"C"</span>)    {        Set-ProtectionGroup $MPG    }}

Disconnect-DPMServer $DPMServerName

<span style="color:#006080;">"------------------------------------------------------------------------"</span></pre>
<p></div>
<p>I LOVE the –MODE switch, allowing me to run the script, and see the results, without actually changing any disk allocations.  I’ve added this script to the DPM servers that I manage, and have the task scheduler run it twice a day.  No more failed jobs due to lack of disk space!  Yeah!</p>
<p>Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-remove-all-datasources-in-inactive-protection' rel='bookmark' title='Script to remove all datasources in Inactive Protection'>Script to remove all datasources in Inactive Protection</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-%e2%80%93-create-recovery-points' rel='bookmark' title='Script – Create Recovery Points'>Script – Create Recovery Points</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/dpm/fix-error-3114-error-30216' rel='bookmark' title='Fix Error 3114 &amp; Error 30216'>Fix Error 3114 &amp; Error 30216</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://everydaynerd.com/microsoft/software-microsoft/powershell/auto-grow-dpm-protection-groups-by-percentage-thresholds/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Script – Create Recovery Points</title>
		<link>http://everydaynerd.com/microsoft/software-microsoft/powershell/script-%e2%80%93-create-recovery-points</link>
		<comments>http://everydaynerd.com/microsoft/software-microsoft/powershell/script-%e2%80%93-create-recovery-points#comments</comments>
		<pubDate>Fri, 16 Jan 2009 19:04:00 +0000</pubDate>
		<dc:creator>Nerd</dc:creator>
				<category><![CDATA[DPM]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://nerd45.wordpress.com/2009/01/16/script-%e2%80%93-create-recovery-points</guid>
		<description><![CDATA[In the environment that I work, DPM protects the Exchange 2007 servers.  I have only one Exchange server in each protection group.  Each Exchange server has between 10-20 Storage Groups (or Data Sources).  If I want to initiate a backup &#8230; <a class="more-link" href="http://everydaynerd.com/microsoft/software-microsoft/powershell/script-%e2%80%93-create-recovery-points">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/auto-grow-dpm-protection-groups-by-percentage-thresholds' rel='bookmark' title='Auto Grow DPM Protection Groups by Percentage Thresholds'>Auto Grow DPM Protection Groups by Percentage Thresholds</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-remove-all-datasources-in-inactive-protection' rel='bookmark' title='Script to remove all datasources in Inactive Protection'>Script to remove all datasources in Inactive Protection</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-script-display-exchange-2007-queue-by-site' rel='bookmark' title='Powershell Script: Display Exchange 2007 Queue by Site'>Powershell Script: Display Exchange 2007 Queue by Site</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In the environment that I work, DPM protects the Exchange 2007 servers.  I have only one Exchange server in each protection group.  Each Exchange server has between 10-20 Storage Groups (or Data Sources).  If I want to initiate a backup on the entire server, it is a pain to select each storage group, click Create Recovery Point, and select either Full or Incremental, then click Close.  </p>
<p>The script below does all that for me.  It connects to the DPM server, lists the Protection Groups, asks if you want to run an Express Full, or Incremental backup, then initiates the jobs for each Data Source in the Protection Group (each Storage Group on the Exchange Server).</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.77%;font-family:consolas, 'Courier New', courier, monospace;height:199px;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#008000;"># DPM 2007 Powershell Script</span><span style="color:#008000;"># Script to initiate a Recovery Point for each Data Source in a Protection Group</span><span style="color:#008000;"># Initial Script from Technet, but Modified to give more choices</span><span style="color:#008000;"># Edited by Dan Burgess</span><span style="color:#008000;"># nerd@EverydayNerd.com</span>

<span style="color:#0000ff;">param</span>([string] $dpmname, [string] $pgname, [string] $backupoption) <span style="color:#008000;"># Clear the screen</span>cls<span style="color:#008000;">#Get name of Localhost</span>$CompStat = Get-WmiObject win32_computersystem$Localhst = $CompStat.Name

<span style="color:#008000;"># Notify that connected to Localhost</span>write-host <span style="color:#006080;">""</span>write-host <span style="color:#006080;">"Script: Create-RecoveryPoint"</span> -foregroundcolor Blue -backgroundcolor whitewrite-host <span style="color:#006080;">""</span>write-host <span style="color:#006080;">""</span>Write-host <span style="color:#006080;">"Connected to Localhost: $Localhst"</span> -foregroundcolor Blue -backgroundcolor whitewrite-host <span style="color:#006080;">""</span>write-host <span style="color:#006080;">""</span>

<span style="color:#008000;"># Set DPM Servername</span>$dpmname = read-host <span style="color:#006080;">"DPM Server Name (Enter for $Localhst):"</span>    <span style="color:#0000ff;">if</span> ($dpmname <span style="color:#cc6633;">-eq</span> <span style="color:#006080;">""</span>)     {   $dpmname = $Localhst   write-host <span style="color:#006080;">"Using Localhost $dpmname "</span> -foregroundcolor green   write-host <span style="color:#006080;">""</span>   write-host <span style="color:#006080;">""</span>  }

<span style="color:#008000;"># List Protection Groups on DPM server</span>$pglist = get-protectiongroup -DPMServerName $dpmnamewrite-host <span style="color:#006080;">"Protection Groups on $dpmname :"</span> -foregroundcolor greenwrite-output $pglistwrite-host <span style="color:#006080;">""</span>write-host <span style="color:#006080;">""</span>

<span style="color:#008000;">#Enter name of Protection Group you wish to create Recovery Point</span>$pgname =  read-host <span style="color:#006080;">"Enter Protection Group Name:"</span>write-host <span style="color:#006080;">""</span>write-host <span style="color:#006080;">""</span>

<span style="color:#008000;">#List choices for JobChoice1 Variable</span>write-host <span style="color:#006080;">"1: Express Full"</span>write-host <span style="color:#006080;">"2: Incremental"</span>write-host <span style="color:#006080;">""</span>

$JobChoice1 = read-host <span style="color:#006080;">"Enter Backup type - 1 or 2 [Default is 1: Express Full]:"</span>

<span style="color:#0000ff;">switch</span> ($JobChoice1)   {    1 { $backupoption = <span style="color:#006080;">'ExpressFull'</span> }    2 { $backupoption = <span style="color:#006080;">'Incremental'</span> }<span style="color:#0000ff;">default</span> { $backupoption = <span style="color:#006080;">'ExpressFull'</span> }        }write-host <span style="color:#006080;">""</span>Write-host <span style="color:#006080;">"You selected $backupoption"</span> -foregroundcolor Blue -backgroundcolor whitewrite-host <span style="color:#006080;">""</span>

<span style="color:#0000ff;">trap</span>{<span style="color:#006080;">"Error in execution... $_"</span>;<span style="color:#0000ff;">break</span>}

    <span style="color:#0000ff;">if</span>($clipg <span style="color:#cc6633;">-eq</span> $abc)    {        write-host <span style="color:#006080;">""</span>        Throw <span style="color:#006080;">"No ProtectionGroup found"</span>        write-host <span style="color:#006080;">""</span>    }    <span style="color:#0000ff;">else</span>    {    write-host <span style="color:#006080;">""</span>    write-host <span style="color:#006080;">"Getting DataSource from Protection Group $pgname..."</span> -foregroundcolor green    write-host <span style="color:#006080;">""</span>

<span style="color:#008000;"># Create variable of each Datasource from Protection Group </span>    $backupds = @(Get-Datasource $clipg)

<span style="color:#008000;"># Run the Job for each DataSource in Protection Group      </span>    <span style="color:#0000ff;">foreach</span> ($ds <span style="color:#0000ff;">in</span> $backupds)    {          write-host <span style="color:#006080;">""</span>        write-host <span style="color:#006080;">"Creating Recovery point for $ds..."</span> -foregroundcolor Blue -backgroundcolor white               write-host <span style="color:#006080;">""</span>

    $job = New-RecoveryPoint -Datasource $ds -Disk -BackupType $backupoption        $jobtype = $job.jobtype        Write-host <span style="color:#006080;">"$jobtype Job has been triggerred..."</span> -foregroundcolor green    }    }}</pre>
<p></div>
<p>I’ve been playing around with this script for a while, and there is more that I want to do to it, but I figured I’d share it, and hope it helps someone out.  I’d love some input on how to make the script better!</p>
<p>One thing I’d really like to do, but have not been able to figure it out yet, is have a status update at the end, updating every 10 seconds showing the Server name, PGname, Status, and HasCompleted – until True.  Just a thought… would save me from having to RDP into all the DPM servers…</p>
<p>Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/auto-grow-dpm-protection-groups-by-percentage-thresholds' rel='bookmark' title='Auto Grow DPM Protection Groups by Percentage Thresholds'>Auto Grow DPM Protection Groups by Percentage Thresholds</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-remove-all-datasources-in-inactive-protection' rel='bookmark' title='Script to remove all datasources in Inactive Protection'>Script to remove all datasources in Inactive Protection</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-script-display-exchange-2007-queue-by-site' rel='bookmark' title='Powershell Script: Display Exchange 2007 Queue by Site'>Powershell Script: Display Exchange 2007 Queue by Site</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://everydaynerd.com/microsoft/software-microsoft/powershell/script-%e2%80%93-create-recovery-points/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Powershell Script to list all Cluster Active Nodes</title>
		<link>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-script-to-list-all-cluster-active-nodes</link>
		<comments>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-script-to-list-all-cluster-active-nodes#comments</comments>
		<pubDate>Fri, 09 Jan 2009 19:54:00 +0000</pubDate>
		<dc:creator>Nerd</dc:creator>
				<category><![CDATA[Exchange]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://nerd45.wordpress.com/2009/01/09/powershell-script-to-list-all-cluster-active-nodes</guid>
		<description><![CDATA[If you have a medium to large infrastructure, it is helpful to know what node of your Exchange Clusters is the active node.  This can be done manually, but it is much easier if done with the following script:   &#8230; <a class="more-link" href="http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-script-to-list-all-cluster-active-nodes">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-move-windows-server-2008-cluster-group' rel='bookmark' title='PowerShell: Move Windows Server 2008 Cluster Group'>PowerShell: Move Windows Server 2008 Cluster Group</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-drive-space-info-from-multiple-systems' rel='bookmark' title='PowerShell: Drive Space Info from multiple systems'>PowerShell: Drive Space Info from multiple systems</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/exchange-powershell-script-get-mailbox-count-by-database' rel='bookmark' title='Exchange PowerShell Script: Get Mailbox Count by Database'>Exchange PowerShell Script: Get Mailbox Count by Database</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>If you have a medium to large infrastructure, it is helpful to know what node of your Exchange Clusters is the active node.  This can be done manually, but it is much easier if done with the following script:</p>
<p> </p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, 'Courier New', courier, monospace;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">$Clusters = Get-MailboxServer | Where-Object { $_.RedundantMachines } | Select Name</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"> </pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"> <span style="color:#0000ff;">foreach</span> ($cluster <span style="color:#0000ff;">in</span> $clusters) {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    Get-ClusteredMailboxServerStatus -identity $Cluster.name | Select OperationalMachines,State </pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"> </pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, 'Courier New', courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    }</pre>
<p>  </div>
<p></div>
<p>Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-move-windows-server-2008-cluster-group' rel='bookmark' title='PowerShell: Move Windows Server 2008 Cluster Group'>PowerShell: Move Windows Server 2008 Cluster Group</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-drive-space-info-from-multiple-systems' rel='bookmark' title='PowerShell: Drive Space Info from multiple systems'>PowerShell: Drive Space Info from multiple systems</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/exchange-powershell-script-get-mailbox-count-by-database' rel='bookmark' title='Exchange PowerShell Script: Get Mailbox Count by Database'>Exchange PowerShell Script: Get Mailbox Count by Database</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-script-to-list-all-cluster-active-nodes/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Script to remove all datasources in Inactive Protection</title>
		<link>http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-remove-all-datasources-in-inactive-protection</link>
		<comments>http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-remove-all-datasources-in-inactive-protection#comments</comments>
		<pubDate>Thu, 25 Sep 2008 14:28:00 +0000</pubDate>
		<dc:creator>Nerd</dc:creator>
				<category><![CDATA[DPM]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://nerd45.wordpress.com/2008/09/25/script-to-remove-all-datasources-in-inactive-protection</guid>
		<description><![CDATA[After I moved several protected servers from one DPM server to another, I had a LOT of exchange storage groups left in the Inactive Protection that I wanted to get rid of.  Doing this  manually was very time consuming, and &#8230; <a class="more-link" href="http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-remove-all-datasources-in-inactive-protection">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/auto-grow-dpm-protection-groups-by-percentage-thresholds' rel='bookmark' title='Auto Grow DPM Protection Groups by Percentage Thresholds'>Auto Grow DPM Protection Groups by Percentage Thresholds</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-%e2%80%93-create-recovery-points' rel='bookmark' title='Script – Create Recovery Points'>Script – Create Recovery Points</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-find-whitespace-on-all-exchange-2007-servers' rel='bookmark' title='Script to Find Whitespace on all Exchange 2007 Servers'>Script to Find Whitespace on all Exchange 2007 Servers</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>After I <a target="_blank" href="http://dpmstyle.everydaynerd.com/2008/09/move-protected-server-agent-to-another.html">moved several protected servers from one DPM server to another</a>, I had a LOT of exchange storage groups left in the Inactive Protection that I wanted to get rid of.  Doing this  manually was very time consuming, and lots of clicks.  So, after a quick search, I found a script on the <a target="_blank" href="http://blogs.technet.com/dpm/archive/tags/DPM+2007/default.aspx">Ctrl P blog</a> that does exactly what I needed to do!</p>
<p>Usage:</p>
<p>Remove-InactiveDatasource.ps1 -DPMServerName [DPMServername] -RemoveOption [Remove Options]</p>
<p>Run &#8216;Remove-InactiveDatasource.ps1 -detailed&#8217; for detailed help</p>
<p><strong>Attachment:</strong> <a target="_blank" href="http://everydaynerd.com/files/Remove-InactiveDatasource.ps1">Remove-InactiveDatasource.ps1</a></p>
<p>Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/auto-grow-dpm-protection-groups-by-percentage-thresholds' rel='bookmark' title='Auto Grow DPM Protection Groups by Percentage Thresholds'>Auto Grow DPM Protection Groups by Percentage Thresholds</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-%e2%80%93-create-recovery-points' rel='bookmark' title='Script – Create Recovery Points'>Script – Create Recovery Points</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-find-whitespace-on-all-exchange-2007-servers' rel='bookmark' title='Script to Find Whitespace on all Exchange 2007 Servers'>Script to Find Whitespace on all Exchange 2007 Servers</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://everydaynerd.com/microsoft/software-microsoft/powershell/script-to-remove-all-datasources-in-inactive-protection/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create multiple RDP files with Powershell</title>
		<link>http://everydaynerd.com/microsoft/create-multiple-rdp-files-with-powershell</link>
		<comments>http://everydaynerd.com/microsoft/create-multiple-rdp-files-with-powershell#comments</comments>
		<pubDate>Sun, 14 Sep 2008 01:43:51 +0000</pubDate>
		<dc:creator>Nerd</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://everydaynerd.com/microsoft/create-multiple-rdp-files-with-powershell</guid>
		<description><![CDATA[RDP &#8211; Remote Desktop Connection, or what we called back in the day, Terminal Services.  Every system administrator uses it daily.  At work, the team I work on has 145 servers that we are responsible for, and only a handful &#8230; <a class="more-link" href="http://everydaynerd.com/microsoft/create-multiple-rdp-files-with-powershell">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/save-password-in-rdp-file' rel='bookmark' title='Save Password in .RDP File'>Save Password in .RDP File</a></li>
<li><a href='http://everydaynerd.com/scripts/save-hashed-password-in-rdp-file' rel='bookmark' title='Save Hashed Password in RDP file'>Save Hashed Password in RDP file</a></li>
<li><a href='http://everydaynerd.com/microsoft/windows-7-slow-remote-desktop-rdp-fix' rel='bookmark' title='Windows 7 Slow Remote Desktop (RDP) fix'>Windows 7 Slow Remote Desktop (RDP) fix</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img style="border-right-width: 0px; margin: 0px 15px 0px 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" src="http://everydaynerd.com/wp-content/uploads/2008/09/image34.png" border="0" alt="image" width="236" height="240" align="left" /></p>
<p>RDP &#8211; Remote Desktop Connection, or what we called back in the day, Terminal Services.  Every system administrator uses it daily.  At work, the team I work on has 145 servers that we are responsible for, and only a handful of them are in the same building as us (although we still remote into them as well).</p>
<p>This being said, I was getting tired of typing in the server&#8217;s name or IP address every time I needed to connect to it.  I know Microsoft has an mmc for Remote Desktops, but I just don&#8217;t like the clunky way it has to be setup, plus, did I mention I had 145 to put in?  Well, call me lazy, but I knew there had to be a way to script it &#8211; after all, a RDP file is nothing but some text (open a .rdp file with notepad &#8211; you&#8217;ll see!).</p>
<p>So, enough background, lets do some scripting!  There are 3 files here:  Powershell script, a CSV file, and a Text file.</p>
<ul>
<li>First, the CSV File:  It has 4 columns with the first row being the headers.  Do not change row.  Name this file <strong>RDPLIST.csv</strong></li>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">ServerName,IP,Directory,USER
FRIENDLYNAME,FQDNorIP,FOLDERNAME\SUBFOLDER,DOMAIN\USERNAME</pre>
</div>
<li>Next, is the Text File.  This contains other parameters that are going to be the same between every connection &#8211; such as enabling shared clipboard, 16bit colors, disable themes, etc.  You can customize this to your liking <em>(to get it just the way you want it, create an .rdp file, and edit it with notepad, and you will see a list similar to below). </em>Name this file <strong>template_bottom.txt</strong></li>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">audiomode:i:2
authentication level:i:0
autoreconnection enabled:i:1
bitmapcachepersistenable:i:1
compression:i:1
disable cursor setting:i:0
disable full window drag:i:1
disable menu anims:i:1
disable themes:i:1
disable wallpaper:i:1
displayconnectionbar:i:1
keyboardhook:i:2
redirectclipboard:i:1
redirectcomports:i:0
redirectdrives:i:0
redirectprinters:i:0
redirectsmartcards:i:0
session bpp:i:16
prompt <span style="color: #0000ff">for</span> credentials:i:0
promptcredentialonce:i:1</pre>
</div>
<li>Lastly, the Powershell script: Name this file <strong>CreateRDP.ps1</strong></li>
<div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: consolas,'Courier New',courier,monospace; max-height: 200px; font-size: 8pt; cursor: text;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;">$List = Import-CSV RDPLIST.CSV
$resolutions = (<span style="color: #006080">"Console"</span>,<span style="color: #006080">"fullscreen"</span>,<span style="color: #006080">"1024x768"</span>,<span style="color: #006080">"1152x864"</span>)
ForEach($Entry <span style="color: #0000ff">in</span> $List) {
  ForEach($resolution <span style="color: #0000ff">in</span> $resolutions) {
    <span style="color: #008000"># Prepend the destination directory info for RDP files</span>
    $Dir = <span style="color: #006080">"..\" + $resolution + "</span>\<span style="color: #006080">" + $Entry.Directory

    # Create new folder
    New-Item -Path $Dir -ItemType Directory -Force

    # Build the file name
    $FileName = $Dir + "</span>\<span style="color: #006080">" + $Entry.ServerName + "</span>.RDP<span style="color: #006080">"

    # Remove the old file
    Remove-Item $FileName -Force

    # Begin building RDP file
    $temp = "</span>`nfull address:s:<span style="color: #006080">" + $Entry.IP 

    switch ($resolution) {

      "</span>Console<span style="color: #006080">" {
        $temp = $temp + "</span>`nscreen mode id:i:1<span style="color: #006080">"
    $temp = $temp + "</span>`ndesktopwidth:i:1024<span style="color: #006080">"
        $temp = $temp + "</span>`ndesktopheight:i:768<span style="color: #006080">"
    $temp = $temp + "</span>`nusername:s:<span style="color: #006080">" + $Entry.USER
    $temp = $temp + "</span>`nadministrative session:i:1<span style="color: #006080">"
      }

      "</span>Fullscreen<span style="color: #006080">" {
        $temp = $temp + "</span>`nscreen mode id:i:2<span style="color: #006080">"
    $temp = $temp + "</span>`nusername:s:<span style="color: #006080">" + $Entry.USER
      }

      "</span>1024x768<span style="color: #006080">" {
        $temp = $temp + "</span>`nscreen mode id:i:1<span style="color: #006080">"
        $temp = $temp + "</span>`ndesktopwidth:i:1024<span style="color: #006080">"
        $temp = $temp + "</span>`ndesktopheight:i:768<span style="color: #006080">"
    $temp = $temp + "</span>`nusername:s:<span style="color: #006080">" + $Entry.USER
      }

      "</span>1152x864<span style="color: #006080">" {
        $temp = $temp + "</span>`nscreen mode id:i:1<span style="color: #006080">"
        $temp = $temp + "</span>`ndesktopwidth:i:1152<span style="color: #006080">"
        $temp = $temp + "</span>`ndesktopheight:i:864<span style="color: #006080">"
    $temp = $temp + "</span>`nusername:s:" + $Entry.USER
      }
    }
    $temp | out-file $FileName
    write-host $temp
    get-content template_bottom.txt &gt;&gt; $FileName
  }
}</pre>
</div>
</ul>
<p>Now, you need a folder structure:</p>
<ul>
<li>Powershell_RDP
<ul>
<li>rdp
<ul>
<li>_script</li>
</ul>
<p><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" src="http://everydaynerd.com/wp-content/uploads/2008/09/image35.png" border="0" alt="image" width="296" height="120" /></li>
</ul>
<p>Put all three files in the <em>_script</em> folder.</li>
</ul>
<p>And just because I&#8217;m a nice guy, here&#8217;s a zip of the files and the correct folder structure.  Just unzip, make your edits to the csv file, save and close it, and open PowerShell (as Administrator if using Vista) and navigate to the _Script folder.  Once there, run the CreateRDP.ps1 (put a ./ in front of the filename)</p>
<p><a href="http://everydaynerd.com/wp-content/uploads/2008/09/image36.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" src="http://everydaynerd.com/wp-content/uploads/2008/09/image-thumb21.png" border="0" alt="image" width="479" height="101" /></a></p>
<div id="scid:8eb9d37f-1541-4f29-b6f4-1eea890d4876:03b522b2-ebee-4241-a778-45ffc53e4355" class="wlWriterSmartContent" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px">
<div><a href="http://everydaynerd.com/wp-content/uploads/2008/09/powershell-rdp.zip" target="_self">Download Powershell_RDP.zip</a></div>
</div>
<p>Feel free to customize this script to your own liking!  It&#8217;s a simple script, so it shouldn&#8217;t be too hard to mess with.  It works like a CHARM!!!  I created 290 RDP files in less than 30 seconds!  Great thing is, it creates a separate folder structure for the different resolutions (I used 1024&#215;768 &amp; 1152&#215;864 because my laptop is a widescreen, but when I&#8217;m docked, it&#8217;s a standard monitor).</p>
<p>One more tip, I made two new toolbars, and pushed them all the way over to the right of the taskbar, making a nifty little launcher!</p>
<p><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" src="http://everydaynerd.com/wp-content/uploads/2008/09/image37.png" border="0" alt="image" width="291" height="64" /></p>
<p>Hope you enjoy this &#8211; I know I did!  It took me longer to write this post than it did to get all my .RDP files! <img src='http://everydaynerd.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>[ UPDATE:  Original Script was written by <a href="http://blog.geekpoet.net/2007/10/powershell-script-to-create-remote.html" target="_blank">Aaron Dodd</a>, just tweaked by me]</p>
<p>Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/save-password-in-rdp-file' rel='bookmark' title='Save Password in .RDP File'>Save Password in .RDP File</a></li>
<li><a href='http://everydaynerd.com/scripts/save-hashed-password-in-rdp-file' rel='bookmark' title='Save Hashed Password in RDP file'>Save Hashed Password in RDP file</a></li>
<li><a href='http://everydaynerd.com/microsoft/windows-7-slow-remote-desktop-rdp-fix' rel='bookmark' title='Windows 7 Slow Remote Desktop (RDP) fix'>Windows 7 Slow Remote Desktop (RDP) fix</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://everydaynerd.com/microsoft/create-multiple-rdp-files-with-powershell/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Free E-Book: PowerShell</title>
		<link>http://everydaynerd.com/software/free/free-e-book-powershell</link>
		<comments>http://everydaynerd.com/software/free/free-e-book-powershell#comments</comments>
		<pubDate>Fri, 15 Jun 2007 14:56:00 +0000</pubDate>
		<dc:creator>Nerd</dc:creator>
				<category><![CDATA[Free]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Tip]]></category>
		<category><![CDATA[Training]]></category>

		<guid isPermaLink="false">http://everydaynerd.com/general/free-e-book-powershell</guid>
		<description><![CDATA[Source: https://blogs.technet.com/chitpro-de English version of Windows PowerShell course book available for download Due to its great popularity, we have decided to translate the Windows PowerShell course book to English.&#160;The book gives you a short introduction with many exercises about the &#8230; <a class="more-link" href="http://everydaynerd.com/software/free/free-e-book-powershell">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/free-e-book-introducing-sql-server-2008' rel='bookmark' title='Free e-Book: Introducing SQL Server 2008'>Free e-Book: Introducing SQL Server 2008</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-move-windows-server-2008-cluster-group' rel='bookmark' title='PowerShell: Move Windows Server 2008 Cluster Group'>PowerShell: Move Windows Server 2008 Cluster Group</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-change-ps-window-size-on-the-fly' rel='bookmark' title='PowerShell: Change PS Window Size on the fly'>PowerShell: Change PS Window Size on the fly</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h6>Source: <a title="https://blogs.technet.com/chitpro-de" href="https://blogs.technet.com/chitpro-de">https://blogs.technet.com/chitpro-de</a></h6>
<h5>English version of Windows PowerShell course book available for download</h5>
<p>Due to its great popularity, we have decided to translate the Windows PowerShell course book to English.&nbsp;The book gives you a short introduction with many exercises about the interactive part of Windows PowerShell as well as some hints how to use other objects like WMI, .NET or COM objects like Excel or Internet Explorer.
<p>The <a href="https://profile.microsoft.com/RegSysProfileCenter/wizard.aspx?wizid=adf74b41-ae6a-42f4-8445-db39ecabb8b3&amp;lcid=1033&amp;fu=http://download.microsoft.com/download/a/9/4/a94270c7-ed16-4c72-8280-658c66315719/Windows%20Powershell%20-%20EN.zip" target="_blank">book is available for free</a> and you can share it with all your colleagues or friends if you leave it as it is. The books can be used with or without the <a href="http://download.microsoft.com/download/a/9/4/a94270c7-ed16-4c72-8280-658c66315719/PowerShell-Demofiles.zip" target="_blank">demo files</a> available at this blog as well.</p>
<p>Related posts:<ol>
<li><a href='http://everydaynerd.com/microsoft/free-e-book-introducing-sql-server-2008' rel='bookmark' title='Free e-Book: Introducing SQL Server 2008'>Free e-Book: Introducing SQL Server 2008</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-move-windows-server-2008-cluster-group' rel='bookmark' title='PowerShell: Move Windows Server 2008 Cluster Group'>PowerShell: Move Windows Server 2008 Cluster Group</a></li>
<li><a href='http://everydaynerd.com/microsoft/software-microsoft/powershell/powershell-change-ps-window-size-on-the-fly' rel='bookmark' title='PowerShell: Change PS Window Size on the fly'>PowerShell: Change PS Window Size on the fly</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://everydaynerd.com/software/free/free-e-book-powershell/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

