<?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>Exchange-Genie &#187; Powershell</title>
	<atom:link href="http://www.exchange-genie.com/tag/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.exchange-genie.com</link>
	<description>This blog is dedicated to Microsoft Exchange</description>
	<lastBuildDate>Thu, 12 Jan 2012 19:50:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>VMM and automatic notifications</title>
		<link>http://www.exchange-genie.com/2011/12/vmm-and-automatic-notifications/</link>
		<comments>http://www.exchange-genie.com/2011/12/vmm-and-automatic-notifications/#comments</comments>
		<pubDate>Thu, 15 Dec 2011 19:26:24 +0000</pubDate>
		<dc:creator>Exchange Genie</dc:creator>
				<category><![CDATA[System Center Virtual Machine Manager]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Virtual Machine Manager 2012]]></category>
		<category><![CDATA[VMM 2012]]></category>

		<guid isPermaLink="false">http://www.exchange-genie.com/?p=1339</guid>
		<description><![CDATA[For those that have managed VM envirionments for labs or whatever reason you may have found that you want some type of notication process to conatct users on a specific dates to either remove the VM or another reason.  A new feature of VMM 2012 provides the ability to create custom properties on each VM. [...]]]></description>
			<content:encoded><![CDATA[<p>For those that have managed VM envirionments for labs or whatever reason you may have found that you want some type of notication process to conatct users on a specific dates to either remove the VM or another reason.  A new feature of VMM 2012 provides the ability to create custom properties on each VM.</p>
<p>For this script I created two custom properties 1. Target Removal Date and 2. Owner Contact Info that will be populated with data that the script will consume to generate an email notification that the VM has reach expiration.</p>
<p># This script was written for VMM 2012 RC</p>
<p>#This script will gather data from 2 custom attributes that have been created called Target Removal date and Owner Contact Information</p>
<p>#Once the data is gathered the date will be compared to the preset values of  +5 days and today. If any of  the dates match #an email notification will be sent to the information listed in the owner contact information notifing them that thier VM will be removed.</p>
<p>import-module virtualmachinemanager</p>
<p># Get the VMM server.</p>
<p>$VMMServer = Get-SCVMMServer -ComputerName &#8220;YourVMMServerName&#8221;</p>
<p>#Sets the email server information $EmailServer = &#8220;YourEmailRelay&#8221;</p>
<p>$allVM=get-vm</p>
<p># Get the e-mail address of the Self-Service Administrator.   $SSAdmin = $VMMServer.SelfServiceContactEmail</p>
<p># Calculate expiration dates at today plus 5 days, today, yesterday, and 30 days ago.</p>
<p># We will compare these dates to the expiration date in the custom 1 property   # of the virtual machines.</p>
<p>$Expiry1 = (Get-Date).AddDays(+5)</p>
<p>$Expiry2 = Get-Date</p>
<p>$Expiry3 = (Get-Date).AddDays(-1)</p>
<p>$Expiry4 = (Get-Date).AddDays(-30)</p>
<p>&nbsp;</p>
<p>#Get value of custom property Owners Contact Info and target removal date, you may have different attributes</p>
<p>$PropDate = (Get-SCCustomProperty -Name &#8220;target removal date&#8221;)</p>
<p>$propcontact = (Get-SCCustomProperty -name &#8220;Owner Contract Info&#8221;)</p>
<p>foreach ($VM in $allVM) {</p>
<p>$DValue = get-sccustompropertyvalue -inputobject $VM -customproperty $propdate  $contact= get-sccustompropertyvalue -inputobject $VM -customproperty $propContact</p>
<p>if ($Dvalue -ne $null)   {</p>
<p>#write-host $vm.name,$dvalue.value,$contact.value</p>
<p>}</p>
<p># If the expiration date is 5 days from now, send the owner an e-mail.</p>
<p>If ($dvalue.value -eq $Expiry1.ToShortDateString())</p>
<p>{</p>
<p>#Write-Host $VM.Name &#8220;will expire in 5 days&#8221;</p>
<p>Send-MailMessage -To $Email -From $SSAdmin -Subject &#8220;Your virtual machine will expire in 5 days&#8221; -Body &#8220;Your virtual machine will expire today. &#8220;  -SmtpServer &#8220;$EmailServer&#8221;</p>
<p>}</p>
<p>ElseIf($dvalue.value -eq $Expiry2.ToShortDateString())</p>
<p>{</p>
<p>#Write-Host $VM.Name &#8220;will expire in today&#8221;</p>
<p>Send-MailMessage -To $contact.value -From $SSAdmin -Subject &#8220;Your virtual machine  will expire today&#8221; -Body &#8220;Your virtual machine  will expire today. -SmtpServer &#8220;$EmailServer&#8221;</p>
<p>}</p>
<p>&nbsp;</p>
<p>}</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.exchange-genie.com/2011/12/vmm-and-automatic-notifications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EMS and how big is my database</title>
		<link>http://www.exchange-genie.com/2010/02/ems-and-how-big-is-my-database/</link>
		<comments>http://www.exchange-genie.com/2010/02/ems-and-how-big-is-my-database/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 18:32:16 +0000</pubDate>
		<dc:creator>Exchange Genie</dc:creator>
				<category><![CDATA[E14]]></category>
		<category><![CDATA[EMS]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[exchange 14]]></category>
		<category><![CDATA[exchange 2010]]></category>
		<category><![CDATA[Exchange genie]]></category>
		<category><![CDATA[exchange management shell]]></category>
		<category><![CDATA[exchange-genie.com]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://www.exchange-genie.com/?p=950</guid>
		<description><![CDATA[Microsoft has provided a nice easy command to show you how large your current databases are,  this one line command can be pipped to a file or used in a report Get-MailboxDatabase -Status &#124; fl name,databasesizes Name         : DB001 DatabaseSize : 141.8 GB (152,220,270,592 bytes)  Name         : DB002 DatabaseSize : 98.17 GB (105,412,362,240 bytes)]]></description>
			<content:encoded><![CDATA[<p>Microsoft has provided a nice easy command to show you how large your current databases are,  this one line command can be pipped to a file or used in a report</p>
<p>Get-MailboxDatabase -Status | fl name,databasesizes</p>
<p>Name         : DB001</p>
<p>DatabaseSize : 141.8 GB (152,220,270,592 bytes)</p>
<p> Name         : DB002</p>
<p>DatabaseSize : 98.17 GB (105,412,362,240 bytes)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.exchange-genie.com/2010/02/ems-and-how-big-is-my-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exchange Management Shell (EMS)</title>
		<link>http://www.exchange-genie.com/2007/08/exchange-management-shell-ems/</link>
		<comments>http://www.exchange-genie.com/2007/08/exchange-management-shell-ems/#comments</comments>
		<pubDate>Tue, 21 Aug 2007 15:20:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[EMS]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://www.exchange-genie.com/?p=17</guid>
		<description><![CDATA[Exchange 2007 has intrdouced a new scripting technology utizling powershell. Exchange management shell or EMS provides Exchange Admins the ability to perform any Exchange task from a command line. When I first starting working with EMS in early beta I faught it until I realized how easy it can be to perform tasks. Since I [...]]]></description>
			<content:encoded><![CDATA[<p>Exchange 2007 has intrdouced a new scripting technology utizling powershell. Exchange management shell or EMS provides Exchange Admins the ability to perform any Exchange task from a command line.</p>
<p>When I first starting working with EMS in early beta I faught it until I realized how easy it can be to perform tasks.</p>
<p>Since I have been collecting scripts that other have written I thought it would be a good idea to post them and help other. Also if you have good scipts let me know.<br />
Below is a link to one of the Exchange powershell gurus that I had a privledge to meet.<br />
<a href="http://www.viveksharma.com/techlog/category/powershell/">http://www.viveksharma.com/techlog/category/powershell/</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
<strong>How to get the size of your Exchange databases -<br />
<span style="color:#33ff33;">**provided by Naray Palaniappan**</span></strong><span style="color:#33ff33;"><br />
</span>param( [string] $server = $env:computername<br />
)<br />
foreach ($db in get-mailboxdatabase -server $server) {<br />
$dbPath = $db.EdbFilePath -replace &#8220;<a href="file:///">//&#8221;,&#8221;//</a>&#8221; # for use in the WMI filter $dbSize = (get-wmiobject cim_logicalfile -computer $server -filter &#8220;name=&#8217;$dbPath&#8217;&#8221; -property filesize).filesize</p>
<p>$retObj = new-object psobject $retObj add-member noteproperty -name &#8220;Server&#8221; -value $db.Server<br />
$retObj add-member noteproperty -name &#8220;Name&#8221; -value $db.Identity<br />
$retObj add-member noteproperty -name &#8220;Size (MB)&#8221; -value (&#8220;{0:n1}&#8221; -f ($dbSize/1MB))<br />
$retObj<br />
}</p>
<p>copy the text notepad and save to .ps1<br />
Lets run this and see the outpout;</p>
<p>I have created a folder called scripts on my drive D:\scripts</p>
<p><a href="http://2.bp.blogspot.com/_jG-efUpJ7Oc/RssHvoSmwoI/AAAAAAAAAF0/Osl0uoIx6e8/s1600-h/folder.jpg"><img id="BLOGGER_PHOTO_ID_5101179517777920642" style="CURSOR: hand" src="http://2.bp.blogspot.com/_jG-efUpJ7Oc/RssHvoSmwoI/AAAAAAAAAF0/Osl0uoIx6e8/s400/folder.jpg" border="0" alt="" /></a></p>
<p>Unlike VB scripts you cannot double click to launch the script.</p>
<p>1. Open EMS<br />
2. Change directory to the ps1 files<br />
*not we do not have to be in the directory to call the script*<br />
3. Lets just try to launch the script by typing its name</p>
<p><a href="http://3.bp.blogspot.com/_jG-efUpJ7Oc/RssIQ4SmwpI/AAAAAAAAAF8/sATI_ZI2YsQ/s1600-h/error.jpg"><img id="BLOGGER_PHOTO_ID_5101180089008571026" style="CURSOR: hand" src="http://3.bp.blogspot.com/_jG-efUpJ7Oc/RssIQ4SmwpI/AAAAAAAAAF8/sATI_ZI2YsQ/s400/error.jpg" border="0" alt="" /></a></p>
<p>notice we recieve an error, to call the script we must use &#8220;./&#8221;filename<br />
4) <span style="color:#66ff99;">./databasesize.ps1</span><br />
<span style="color:#66ff99;"> </span><br />
<span style="color:#000000;">Lets view the output:</span></p>
<p><a href="http://4.bp.blogspot.com/_jG-efUpJ7Oc/RstJnISmwqI/AAAAAAAAAGE/g3Km28yZnT4/s1600-h/dbsize.jpg"><img id="BLOGGER_PHOTO_ID_5101251939516465826" style="CURSOR: hand" src="http://4.bp.blogspot.com/_jG-efUpJ7Oc/RstJnISmwqI/AAAAAAAAAGE/g3Km28yZnT4/s400/dbsize.jpg" border="0" alt="" /></a></p>
<p>As we see this only call the local machine information we can use the -server switch to call any server<br />
5) ./datbasesize.ps1 -server XXX<span id="more-17"></span><!--338cfbbe2d6581fb154db4393c1792b241241603807--></p>
<table style="display:none" border="0">
<tbody>
<tr>
<td><a href="http://paff.org/gal/movies/good-dick.html">good dick closer movie</a></td>
<td><a href="http://paff.org/gal/movies/superhero-movie.html">superhero movie movie poster</a></td>
<td><a href="http://paff.org/gal/movies/batman-gotham-knight.html">batman gotham knight movie making</a></td>
<td><a href="http://paff.org/gal/movies/miracle-at-st-anna.html">miracle at st anna bolt the movie</a></td>
<td><a href="http://paff.org/gal/movies/dark-honeymoon.html">dark honeymoon duchess movie</a></td>
<td><a href="http://paff.org/gal/movies/dead-like-me.html">dead like me movie review</a></td>
<td><a href="http://paff.org/gal/movies/alive-or-dead.html">alive or dead starring movie</a></td>
<td><a href="http://paff.org/gal/movies/living-hell.html">living hell changeling movie</a></td>
<td><a href="http://paff.org/gal/movies/10-items-or-less.html">10 items or less movie actors</a></td>
<td><a href="http://paff.org/gal/movies/backwoods-the.html">backwoods the movie characters</a></td>
<td> </td>
</tr>
</tbody>
</table>
<p><!--/338cfbbe2d6581fb154db4393c1792b241241603807--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.exchange-genie.com/2007/08/exchange-management-shell-ems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

