<?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>Luka Manojlovic &#187; Powershell</title>
	<atom:link href="http://luka.manojlovic.net/category/ms-scripting/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>http://luka.manojlovic.net</link>
	<description>Luka&#039;s technical blog</description>
	<lastBuildDate>Sun, 18 Dec 2011 14:19:38 +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>Get IP address of virtual machines running on Hyper-V &#8211; FIXED!</title>
		<link>http://luka.manojlovic.net/2011/03/16/get-ip-address-of-virtual-machines-running-on-hyper-v-fixed/</link>
		<comments>http://luka.manojlovic.net/2011/03/16/get-ip-address-of-virtual-machines-running-on-hyper-v-fixed/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 14:10:48 +0000</pubDate>
		<dc:creator>manojlovicl</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Windows server 2008]]></category>
		<category><![CDATA[Windows server 2008 R2]]></category>

		<guid isPermaLink="false">http://luka.manojlovic.net/?p=311</guid>
		<description><![CDATA[Big thank you &#8211; goes to Max Trinidad my fellow MVP from Powershell group&#8230; Here is errorless script - much better than mine! Copa, paste and save as .ps1 - then run on your Hyper-V server and you will get IP&#8217;s of your virtual machines&#8230; Set-ExecutionPolicy -ExecutionPolicy RemoteSigned ## &#8211; Use Line below to list all your [...]]]></description>
			<content:encoded><![CDATA[<div>Big thank you &#8211; goes to <a href="http://www.maxtblog.com/" target="_blank">Max Trinidad</a> my fellow MVP from Powershell group&#8230;</div>
<div>Here is errorless script - much better than mine! <img src='http://luka.manojlovic.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </div>
<div>Copa, paste and save as .ps1 - then run on your Hyper-V server and you will get IP&#8217;s of your virtual machines&#8230;</div>
<div>
<p>Set-ExecutionPolicy -ExecutionPolicy RemoteSigned</p>
<p>## &#8211; Use Line below to list all your Virtualization Class<br />
#get-wmiobject -namespace &#8220;root/virtualization&#8221; -list</p>
<p>## &#8211; Load filter (or function first)<br />
filter Import-CimXml{</p>
<p>    $CimXml = [Xml]$_<br />
    $CimObj = New-Object -TypeName System.Object<br />
   <br />
    foreach ($CimProperty in $CimXml.SelectNodes(&#8220;/INSTANCE/PROPERTY&#8221;)){<br />
        if ($CimProperty.Name -eq &#8220;Name&#8221; -or $CimProperty.Name -eq &#8220;Data&#8221;){<br />
            $CimObj | Add-Member -MemberType NoteProperty -Name $CimProperty.NAME -Value $CimProperty.VALUE<br />
        }<br />
    }<br />
   <br />
    $CimObj<br />
}</p>
<p>## &#8211; Collect WMI Virtual information<br />
$getWmiVirtual = Get-WmiObject -Namespace &#8220;root\virtualization&#8221; -Query &#8220;Select * From Msvm_ComputerSystem&#8221; | sort-object elementname</p>
<p>## &#8211; Build your results from your collected objects<br />
ForEach($v in $getWmiVirtual){<br />
    $vm = $v.ElementName;<br />
    $VmObj = Get-WmiObject -Namespace &#8220;root\virtualization&#8221; -Query &#8220;Select * From Msvm_ComputerSystem Where ElementName=&#8217;$vm&#8217;&#8221;;<br />
    $KvpObj = Get-WmiObject -Namespace &#8220;root\virtualization&#8221; -Query &#8220;Associators of {$VmObj} Where AssocClass=Msvm_SystemDevice ResultClass=Msvm_KvpExchangeComponent&#8221;;<br />
    if($KvpObj.GuestIntrinsicExchangeItems -ne $null){<br />
        write-host $vm;<br />
        $KvpObj.GuestIntrinsicExchangeItems | Import-CimXml | where {$_.NAME -match &#8220;NetworkAddressIPv4&#8243;} | ft;<br />
    }<br />
}</p>
<p>## &#8211; End of Script</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://luka.manojlovic.net/2011/03/16/get-ip-address-of-virtual-machines-running-on-hyper-v-fixed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Get IP address of virtual machines running on Hyper-V</title>
		<link>http://luka.manojlovic.net/2011/02/20/get-ip-address-of-virtual-machines-running-on-hyper-v/</link>
		<comments>http://luka.manojlovic.net/2011/02/20/get-ip-address-of-virtual-machines-running-on-hyper-v/#comments</comments>
		<pubDate>Sun, 20 Feb 2011 15:33:01 +0000</pubDate>
		<dc:creator>manojlovicl</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Windows server 2008 R2]]></category>
		<category><![CDATA[get ip hyper-v]]></category>
		<category><![CDATA[hyper-v ip]]></category>
		<category><![CDATA[powershell get ip]]></category>
		<category><![CDATA[virtual machines get ip]]></category>
		<category><![CDATA[virtual machines ip]]></category>

		<guid isPermaLink="false">http://luka.manojlovic.net/?p=298</guid>
		<description><![CDATA[I have been searching for an easy solution to somehow &#8220;scan&#8221; virtual machines and get their IP addresses becouse sometimes you need to find your virtual machines and it is more practical to somehow get a whole list of machines + IPs in stead of loging in from machne to machine and check IP&#8230; Well [...]]]></description>
			<content:encoded><![CDATA[<p>I have been searching for an easy solution to somehow &#8220;scan&#8221; virtual machines and get their IP addresses becouse sometimes you need to find your virtual machines and it is more practical to somehow get a whole list of machines + IPs in stead of loging in from machne to machine and check IP&#8230; Well it can be done using Powershell&#8230; I have encountered an <a href="http://blogs.technet.com/b/m2/archive/2010/07/29/how-to-get-the-ip-address-of-a-virtual-machine-from-hyper-v.aspx" target="_blank">article</a> but the problem is that here you need to put machine name on which you want to get data&#8230; I modified this script a bit so it looks like:</p>
<p>Get-WmiObject -Namespace root\virtualization -Query &#8220;Select * From Msvm_ComputerSystem&#8221;| sort-object elementname | ForEach-Object {$vm = $_.Elementname<br />
write-host $vm<br />
filter Import-CimXml<br />
{<br />
    $CimXml = [Xml]$_<br />
    $CimObj = New-Object -TypeName System.Object<br />
    foreach ($CimProperty in $CimXml.SelectNodes(&#8220;/INSTANCE/PROPERTY&#8221;))<br />
    {<br />
if ($CimProperty.Name -eq &#8220;Name&#8221; -or $CimProperty.Name -eq &#8220;Data&#8221;)<br />
{</p>
<p>         $CimObj | Add-Member -MemberType NoteProperty -Name $CimProperty.NAME -Value $CimProperty.VALUE</p>
<p>}<br />
    }<br />
    $CimObj<br />
}<br />
$VmObj = Get-WmiObject -Namespace root\virtualization -Query &#8220;Select * From Msvm_ComputerSystem Where ElementName=&#8217;$vm&#8217;&#8221;<br />
$KvpObj = Get-WmiObject -Namespace root\virtualization -Query &#8220;Associators of {$VmObj} Where AssocClass=Msvm_SystemDevice ResultClass=Msvm_KvpExchangeComponent&#8221;<br />
$KvpObj.GuestIntrinsicExchangeItems | Import-CimXml<br />
} | where {$_.NAME -match &#8220;NetworkAddressIPv4&#8243;} | ft<br />
read-host</p>
<p>So&#8230; Copy paste this script to an text file and save it as getip.ps1 and run it using powershell &#8211; it does need any other modules you should only run it on Windows Server where you have Hyper-V role installed&#8230; (I do not remember but I think you should enable execution policy for ps1 scripts&#8230; If you have truble executing your ps1 check <a href="http://technet.microsoft.com/en-us/library/ee176961.aspx" target="_blank">here</a>&#8230;)</p>
<p>By the way&#8230; This script has an error first virtual machine name will not fit in table (I do not know why <img src='http://luka.manojlovic.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) and you will get an error when this script will try to analyze your Hyper-V host machine&#8230; I do not know how to solve this two errors if someone out there solves it please provide feedback. <img src='http://luka.manojlovic.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Thank you!</p>
]]></content:encoded>
			<wfw:commentRss>http://luka.manojlovic.net/2011/02/20/get-ip-address-of-virtual-machines-running-on-hyper-v/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SBS 2011 &#8211; Import PST in Exhange 2011</title>
		<link>http://luka.manojlovic.net/2011/01/11/sbs-2011-import-pst-in-exhange-2011/</link>
		<comments>http://luka.manojlovic.net/2011/01/11/sbs-2011-import-pst-in-exhange-2011/#comments</comments>
		<pubDate>Tue, 11 Jan 2011 22:56:02 +0000</pubDate>
		<dc:creator>manojlovicl</dc:creator>
				<category><![CDATA[MS Exchange server 2010]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SBS 2011]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://luka.manojlovic.net/?p=292</guid>
		<description><![CDATA[To enable import and export of mailboxes on SBS 2011 you need to: Go to Windows SBS console and create a security group &#8211; that shuld be universal (by default) for example: Mailbox management Add administrator / admin account to the group Then you need to enable &#8220;import / export&#8221; feature on members of this [...]]]></description>
			<content:encoded><![CDATA[<p>To enable import and export of mailboxes on SBS 2011 you need to:</p>
<p>Go to Windows SBS console and create a <strong>security group</strong> &#8211; that shuld be universal (by default) for example: Mailbox management</p>
<p><strong>Add administrator / admin</strong> account to the <strong>group</strong></p>
<p>Then you need to <strong>enable &#8220;import / export&#8221; feature</strong> on members of this<strong> group</strong>. To do that you need to open <strong>Exchange Management Shell</strong> (Powershell with Exchange 2010 modules) as administrator and write:</p>
<p><strong>New-ManagementRoleAssignment -Name &#8220;Import Export Mailbox Admins&#8221; -SecurityGroup &#8220;Mailbox management&#8221; -Role &#8220;Mailbox Import Export&#8221;</strong></p>
<p>After that you can folow my article to <a href="http://luka.manojlovic.net/2010/12/22/happy-migration-exchange-2003-to-exchange-2010-sp1/" target="_blank">import or export mailboxes</a>&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://luka.manojlovic.net/2011/01/11/sbs-2011-import-pst-in-exhange-2011/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Happy migration :) Exchange 2003 to Exchange 2010 SP1</title>
		<link>http://luka.manojlovic.net/2010/12/22/happy-migration-exchange-2003-to-exchange-2010-sp1/</link>
		<comments>http://luka.manojlovic.net/2010/12/22/happy-migration-exchange-2003-to-exchange-2010-sp1/#comments</comments>
		<pubDate>Wed, 22 Dec 2010 12:23:13 +0000</pubDate>
		<dc:creator>manojlovicl</dc:creator>
				<category><![CDATA[MS Exchange server 2010]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://luka.manojlovic.net/?p=288</guid>
		<description><![CDATA[We have setup a completely new environment with Exchange 2010 SP1&#8230; Old Exchange 2003 had around 100 mailboxes with quota from 300 MB - 1GB. I used Exmerge to export all mailboxes from Exchange 2003 (using ExMerge to extract PSTs from Exchange 2003 database) and sucessfuly used new Powershell cmdlets to import them to users in Exchange 2010&#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>We have setup a completely new environment with Exchange 2010 SP1&#8230; Old Exchange 2003 had around 100 mailboxes with quota from 300 MB - 1GB. I used Exmerge to export all mailboxes from Exchange 2003 (using <a href="http://www.microsoft.com/downloads/en/details.aspx?familyid=429163ec-dcdf-47dc-96da-1c12d67327d5" target="_blank">ExMerge</a> to extract PSTs from Exchange 2003 database) and sucessfuly used new Powershell cmdlets to import them to users in Exchange 2010&#8230;</p>
<p>You first need to add permissions to a group in which you put administrator to be able to use import / export features. You can read about that in <a href="http://www.msexchange.org/articles_tutorials/exchange-server-2010/management-administration/look-import-export-mailbox-improvements-exchange-2010-service-pack-1-part1.html" target="_blank">this article</a>.</p>
<p>Useful comdlets are:</p>
<p>Importing pst to existing mailbox:</p>
<p><strong>New-MailboxImportRequest -FilePath </strong><a href="file://\\oldserver\share\user1.pst"><strong>\\oldserver\share\user1.pst</strong></a><strong> -Mailbox user1</strong></p>
<p>To check status of your import type:</p>
<p><strong>Get-MailboxImportRequest | Get-MailboxImportRequestStatistics</strong></p>
<p>If import fails you can try with option:</p>
<p><strong>New-MailboxImportRequest -FilePath </strong><a href="file://oldserver/share/user1.pst"><strong>\\oldserver\share\user1.pst</strong></a><strong> -Mailbox user1 -BadItemLimit 10</strong></p>
<p>What it does? <a href="http://exchange.si/" target="_blank">Saso</a> (tnx man!) explained to me, that it might happen when you have used some antivirus solution that has &#8220;corrupted&#8221; some e-mails&#8230; So try with BadItemLimit 10 probably we are talking about one or two e-mails with problems.</p>
<p>If you want to remove old importrequest you can use:</p>
<p><strong>Remove-MailboxImportRequest -Identity username\MailboxImport or MailboxImport1 or 2&#8230;</strong>If you want to look at just a signle mailbox import progress you can use modified cmdlet:</p>
<p><strong>Get-MailboxImportRequest -Identity username\mailboximport | Get-MailboxImportRequestStatistics</strong></p>
<p>At the end you will have alot of Completed malilboximport&#8217;s&#8230; If you want to cleane up your exchange you can run:</p>
<p><strong>Get-MailboxImportRequest -Status Completed | Remove-MailboxImportRequest</strong></p>
<p>Happy importing! <img src='http://luka.manojlovic.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://luka.manojlovic.net/2010/12/22/happy-migration-exchange-2003-to-exchange-2010-sp1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SBS 2008 / Exchange 2007 remote.company.com and TLS&#8230;</title>
		<link>http://luka.manojlovic.net/2010/09/05/sbs-2008-exchange-2007-remote-company-com-and-tls/</link>
		<comments>http://luka.manojlovic.net/2010/09/05/sbs-2008-exchange-2007-remote-company-com-and-tls/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 12:18:02 +0000</pubDate>
		<dc:creator>manojlovicl</dc:creator>
				<category><![CDATA[MS Exchange server 2007]]></category>
		<category><![CDATA[MS Scripting]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SBS 2008]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://luka.manojlovic.net/?p=250</guid>
		<description><![CDATA[Everyone that has ever installed SBS 2008 has encountered the wizard that create certificate and remote workplace &#8211; by default called remote.company.com (yes, you can chose other prefixes but let say that I like remote becouse it is easy to remember for my users&#8230;).SBS wizards generates a certificate for this hostname and uses it for [...]]]></description>
			<content:encoded><![CDATA[<p>Everyone that has ever installed SBS 2008 has encountered the wizard that create certificate and remote workplace &#8211; by default called <strong>remote.company.com</strong> (yes, you can chose other prefixes but let say that I like remote becouse it is easy to remember for my users&#8230;).<br />SBS wizards generates a certificate for this hostname and uses it for all services (Outlook web access, Active Sync stuff and also for SMTP receive and send connectors&#8230;).<br />The problem is when you want to rename your SMTP receive and send connectors to match the records in DNS. It is a best practice to have same SMTP greetings as the records in DNS so for example if you have a domain <strong>company.com</strong> and you have an host record <strong>A</strong> called <strong>mail.company.com</strong> and <strong>MX</strong> record pointed to <strong>mail.company.com</strong> it is correct and I suggest you to folow this rule to have <strong>SMTP greeting</strong> or fqdn for SMTP connectors to match<strong> mail.company.com.</strong></p>
<p>You can rename your connectors however you want by using Exchange management console but you will lose functionality of <strong>TLS </strong>in SMTP traffic &#8211; becouse the certificate <strong>remote.company.com</strong> does not match fqdn or smtp greeting of a connector that advertise <strong>mail.company.com. </strong>You will also get an error in Event log saying:</p>
<p>Microsoft Exchange could not find a certificate that contains the domain name mail.company.com in the personal store on the local computer&#8230;</p>
<p> Ok, what can we do now?</p>
<p>Well turn on Exchange Management Shell &#8211; that is Powershell with modules for Exchange 2007 management &#8211; you can find it in star menu&#8230; And first of all we want to see current Exchange certificates that are enabled for Exchange services by using cmdlet:</p>
<p>[PS] C:\Windows\System32&gt;<strong>Get-ExchangeCertificate </strong></p>
<p>and you wil receive something like this:</p>
<div>Thumbprint                                Services   Subject<br />&#8212;&#8212;&#8212;-                                &#8212;&#8212;&#8211;   &#8212;&#8212;-<br />45EEEB44DF4BFE2EB1B7A7592EA1DF5BF93F44B4  IP.WS      CN=<strong>remote.company.com<br /></strong>42F146B12BEF918A6A8FC730F5AA87AC4ACB1CEB  IP..S      CN=<strong>remote.company.com</strong><br />817F1311CB72FB70F962EC0FAD2D8FA857F114A4  &#8230;.S      CN=sbssrv01.company.local<br />4BAAC7906689AFF0129767CF492AAE058B5DF494  &#8230;.S      CN=Sites<br />8F1D9C5FEB6EF0C39F25175AFBDEA54FE9668EF9  &#8230;..      CN=xxxxxx-xxxxxxxx-CA<br />8E4F33523325500F38ECF41FCDFBBE684AFC6145  &#8230;..      CN=WMSvc-WIN-K7KGUV5MQ40</div>
<div> </div>
<div>Now we should create a new certificate that we will use for SMTP connectors by using cmdlet:</div>
<div> </div>
<div><strong>New-ExchangeCertificate -domainname mail.company.com -PrivateKeyExportable:1</strong></div>
<div> </div>
<div><strong>Warning!</strong> When you are asked if you want to overwrite certificates chose <strong>No!</strong></div>
<div><strong> </strong> </div>
<div>
<div>Confirm<br />Overwrite existing default SMTP certificate,<br />&#8217;45EEEB44DF4BFE2EB1B7A7592EA1DF5BF93F44B4&#8242; (expires 14.1.2012 22:37:04), with<br />certificate &#8217;59D62E7850EE4093AFF1EC73E2623D52058C2B35&#8242; (expires 27.1.2015<br />17:09:02)?<br />[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help<br />(default is &#8220;Y&#8221;): <strong>N</strong></div>
<div> </div>
<div>so we get output:</div>
<div>Thumbprint                                Services   Subject<br />&#8212;&#8212;&#8212;-                                &#8212;&#8212;&#8211;   &#8212;&#8212;-<br />59D62E7850EE4093AFF1EC73E2623D52058C2B35  &#8230;..      CN=<strong>mail.company.com</strong></div>
<div> </div>
<div>Great!  If we want to be shure that everything is working correctly and that Exchange SMTP service is using our new certificate we can use cmdlet:</div>
</div>
<div>
<p>[PS] C:\Windows\System32&gt;<strong>Get-ExchangeCertificate </strong></p>
<p>[PS] C:\Windows\System32&gt;</p>
<div>Thumbprint                                Services   Subject<br />&#8212;&#8212;&#8212;-                                &#8212;&#8212;&#8211;   &#8212;&#8212;-<br />59D62E7850EE4093AFF1EC73E2623D52058C2B35  &#8230;.<strong>S</strong>      CN=<strong>mail.company.com</strong><br />45EEEB44DF4BFE2EB1B7A7592EA1DF5BF93F44B4  IP.W<strong>S</strong>      CN=<strong>remote.company.com</strong></div>
<div>42F146B12BEF918A6A8FC730F5AA87AC4ACB1CEB  IP..<strong>S</strong>      CN=<strong>remote.company.com</strong></div>
<div>817F1311CB72FB70F962EC0FAD2D8FA857F114A4  &#8230;.S      CN=sbssrv01.company.local<br />4BAAC7906689AFF0129767CF492AAE058B5DF494  &#8230;.S      CN=Sites<br />8F1D9C5FEB6EF0C39F25175AFBDEA54FE9668EF9  &#8230;..      CN=xxxxxxxxxxx-xxxxxxxxxxxx01-CA<br />8E4F33523325500F38ECF41FCDFBBE684AFC6145  &#8230;..      CN=WMSvc-WIN-K7KGUV5MQ40</div>
<div>We can now see that SMTP connectors are using all certificates (S defnies SMTP service).</div>
<div>Ok&#8230; How can you test that TLS works?</div>
<div>You can try it by using telnet client and connect to your server:</div>
<div><strong>telnet mail.company.com 25</strong></div>
<div>
<div> </div>
<div>Exchange should respond something like:</div>
<div>220 <strong>mail.company.com</strong> Microsoft ESMTP MAIL Service ready at Wed, 27 Jan 2010 17:<br />12:09 +0100</div>
<div> </div>
<div>then you can write:</div>
<div><strong>helo test.blablabla.com</strong></div>
<div> </div>
<div>220 <strong>mail.company.com</strong> Microsoft ESMTP MAIL Service ready at Wed, 27 Jan 2010 17:<br />13:07 +0100<br />helo test.blablabla.si<br />250 <strong>mail.xxxxxxxxxxxxxxxx.si</strong> Hello [xxx.xxx.xxxx.xxx]</div>
<div>after that enter command:</div>
<div><strong>starttls</strong></div>
<p><strong> </strong></p>
</div>
<div>server should respond:
<div>220 2.0.0 SMTP server ready</div>
<div> </div>
<div>Server ready? Super! <img src='http://luka.manojlovic.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </div>
<div> </div>
<div>PS.</div>
<div>If you did miss something you will receive error from server saying:</div>
<div> </div>
<div>starttls<br />500 5.3.3 Unrecognized command</div>
<div> </div>
<div>If you get that? Read this tutorial again <img src='http://luka.manojlovic.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </div>
<div>PS. PS. You do not need to restart anything when you apply this commands&#8230; No need for restarting Exchange services&#8230;</div>
<div>Special thanks to <a href="http://blog.mreza.info/" target="_blank">Saso Erdeljanov</a> for some hints about this issue&#8230;</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://luka.manojlovic.net/2010/09/05/sbs-2008-exchange-2007-remote-company-com-and-tls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell with task scheduler… This is the way to automate your IT! – remote machine – p2</title>
		<link>http://luka.manojlovic.net/2010/08/10/powershell-with-task-scheduler%e2%80%a6-this-is-the-way-to-automate-your-it-%e2%80%93-remote-machine-%e2%80%93-p2/</link>
		<comments>http://luka.manojlovic.net/2010/08/10/powershell-with-task-scheduler%e2%80%a6-this-is-the-way-to-automate-your-it-%e2%80%93-remote-machine-%e2%80%93-p2/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 07:54:08 +0000</pubDate>
		<dc:creator>manojlovicl</dc:creator>
				<category><![CDATA[MS Scripting]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://luka.manojlovic.net/?p=247</guid>
		<description><![CDATA[Ok! Welcome to part two&#8230; What is the idea behind this second part&#8230; Well with Powershell 2.0 we have now Powershell remoting that allow us to run commands on remote machines&#8230; When we are thinking about automating tasks we would like to execute some powershell scripts on servers or machines around our company. Ok in [...]]]></description>
			<content:encoded><![CDATA[<p>Ok! Welcome to part two&#8230; What is the idea behind this second part&#8230; Well with Powershell 2.0 we have now Powershell remoting that allow us to run commands on remote machines&#8230; When we are thinking about automating tasks we would like to execute some powershell scripts on servers or machines around our company.</p>
<p>Ok in example 2 we have two servers:<br /><strong>DEMOAD.demo.local</strong> &#8211; active directory server<br />and<br /><strong>DEMORDSSRV01.demo.local</strong> &#8211; member server (in fact remote desktop server but it is not an important info&#8230; <img src='http://luka.manojlovic.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )</p>
<p>Let say that we will be connected to <strong>DEMOAD.demo.local</strong> and we will prepare a script and schedule it to get information from <strong>DEMORDSSRV01.demo.local</strong></p>
<p>1. First we need to enable Powershell remoting on DEMORDSSRV01.demo.local using Powershell cmdlet:</p>
<p><strong>Enable-PSRemoting<br /></strong><br />2. We need to test if remoting works so we can test it by using cmdlet:</p>
<p><strong>Test-WSMan -ComputerName DEMORDSSRV01</strong> </p>
<p>this cmdlet should be run on DEMOAD machine. If  everything is ok you should receive something like:</p>
<p>wsmid : <a href="http://schemas.dmtf">http://schemas.dmtf</a>&#8230;<br />ProtocolVersion: <a href="http://schemas">http://schemas</a>&#8230;<br />ProductVendor: Microsoft Corporation<br />ProductVersion: OS: 0.0.0 SP: 0.0 Stack: 2.0</p>
<p>If you did not enable remoting on DEMORDSSRV01.demo.local you will receive:</p>
<p>Test-WSMan : The WinRM client cannot complete the operation&#8230;</p>
<p>If you receive this error try to reenable Powershell Remoting by using cmdlet: <strong>Enable-PSRemoting</strong></p>
<p>3. Create a powershell script (a txt file that has extension .ps1) for example <strong>remoteprocess.ps1 </strong>edit it with your notepad and write inside the cmdlet:<br /><strong>get-process -computername demordssrv01 | out-file c:\remoteprocess.txt</strong></p>
<p>this script will<strong> request process list</strong> from <strong>demordssrv01</strong> and the result will be<strong> pipelined</strong> to txt file called<strong> c:\remoteprocess.txt</strong> on <strong>demoad.demo.local</strong> &#8211; so from machine that will execute the query.</p>
<p>4. When you are done with script you just need to create a Basic Task in Task Scheduler. You can check my prevous article (<a href="http://luka.manojlovic.net/2010/06/17/powershell-with-task-scheduler-this-is-the-way-to-automate-your-it/" target="_blank">part1</a>) to see other steps to do that.</p>
]]></content:encoded>
			<wfw:commentRss>http://luka.manojlovic.net/2010/08/10/powershell-with-task-scheduler%e2%80%a6-this-is-the-way-to-automate-your-it-%e2%80%93-remote-machine-%e2%80%93-p2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell with task scheduler&#8230; This is the way to automate your IT! &#8211; single machine &#8211; p1</title>
		<link>http://luka.manojlovic.net/2010/06/17/powershell-with-task-scheduler-this-is-the-way-to-automate-your-it/</link>
		<comments>http://luka.manojlovic.net/2010/06/17/powershell-with-task-scheduler-this-is-the-way-to-automate-your-it/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 10:57:41 +0000</pubDate>
		<dc:creator>manojlovicl</dc:creator>
				<category><![CDATA[MS Scripting]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://luka.manojlovic.net/?p=240</guid>
		<description><![CDATA[Well using Powershell interactively is something that we see all the time when Microsoft want to show us what and how we can automate our daily taks&#8230; But administrators want to know how can we schedule our brand new fantastic powershell scripts&#8230; Ok, this guide will tell you how to do it&#8230; How to run separate [...]]]></description>
			<content:encoded><![CDATA[<p>Well using Powershell interactively is something that we see all the time when Microsoft want to show us what and how we can automate our daily taks&#8230; But administrators want to know how can we schedule our brand new fantastic powershell scripts&#8230;</p>
<p>Ok, this guide will tell you how to do it&#8230; How to run separate commands from powershell and how to run a complete scripts so you can realy start to automate your stuff by using Powershell&#8230;</p>
<p><strong>Example: </strong>I would like to schedule script that lists all processes running on a specific server<br />1. on my server I will first create a txt file (extension should be renamed to ps1 &#8211; as we are writing powershell script) called <strong>listproces.ps1<br /></strong>2. into the file I will put my scipt:</p>
<p>get-process | out-file c:\processes.txt</p>
<p>3. start task scheduler on server and <strong>Create Basic Task<br /></strong>Name: Powershell list processes<br />Triger: Chose when you want your script to run<br />Action: Start a program<br />Program / script: <strong>powershell.exe<br /></strong>Add arguments: <strong>-ExecutionPolicy RemoteSigned –Noninteractive –Noprofile –File C:\<strong>listproces.ps1</strong></strong></p>
<p><strong>Important! You should set your task to run whether user is logged into a session or not&#8230; To do that do the folowing:</strong></p>
<p><strong><a href="http://luka.manojlovic.net/wp-content/uploads/2010/11/PowershellTask1.png"><img class="alignnone size-full wp-image-243" title="PowershellTask1" src="http://luka.manojlovic.net/wp-content/uploads/2010/11/PowershellTask1.png" alt="" width="633" height="473" /></a><br /></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://luka.manojlovic.net/2010/06/17/powershell-with-task-scheduler-this-is-the-way-to-automate-your-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hyper-V FreeBSD shutdown problem workaround</title>
		<link>http://luka.manojlovic.net/2008/07/18/hyper-v-freebsd-shutdown-problem-workaround/</link>
		<comments>http://luka.manojlovic.net/2008/07/18/hyper-v-freebsd-shutdown-problem-workaround/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 17:09:39 +0000</pubDate>
		<dc:creator>manojlovicl</dc:creator>
				<category><![CDATA[MS Windows server]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Windows server 2008]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[Hyper-V]]></category>
		<category><![CDATA[Shutdown problem]]></category>

		<guid isPermaLink="false">http://luka.manojlovic.net/2008/07/18/hyper-v-freebsd-shutdown-problem-workaround/</guid>
		<description><![CDATA[Thanks to Mike &#8230;  Mike wrote:  &#8220;I&#8217;ve found an even easier way to do this.  I found a PowerShell Hyper-V script at: http://www.codeplex.com/PSHyperv It has a lot of functions already, and I added a &#8220;Kill-VM&#8221; function that automates the kill process: Kill-VM &#60;VM name&#62; My modified script is attached to this message. To use it, you [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to Mike &#8230; </p>
<p>Mike wrote: </p>
<p>&#8220;I&#8217;ve found an even easier way to do this.  I found a PowerShell Hyper-V script at:</p>
<p><a href="http://www.codeplex.com/PSHyperv">http://www.codeplex.com/PSHyperv</a></p>
<p>It has a lot of functions already, and I added a &#8220;Kill-VM&#8221; function that automates the kill process:</p>
<p>Kill-VM &lt;VM name&gt;</p>
<p>My modified script is attached to this message.</p>
<p>To use it, you need to install PowerShell (Under Server Manager -&gt; Features in Win2008).  Once installed, run PowerShell from Start -&gt; Search, find the script, and type:</p>
<p>. .\hyperv.ps1</p>
<p>Once loaded into memory, type:</p>
<p>Kill-VM &lt;VM Name&gt;</p>
<p>Enjoy&#8221;</p>
<p><a href="http://store.manojlovic.net/utility/Hyper-VPS/hyperv-script.zip">Click here to download script &#8211; hyperv-script.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://luka.manojlovic.net/2008/07/18/hyper-v-freebsd-shutdown-problem-workaround/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Portable Powershell even on Windows server 2008 core &#8211; it is possible!</title>
		<link>http://luka.manojlovic.net/2008/06/18/portable-powershell-even-on-windows-server-2008-core-it-is-possible/</link>
		<comments>http://luka.manojlovic.net/2008/06/18/portable-powershell-even-on-windows-server-2008-core-it-is-possible/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 22:01:52 +0000</pubDate>
		<dc:creator>manojlovicl</dc:creator>
				<category><![CDATA[MS Scripting]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Windows server 2008]]></category>

		<guid isPermaLink="false">http://luka.manojlovic.net/2008/06/18/portable-powershell-even-on-windows-server-2008-core-it-is-possible/</guid>
		<description><![CDATA[Look at: http://karlprosser.com/coder/2008/06/17/portable-powershell-v1-and-v2-side-by-side-even-on-server-core/  Great stuff!!!]]></description>
			<content:encoded><![CDATA[<p>Look at: <a href="http://karlprosser.com/coder/2008/06/17/portable-powershell-v1-and-v2-side-by-side-even-on-server-core/">http://karlprosser.com/coder/2008/06/17/portable-powershell-v1-and-v2-side-by-side-even-on-server-core/</a></p>
<p> Great stuff!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://luka.manojlovic.net/2008/06/18/portable-powershell-even-on-windows-server-2008-core-it-is-possible/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mailbox statistics using Powershell in Exchange 2007</title>
		<link>http://luka.manojlovic.net/2008/01/12/mailbox-statistics-using-powershell-in-exchange-2007/</link>
		<comments>http://luka.manojlovic.net/2008/01/12/mailbox-statistics-using-powershell-in-exchange-2007/#comments</comments>
		<pubDate>Sat, 12 Jan 2008 15:01:37 +0000</pubDate>
		<dc:creator>manojlovicl</dc:creator>
				<category><![CDATA[MS Exchange server]]></category>
		<category><![CDATA[MS Exchange server 2007]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://luka.manojlovic.net/2008/01/12/mailbox-statistics-using-powershell-in-exchange-2007/</guid>
		<description><![CDATA[1. Sorted by Displayname (Display name, Mailbox size (MB), Item count, Last logon time, Last logoff time, Last loggedon user account) Get-MailboxStatistics -Database &#8220;mailbox database&#8221; &#124; Sort -Property DisplayName &#124; ft DisplayName,@{expression={$_.totalitemsize.value.ToMB()};label=&#8221;Mailbox Size(MB)&#8221;}, itemcount, lastlogontime,lastlogofftime,lastloggedonuseraccount 2. Sorted by Last logon time Get-MailboxStatistics -Database &#8220;mailbox database&#8221; &#124; Sort -Property lastlogontime &#124; ft DisplayName,@{expression={$_.totalitemsize.value.ToMB()};label=&#8221;Mailbox Size(MB)&#8221;}, itemcount, lastlogontime, [...]]]></description>
			<content:encoded><![CDATA[<p align="left">1. Sorted by Displayname (Display name, Mailbox size (MB), Item count, Last logon time, Last logoff time, Last loggedon user account)</p>
<p align="left">Get-MailboxStatistics -Database &#8220;mailbox database&#8221; | Sort -Property DisplayName | ft DisplayName,@{expression={$_.totalitemsize.value.ToMB()};label=&#8221;Mailbox Size(MB)&#8221;}, itemcount, lastlogontime,lastlogofftime,lastloggedonuseraccount</p>
<p align="left">2. Sorted by Last logon time<br />
Get-MailboxStatistics -Database &#8220;mailbox database&#8221; | Sort -Property lastlogontime | ft DisplayName,@{expression={$_.totalitemsize.value.ToMB()};label=&#8221;Mailbox Size(MB)&#8221;}, itemcount, lastlogontime, lastlogofftime</p>
]]></content:encoded>
			<wfw:commentRss>http://luka.manojlovic.net/2008/01/12/mailbox-statistics-using-powershell-in-exchange-2007/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

