<?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>Kreslavsky IT blog &#187; Scripts</title>
	<atom:link href="http://www.kreslavsky.com/category/scripts/feed" rel="self" type="application/rss+xml" />
	<link>http://www.kreslavsky.com</link>
	<description>News, guides, and tips to antivirus programmes, scripts, and security</description>
	<lastBuildDate>Sun, 29 Jan 2012 04:57: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>Deploy wireless settings with Key using netsh script and GPO</title>
		<link>http://www.kreslavsky.com/2011/05/deploy-wireless-settings-with-key-using-netsh-script-and-gpo.html</link>
		<comments>http://www.kreslavsky.com/2011/05/deploy-wireless-settings-with-key-using-netsh-script-and-gpo.html#comments</comments>
		<pubDate>Tue, 03 May 2011 08:36:13 +0000</pubDate>
		<dc:creator>Gil Kreslavsky</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[GPO]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Certificates]]></category>
		<category><![CDATA[Command Prompt]]></category>
		<category><![CDATA[Deploy]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Export Profile]]></category>
		<category><![CDATA[Folder C]]></category>
		<category><![CDATA[Gpo]]></category>
		<category><![CDATA[Interface]]></category>
		<category><![CDATA[Lan Settings]]></category>
		<category><![CDATA[Lt]]></category>
		<category><![CDATA[netsh]]></category>
		<category><![CDATA[Profile Name]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Shared Key]]></category>
		<category><![CDATA[Wireless]]></category>
		<category><![CDATA[Wireless Lan]]></category>
		<category><![CDATA[Wireless Management]]></category>
		<category><![CDATA[Wireless Profile]]></category>
		<category><![CDATA[Wlan]]></category>
		<category><![CDATA[Workstation]]></category>
		<category><![CDATA[Yourkey]]></category>

		<guid isPermaLink="false">http://www.kreslavsky.com/2011/05/deploy-wireless-settings-with-key-using-netsh-script-and-gpo.html</guid>
		<description><![CDATA[Tweet &#160; Windows 2008 has built in policy GPO for wireless setting management. You can configure your network setting using Certificates. It is the most recommended and secure way But if you like to deploy the wireless settings using static key, you will have to use other way. The steps bellow describe the way to deploy Wireless LAN settings with a Pre-Shared Key The purpose is to Automate Adding Wireless Profile in Windows. Preparations Configure Wireless settings on one workstation from command prompt run netsh wlan export profile name=&#34;NameOfyourProfile&#34; folder=c:temp interface=&#34;wirelesssettings” Confirm that under c:temp you have wirelesssettings.xml file Open wirelesssettings.xml file locate the following line &#60;protected&#62;true&#60;/protected&#62; Change it to &#60;protected&#62;false&#60;/protected&#62; Under you will see encrypted line &#60;keyMaterial&#62;01000000D08C9DDF0115D1118&#60;/keyMaterial&#62; Change it to your key like that &#60;keyMaterial&#62;Yourkey&#60;/keyMaterial&#62; Note: It means that your wireless key will be in clear text and everyone who has access to the file will be able to read your wireless key&#34; Deployment Copy your wireless settings xml file to NETLOGON Create a bat or cmd file with the following line netsh wlan add profile filename=&#34;\yourserverNETLOGONwirelesssettings.xml&#34; user=all Run the bat file from some domain member computer and confirm that it works After finishing all steps above you can deploy the script from GPO Note: Setting are applicable for Windows Vista Windows 7 and Windows 2008 Only]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.kreslavsky.com%2F2011%2F05%2Fdeploy-wireless-settings-with-key-using-netsh-script-and-gpo.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.kreslavsky.com/2011/05/deploy-wireless-settings-with-key-using-netsh-script-and-gpo.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.kreslavsky.com/2011/05/deploy-wireless-settings-with-key-using-netsh-script-and-gpo.html"  data-text="Deploy wireless settings with Key using netsh script and GPO" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.kreslavsky.com/2011/05/deploy-wireless-settings-with-key-using-netsh-script-and-gpo.html" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.kreslavsky.com/2011/05/deploy-wireless-settings-with-key-using-netsh-script-and-gpo.html"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>&#160;</p>
<p>Windows 2008 has built in policy GPO for wireless setting management.    <br />You can configure your network setting using Certificates. It is the most recommended and secure way     <br />But if you like to deploy the wireless settings using static key, you will have to use other way.</p>
<p>The steps bellow describe the way to deploy Wireless LAN settings with a Pre-Shared Key   <br />The purpose is to Automate Adding Wireless Profile in Windows.</p>
<p>Preparations</p>
<ul>
<li>Configure Wireless settings on one workstation </li>
<li>from command prompt run      <br />netsh wlan export profile name=&quot;<em>NameOfyourProfile</em>&quot; folder=<em>c:temp</em> interface=&quot;wirelesssettings” </li>
<li>Confirm that under c:temp you have wirelesssettings.xml file </li>
<li>Open wirelesssettings.xml file locate the following line      <br />&lt;protected&gt;true&lt;/protected&gt; </li>
<li>Change it to &lt;protected&gt;false&lt;/protected&gt; </li>
<li>Under you will see encrypted line &lt;keyMaterial&gt;01000000D08C9DDF0115D1118&lt;/keyMaterial&gt; </li>
<li>Change it to your key like that &lt;keyMaterial&gt;<em>Yourkey&lt;/keyMaterial&gt;</em><br />
<blockquote>
<p>Note: It means that your wireless key will be in clear text and everyone who has access to the file will be able to read your wireless key&quot;</p>
</blockquote>
</li>
</ul>
<p>Deployment</p>
<ul>
<li>Copy your wireless settings xml file to NETLOGON </li>
<li>Create a bat or cmd file with the following line      <br />netsh wlan add profile filename=&quot;\yourserverNETLOGONwirelesssettings.xml&quot; user=all </li>
<li>Run the bat file from some domain member computer and confirm that it works </li>
</ul>
<p>After finishing all steps above you can deploy the script from GPO</p>
<blockquote><p>Note: Setting are applicable for Windows Vista Windows 7 and Windows 2008 Only</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.kreslavsky.com/2011/05/deploy-wireless-settings-with-key-using-netsh-script-and-gpo.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Shut Down Exchange 2010 DAG member</title>
		<link>http://www.kreslavsky.com/2011/04/shut-down-exchange-2010-dag-member.html</link>
		<comments>http://www.kreslavsky.com/2011/04/shut-down-exchange-2010-dag-member.html#comments</comments>
		<pubDate>Thu, 21 Apr 2011 11:12:22 +0000</pubDate>
		<dc:creator>Gil Kreslavsky</dc:creator>
				<category><![CDATA[Exchange 2010]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[C Program]]></category>
		<category><![CDATA[Cluster Group]]></category>
		<category><![CDATA[Company Mail]]></category>
		<category><![CDATA[Dag]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Emc]]></category>
		<category><![CDATA[Functionality]]></category>
		<category><![CDATA[High Availability Solution]]></category>
		<category><![CDATA[Mail Services]]></category>
		<category><![CDATA[Maintenance]]></category>
		<category><![CDATA[Maitainance]]></category>
		<category><![CDATA[Members]]></category>
		<category><![CDATA[Microsoft Exchange Server]]></category>
		<category><![CDATA[Microsoft Server]]></category>
		<category><![CDATA[Node]]></category>
		<category><![CDATA[Pam]]></category>
		<category><![CDATA[PS Script]]></category>
		<category><![CDATA[Shutdown Exchange]]></category>
		<category><![CDATA[Type Cd]]></category>
		<category><![CDATA[Windows Server]]></category>
		<category><![CDATA[Windows Shutdown]]></category>

		<guid isPermaLink="false">http://www.kreslavsky.com/2011/04/shut-down-exchange-2010-dag-member.html</guid>
		<description><![CDATA[Tweet &#160; While performing maintenance to Exchange 2010 DAG server you should first remove the DAG member from DAG group.Other wise you may have unwanted DB failovers and many other unexpected issue that may affect company mail services availability Shutting Down DAG Members The Exchange 2010 high availability solution is integrated with the Windows shutdown process. If an administrator or application initiates a shutdown of a Windows server in a DAG that has a mounted database that&#8217;s replicated to one or more DAG members, the system attempts to activate another copy of the mounted database prior to allowing the shutdown process to complete. However, this new behavior doesn&#8217;t guarantee that all of the databases on the server being shut down will experience a lossless activation. As a result, it&#8217;s a best practice to perform a server switchover prior to shutting down a server that&#8217;s a member of a DAG. The correct way to perform any maintenance is to run first&#160; StartDagServerMaintenance.ps1 script that is located under “C:Program FilesMicrosoftExchange ServerV14scripts” This script moves all the active databases to next preferred DAG server and prevents active databases from moving to that server during the maintenance. In addition the script ensures that all critical DAG support functionality that may be on this server has been moved to next proffered server To run the script open EMC Type: cd $exscripts StartDagServerMaintenance.ps1 -server YourServername The script performs the following tasks on the background: Runs the Suspend-MailboxDatabaseCopy cmdlet for each database copy hosted on the DAG member. Pauses the node in the cluster, which prevents the node from being and becoming the PAM. Sets the value of the DatabaseCopyAutoActivationPolicy parameter on the DAG member to blocked Moves all active databases currently hosted on the DAG member to other DAG members. If the DAG member currently owns the default cluster group, the script moves the default cluster group (and therefore the PAM role) to another DAG member. If any of the preceding tasks fails, all operations, except for successful database moves, are undone. &#160; After the maintenance is complete and the DAG member is ready to return to serve clients you need to run the following script: cd $exscripts StopDagServerMaintenance.ps1 -server YourServername The script performs the following tasks on the background: Runs the Resume-MailboxDatabaseCopy cmdlet for each database copy hosted on the DAG member. Resumes the node in the cluster, which enables full cluster functionality for the DAG member. Sets the value of the DatabaseCopyAutoActivationPolicy parameter on the DAG member to Unrestricted &#160; I highly recommend using&#160; Start/StopDagServerMaintenanceInstalling maintainance scripts before any action that requiers server Reboot/ShutDown or Update Rollups instalation. &#160; Most of the material has been taken from Managing Database Availability Groups MS article]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.kreslavsky.com%2F2011%2F04%2Fshut-down-exchange-2010-dag-member.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.kreslavsky.com/2011/04/shut-down-exchange-2010-dag-member.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.kreslavsky.com/2011/04/shut-down-exchange-2010-dag-member.html"  data-text="Shut Down Exchange 2010 DAG member" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.kreslavsky.com/2011/04/shut-down-exchange-2010-dag-member.html" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.kreslavsky.com/2011/04/shut-down-exchange-2010-dag-member.html"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>&#160;</p>
<p>While performing maintenance to Exchange 2010 DAG server you should first remove the DAG member from DAG group.Other wise you may have unwanted DB failovers and many other unexpected issue that may affect company mail services availability</p>
<p><strong>Shutting Down DAG Members</strong> </p>
<p>The Exchange 2010 high availability solution is integrated with the Windows shutdown process. If an administrator or application initiates a shutdown of a Windows server in a DAG that has a mounted database that&#8217;s replicated to one or more DAG members, the system attempts to activate another copy of the mounted database prior to allowing the shutdown process to complete. </p>
<p>However, this new behavior doesn&#8217;t guarantee that all of the databases on the server being shut down will experience a lossless activation. As a result, it&#8217;s a best practice to perform a server switchover prior to shutting down a server that&#8217;s a member of a DAG.</p>
<p>The correct way to perform any maintenance is to run first&#160; StartDagServerMaintenance.ps1 script that is located under “C:Program FilesMicrosoftExchange ServerV14scripts”   <br />This script moves all the active databases to next preferred DAG server and prevents active databases from moving to that server during the maintenance.     <br />In addition the script ensures that all critical DAG support functionality that may be on this server has been moved to next proffered server</p>
<p>To run the script open EMC   <br />Type:    <br /><em>cd $exscripts     <br />StartDagServerMaintenance.ps1 -server YourServername</em></p>
<p>The script performs the following tasks on the background:</p>
<ul>
<li>Runs the <em>Suspend-MailboxDatabaseCopy</em> cmdlet for each database copy hosted on the DAG member.</li>
<li>Pauses the node in the cluster, which prevents the node from being and becoming the PAM.</li>
<li>Sets the value of the <em>DatabaseCopyAutoActivationPolicy</em> parameter on the DAG member to <strong>blocked</strong></li>
<li>Moves all active databases currently hosted on the DAG member to other DAG members.</li>
<li>If the DAG member currently owns the default cluster group, the script moves the default cluster group (and therefore the PAM role) to another DAG member.</li>
</ul>
<p>If any of the preceding tasks fails, all operations, except for successful database moves, are undone.</p>
<p>&#160;</p>
<p>After the maintenance is complete and the DAG member is ready to return to serve clients you need to run the following script: </p>
<p><em>cd $exscripts     <br />StopDagServerMaintenance.ps1 -server YourServername</em></p>
<p>The script performs the following tasks on the background:</p>
<ul>
<li>Runs the Resume-MailboxDatabaseCopy cmdlet for each database copy hosted on the DAG member.</li>
<li>Resumes the node in the cluster, which enables full cluster functionality for the DAG member.</li>
<li>Sets the value of the <em>DatabaseCopyAutoActivationPolicy</em> parameter on the DAG member to <strong>Unrestricted</strong></li>
</ul>
<p>&#160;</p>
<p><img src="http://i.msdn.microsoft.com/Global/Images/clear.gif" />I highly recommend using&#160; Start/StopDagServerMaintenanceInstalling maintainance scripts before any action that requiers server Reboot/ShutDown or Update Rollups instalation.</p>
<p>&#160;</p>
<p>Most of the material has been taken from Managing <a href="http://technet.microsoft.com/en-us/library/dd298065.aspx" target="_blank">Database Availability Groups MS article</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kreslavsky.com/2011/04/shut-down-exchange-2010-dag-member.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Some Exchange 2010sp1 power shell scripts part1</title>
		<link>http://www.kreslavsky.com/2011/04/some-exchange-2010sp1-power-shell-scripts-part1.html</link>
		<comments>http://www.kreslavsky.com/2011/04/some-exchange-2010sp1-power-shell-scripts-part1.html#comments</comments>
		<pubDate>Thu, 14 Apr 2011 11:23:19 +0000</pubDate>
		<dc:creator>Gil Kreslavsky</dc:creator>
				<category><![CDATA[Exchange 2010]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Alias]]></category>
		<category><![CDATA[Cluster Member]]></category>
		<category><![CDATA[Csv]]></category>
		<category><![CDATA[Dag]]></category>
		<category><![CDATA[Distribution Group]]></category>
		<category><![CDATA[Firewall]]></category>
		<category><![CDATA[Group Owner]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[Mailbox Format]]></category>
		<category><![CDATA[Mailboxes]]></category>
		<category><![CDATA[Move Mailbox]]></category>
		<category><![CDATA[Profiles]]></category>
		<category><![CDATA[Quota Report]]></category>
		<category><![CDATA[Server Exchange]]></category>
		<category><![CDATA[Server Servername]]></category>
		<category><![CDATA[Shell Scripts]]></category>

		<guid isPermaLink="false">http://www.kreslavsky.com/?p=1163</guid>
		<description><![CDATA[Tweet &#160; Get Quota report Get-Mailbox &#124; Format-Table alias, *quota Delete message from Mailbox get-mailbox -resultsize unlimited &#124; search-mailbox -SearchQuery &#8220;Subject:ABDCEV&#8217;&#8221; -DeleteContent Turn Off firewall on all profiles netsh advfirewall set allprofiles firewallpolicy allowinbound,allowoutbound Exchange 2007 &#8211; check DB copy status. Get-StorageGroupCopyStatus -StandbyMachine mtvmail01 Message Tracking log to csv (&#124; Select Sender, Recipients, TimeStamp, MessageSubject) Get-MessageTrackingLog -Server servername-ResultSize Unlimited &#124; Where { $_.Sender -like &#8220;username*&#8221; } &#124; Export-CSV &#8220;c:username.csv&#8221; Put Exchange DAG cluster member to Maintainance cd $exscripts StartDagServerMaintenance.ps1 -server servername Get Exchange DAG cluster member from Mainatainance cd $exscripts StopDagServerMaintenance.ps1 -server servername Set Distribution group owner Set-DistributionGroup groupname -ManagedBy &#8220;User Name&#8221; -BypassSecurityGroupManagerCheck Access rights to all mailboxes in DB or All Get-Mailbox &#124; Add-MailboxPermission -User “Username” -AccessRights FullAccess -InheritanceType All Get-MailboxDatabase –identity “DBNAME” &#124; Add-ADPermission -User “UserName” -AccessRights GenericAll Move Mailbox New-MoveRequest -Identity user@mail.com -TargetDatabase DBNAME -BadItemLimit 100 -AcceptLargeDataLoss Add permition to send as Add-ADpermission -Identity &#8220;DatabaseName&#8221; -user &#8220;username&#8221;  -ExtendedRights Receive-as]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.kreslavsky.com%2F2011%2F04%2Fsome-exchange-2010sp1-power-shell-scripts-part1.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.kreslavsky.com/2011/04/some-exchange-2010sp1-power-shell-scripts-part1.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.kreslavsky.com/2011/04/some-exchange-2010sp1-power-shell-scripts-part1.html"  data-text="Some Exchange 2010sp1 power shell scripts part1" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.kreslavsky.com/2011/04/some-exchange-2010sp1-power-shell-scripts-part1.html" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.kreslavsky.com/2011/04/some-exchange-2010sp1-power-shell-scripts-part1.html"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>&nbsp;</p>
<p><strong>Get Quota report<br />
</strong>Get-Mailbox | Format-Table alias, *quota</p>
<p><strong>Delete message from Mailbox<br />
</strong>get-mailbox -resultsize unlimited | search-mailbox -SearchQuery &#8220;Subject:ABDCEV&#8217;&#8221; -DeleteContent</p>
<p><strong>Turn Off firewall on all profiles<br />
</strong>netsh advfirewall set allprofiles firewallpolicy allowinbound,allowoutbound</p>
<p><strong>Exchange 2007 &#8211; check DB copy status.<br />
</strong>Get-StorageGroupCopyStatus -StandbyMachine mtvmail01</p>
<p><strong>Message Tracking log to csv (| Select Sender, Recipients, TimeStamp, MessageSubject)<br />
</strong>Get-MessageTrackingLog -Server <strong>servername</strong>-ResultSize Unlimited | Where { $_.Sender -like &#8220;username*&#8221; } | Export-CSV &#8220;c:username.csv&#8221;</p>
<p><strong>Put Exchange DAG cluster member to Maintainance<br />
</strong>cd $exscripts<br />
StartDagServerMaintenance.ps1 -server servername</p>
<p><strong>Get Exchange DAG cluster member from Mainatainance</strong></p>
<p>cd $exscripts<br />
StopDagServerMaintenance.ps1 -server servername</p>
<p><strong>Set Distribution group owner<br />
</strong>Set-DistributionGroup groupname -ManagedBy &#8220;User Name&#8221; -BypassSecurityGroupManagerCheck</p>
<p><strong>Access rights to all mailboxes in DB or All<br />
</strong>Get-Mailbox | Add-MailboxPermission -User “Username” -AccessRights FullAccess -InheritanceType All<br />
Get-MailboxDatabase –identity “DBNAME” | Add-ADPermission -User “UserName” -AccessRights GenericAll</p>
<p><strong>Move Mailbox<br />
</strong>New-MoveRequest -Identity user@mail.com -TargetDatabase DBNAME -BadItemLimit 100 -AcceptLargeDataLoss</p>
<p><strong>Add permition to send as<br />
</strong>Add-ADpermission -Identity &#8220;DatabaseName&#8221; -user &#8220;username&#8221;  -ExtendedRights Receive-as</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kreslavsky.com/2011/04/some-exchange-2010sp1-power-shell-scripts-part1.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Send Email Powershell script</title>
		<link>http://www.kreslavsky.com/2010/11/send-email-powershell-script.html</link>
		<comments>http://www.kreslavsky.com/2010/11/send-email-powershell-script.html#comments</comments>
		<pubDate>Thu, 25 Nov 2010 12:36:00 +0000</pubDate>
		<dc:creator>Gil Kreslavsky</dc:creator>
				<category><![CDATA[Exchange 2007]]></category>
		<category><![CDATA[Exchange 2010]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Server 2008]]></category>
		<category><![CDATA[Att]]></category>
		<category><![CDATA[Attachments]]></category>
		<category><![CDATA[C Program]]></category>
		<category><![CDATA[Exe]]></category>
		<category><![CDATA[Mail Attachment]]></category>
		<category><![CDATA[Mailmessage]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Microsoft Exchange Server]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[PS Script]]></category>
		<category><![CDATA[Ps1]]></category>
		<category><![CDATA[Quot]]></category>
		<category><![CDATA[Recipient Address]]></category>
		<category><![CDATA[Send Email]]></category>
		<category><![CDATA[Send Mail]]></category>
		<category><![CDATA[Send mail Powershel]]></category>
		<category><![CDATA[Smtp]]></category>
		<category><![CDATA[Task Scheduler]]></category>

		<guid isPermaLink="false">http://www.kreslavsky.com/2010/11/send-email-powershell-script.html</guid>
		<description><![CDATA[Tweet &#160; Some times we need to use PS script to send email, script can be used in Task Scheduler or any other program BatchFile to run script: Create *.bat file C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -PSConsoleFile &#34;C:Program FilesMicrosoftExchange Serverbinexshell.psc1&#34; -noexit -command &#34;. C:scriptslocationscriptname.ps1&#34; &#160; PS Script to send mail: Create&#160; .ps1 file $filename = “c:filelocationHtmlFIleyouwant torecieve.html” $smtpServer = “SMTP Servername” $msg = new-object Net.Mail.MailMessage $att = new-object Net.Mail.Attachment($filename) $smtp = new-object Net.Mail.SmtpClient($smtpServer) $msg.From = “sendername@domainanme” $msg.To.Add(“recipient_address@domainanme”) $msg.Subject = “Subject” $msg.Body = “Body ” $msg.Attachments.Add($att) $smtp.Send($msg)]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.kreslavsky.com%2F2010%2F11%2Fsend-email-powershell-script.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.kreslavsky.com/2010/11/send-email-powershell-script.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.kreslavsky.com/2010/11/send-email-powershell-script.html"  data-text="Send Email Powershell script" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.kreslavsky.com/2010/11/send-email-powershell-script.html" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.kreslavsky.com/2010/11/send-email-powershell-script.html"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>&#160;</p>
<p>Some times we need to use PS script to send email, script can be used in Task Scheduler or any other program</p>
<p>BatchFile to run script: Create *.bat file </p>
<p>C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -PSConsoleFile &quot;C:Program FilesMicrosoftExchange Serverbinexshell.psc1&quot; -noexit -command &quot;.<em><strong> C:scriptslocationscriptname.ps1</strong></em>&quot;</p>
<p>&#160;</p>
<p><strong>PS Script to send mail:</strong> Create&#160; .ps1 file </p>
<p>$filename = “<strong>c:filelocationHtmlFIleyouwant torecieve.html</strong>”    <br />$smtpServer = “<strong><em>SMTP Servername</em></strong>” </p>
<p>$msg = new-object Net.Mail.MailMessage   <br />$att = new-object Net.Mail.Attachment($filename)    <br />$smtp = new-object Net.Mail.SmtpClient($smtpServer) </p>
<p>$msg.From = “<strong><em>sendername@domainanme</em></strong>”    <br />$msg.To.Add(“<strong><em>recipient_address@domainanme</em></strong>”)    <br />$msg.Subject = “Subject”    <br />$msg.Body = “Body ”    <br />$msg.Attachments.Add($att)     <br />$smtp.Send($msg)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kreslavsky.com/2010/11/send-email-powershell-script.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to update exchange 2007 Offline Address List</title>
		<link>http://www.kreslavsky.com/2009/11/how-to-update-exchange-2007-offline-address-list.html</link>
		<comments>http://www.kreslavsky.com/2009/11/how-to-update-exchange-2007-offline-address-list.html#comments</comments>
		<pubDate>Mon, 09 Nov 2009 07:42:58 +0000</pubDate>
		<dc:creator>Gil Kreslavsky</dc:creator>
				<category><![CDATA[Exchange 2007]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[OAB]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.kreslavsky.com/2009/11/how-to-update-exchange-2007-offline-address-list.html</guid>
		<description><![CDATA[Tweet &#160; You can update OAB by 2 ways via EMS or using Power Shell 1 To update via&#160; EMS Open EMC&#62;Organizational Configuration&#62;Mailbox&#62;Offline Address Book tab. Right click on desired Address Book and press update. 2. Via Power Shell Type: Update-OfflineAddressBook –Identity “Address List Name” To update all Address Books type : Get-OfflineAddressBook &#124; Update-OfflineAddressBook &#160; &#160;]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.kreslavsky.com%2F2009%2F11%2Fhow-to-update-exchange-2007-offline-address-list.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.kreslavsky.com/2009/11/how-to-update-exchange-2007-offline-address-list.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.kreslavsky.com/2009/11/how-to-update-exchange-2007-offline-address-list.html"  data-text="How to update exchange 2007 Offline Address List" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.kreslavsky.com/2009/11/how-to-update-exchange-2007-offline-address-list.html" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.kreslavsky.com/2009/11/how-to-update-exchange-2007-offline-address-list.html"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>&#160;</p>
<p>You can update OAB by 2 ways via EMS or using Power Shell</p>
<p>1 To update via&#160; EMS</p>
<p>Open EMC&gt;Organizational Configuration&gt;Mailbox&gt;Offline Address Book tab.</p>
<p>Right click on desired Address Book and press update.</p>
<p><a href="http://www.kreslavsky.com/wp-content/uploads/2009/11/image12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="EMS Offline Address Book " border="0" alt="EMS Offline Address Book " src="http://www.kreslavsky.com/wp-content/uploads/2009/11/image_thumb11.png" width="421" height="292" /></a> </p>
<p>2. Via Power Shell</p>
<p>Type: Update-OfflineAddressBook –Identity<font face="Trebuchet MS"> “Address List Name”</font></p>
<p><a href="http://www.kreslavsky.com/wp-content/uploads/2009/11/image13.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Power Shell OAB update" border="0" alt="Power Shell OAB update" src="http://www.kreslavsky.com/wp-content/uploads/2009/11/image_thumb12.png" width="438" height="203" /></a> </p>
<p>To update all Address Books type : Get-OfflineAddressBook | Update-OfflineAddressBook</p>
<p>&#160;</p>
<pre>&#160;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kreslavsky.com/2009/11/how-to-update-exchange-2007-offline-address-list.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Useful AD PowerShell Commands</title>
		<link>http://www.kreslavsky.com/2009/04/useful-ad-powershell-commands.html</link>
		<comments>http://www.kreslavsky.com/2009/04/useful-ad-powershell-commands.html#comments</comments>
		<pubDate>Wed, 08 Apr 2009 09:48:00 +0000</pubDate>
		<dc:creator>Gil Kreslavsky</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Server 2008]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.kreslavsky.com/2009/04/useful-ad-powershell-commands.html</guid>
		<description><![CDATA[Tweet Finding Disabled Users: get-qaduser –disabled Create a new Active Directory user: new-QADUser -name '&#60;User CN&#62;' -parentContainer '&#60;Parent DN&#62;' -UserPassword '&#60;Password&#62;' -FirstName '&#60;User First Name&#62;' -LastName '&#60;User Last Name&#62;' -UserPrincipalName '&#60;User UPN&#62;' Create multiple users in Active Directory: $parentDN = &#8220;&#60;ParentDN&#62;" $strPass = &#8220;userPaswd&#8221; For ($i = 1; $i -le 1000; $i++) { $strUserName = &#8220;User&#8221; + $i New-QADUser -name $strUserName -parentContainer $parentDN -UserPassword $strPass } Modify Attributes for several users: $strfileServer = "\Servername" $objOU = [ADSI] "LDAP://&#60;OU DN&#62;" $objOU.psbase.Children &#124;% { $uac = [int](($_.userAccountControl).ToString()) if (($_.objectClass -eq "user") -and (($uac -band 2) -eq 0)) { $_.put("homeDirectory", $strFileServer + $_.sAMAccountName) $_.SetInfo() } } Delete user in Active Directory remove-QADObject -identity &#60;User DN&#62; Set user profile in Active Directory get-QADUser -identity "&#60;User DN&#62;" &#124; set-QADUser -HomeDirectory '\ServernameKatrin' -HomeDrive 'H:' -ProfilePath '\server1profilesjsmith' -scriptpath '\dcnamenetlogonlogonscript.vbs' Move User to other OU move-QADObject -Identity &#60;UserDN&#62; -NewParentContainerName &#60;New OU DN&#62; Find Locked User Accounts Get-QADuser -locked Unlock User Account Unlock-QADUser -Identity &#60;UserDN&#62; Retrieve Password lockout policy Get-QADObject domainname.com &#124; format-list Name, *password*, *lockout*]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.kreslavsky.com%2F2009%2F04%2Fuseful-ad-powershell-commands.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.kreslavsky.com/2009/04/useful-ad-powershell-commands.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.kreslavsky.com/2009/04/useful-ad-powershell-commands.html"  data-text="Useful AD PowerShell Commands" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.kreslavsky.com/2009/04/useful-ad-powershell-commands.html" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.kreslavsky.com/2009/04/useful-ad-powershell-commands.html"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><h4>Finding Disabled Users:</h4>
<blockquote>
<pre>get-qaduser –disabled</pre>
</blockquote>
<h4>Create a new Active Directory user:</h4>
<blockquote>
<pre>new-QADUser -name '&lt;<tt><em>User CN</em></tt>&gt;' -parentContainer '&lt;<tt><em>Parent DN</em></tt>&gt;' -UserPassword
'&lt;<tt><em>Password</em></tt>&gt;' -FirstName '&lt;<tt><em>User First Name</em></tt>&gt;' -LastName '&lt;<tt><em>User Last Name</em></tt>&gt;'
-UserPrincipalName '&lt;<tt><em>User UPN</em></tt>&gt;'</pre>
</blockquote>
<h4>Create multiple users in Active Directory:</h4>
<blockquote><p>$parentDN = &#8220;<tt><em>&lt;ParentDN&gt;"</em></tt> $strPass = &#8220;userPaswd&#8221; For ($i = 1; $i -le 1000; $i++) { $strUserName = &#8220;User&#8221; + $i New-QADUser -name $strUserName -parentContainer $parentDN -UserPassword $strPass }</p></blockquote>
<h4>Modify Attributes for several users:</h4>
<blockquote>
<pre>$strfileServer = "\Servername"
$objOU = [ADSI] "LDAP://<tt><em>&lt;OU DN&gt;</em></tt>"
$objOU.psbase.Children |% {
    $uac = [int](($_.userAccountControl).ToString())
    if (($_.objectClass -eq "user") -and (($uac -band 2) -eq 0))
    {
        $_.put("homeDirectory", $strFileServer + $_.sAMAccountName)
        $_.SetInfo()
    }
}</pre>
</blockquote>
<h4>Delete user in Active Directory</h4>
<blockquote>
<pre>remove-QADObject -identity <tt><em>&lt;User DN&gt;</em></tt></pre>
</blockquote>
<h4>Set user profile in Active Directory</h4>
<blockquote>
<pre>get-QADUser -identity "<tt><em>&lt;User DN&gt;</em></tt>" |
set-QADUser -HomeDirectory '\ServernameKatrin' -HomeDrive
'H:' -ProfilePath '\server1profilesjsmith'
-scriptpath '\dcnamenetlogonlogonscript.vbs'</pre>
</blockquote>
<h4>Move User to other OU</h4>
<blockquote>
<pre>move-QADObject -Identity <tt><em>&lt;UserDN&gt;</em></tt> -NewParentContainerName &lt;<tt><em>New OU DN</em></tt>&gt;</pre>
</blockquote>
<h4>Find Locked User Accounts</h4>
<blockquote>
<pre>Get-QADuser -locked</pre>
</blockquote>
<h4>Unlock User Account</h4>
<blockquote>
<pre>Unlock-QADUser -Identity &lt;<tt><em>UserDN</em></tt>&gt;</pre>
</blockquote>
<h4>Retrieve Password lockout policy</h4>
<blockquote>
<pre>Get-QADObject domainname.com | format-list Name, *password*, *lockout*</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.kreslavsky.com/2009/04/useful-ad-powershell-commands.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Move Domain Controller to other site – PowerShell</title>
		<link>http://www.kreslavsky.com/2009/04/move-domain-controller-to-other-site-powershell.html</link>
		<comments>http://www.kreslavsky.com/2009/04/move-domain-controller-to-other-site-powershell.html#comments</comments>
		<pubDate>Mon, 06 Apr 2009 09:24:00 +0000</pubDate>
		<dc:creator>Gil Kreslavsky</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Server 2008]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[Windows Server]]></category>

		<guid isPermaLink="false">http://www.kreslavsky.com/2009/04/move-domain-controller-to-other-site-powershell.html</guid>
		<description><![CDATA[Tweet $dcname = &#60;DomainDNSName&#62; $newSite = &#34;NewSite Name&#34; $context = New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext(&#8216;DirectoryServer&#8217;, $dcname) $dc = [System.DirectoryServices.ActiveDirectory.DomainController]::getDomainController ($context) $dc.MoveToAnotherSite($newSite) &#160; Where DomainDNSName – Enter your DNS domain name]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.kreslavsky.com%2F2009%2F04%2Fmove-domain-controller-to-other-site-powershell.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.kreslavsky.com/2009/04/move-domain-controller-to-other-site-powershell.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.kreslavsky.com/2009/04/move-domain-controller-to-other-site-powershell.html"  data-text="Move Domain Controller to other site – PowerShell" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.kreslavsky.com/2009/04/move-domain-controller-to-other-site-powershell.html" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.kreslavsky.com/2009/04/move-domain-controller-to-other-site-powershell.html"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>$dcname = <tt><i>&lt;DomainDNSName&gt;       <br /></i></tt> $newSite = &quot;NewSite Name&quot;     <br />$context = New-Object     <br />System.DirectoryServices.ActiveDirectory.DirectoryContext(&#8216;DirectoryServer&#8217;, $dcname)     <br />$dc =     <br />[System.DirectoryServices.ActiveDirectory.DomainController]::getDomainController ($context)     <br />$dc.MoveToAnotherSite($newSite)</p>
<p>&#160;</p>
<p>Where <strong>DomainDNSName</strong> – Enter your DNS domain name</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kreslavsky.com/2009/04/move-domain-controller-to-other-site-powershell.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell Script To Create Snapshot of All VMs – Hyper-V</title>
		<link>http://www.kreslavsky.com/2009/04/powershell-script-to-create-snapshot-of-all-vms-hyper-v.html</link>
		<comments>http://www.kreslavsky.com/2009/04/powershell-script-to-create-snapshot-of-all-vms-hyper-v.html#comments</comments>
		<pubDate>Sun, 05 Apr 2009 09:17:00 +0000</pubDate>
		<dc:creator>Gil Kreslavsky</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Server 2008]]></category>
		<category><![CDATA[Hyper-V]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.kreslavsky.com/2009/04/powershell-script-to-create-snapshot-of-all-vms-hyper-v.html</guid>
		<description><![CDATA[Tweet $VSMgtSvc=Get-WmiObject -ComputerName localhost -NameSpace &#34;rootvirtualization&#34; -Class &#34;MsVM_virtualSystemManagementService&#34; get-wmiobject -computername localhost -Namespace rootVirtualization -query &#34;Select * from MSVM_Computersystem where Description like '%Virtual%' &#34; &#124; foreach-object {$VSMgtSvc.psbase.invokeMethod (&#34;CreateVirtualSystemSnapshot&#34;,@($_,$Null,$null)) }]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.kreslavsky.com%2F2009%2F04%2Fpowershell-script-to-create-snapshot-of-all-vms-hyper-v.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.kreslavsky.com/2009/04/powershell-script-to-create-snapshot-of-all-vms-hyper-v.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.kreslavsky.com/2009/04/powershell-script-to-create-snapshot-of-all-vms-hyper-v.html"  data-text="PowerShell Script To Create Snapshot of All VMs – Hyper-V" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.kreslavsky.com/2009/04/powershell-script-to-create-snapshot-of-all-vms-hyper-v.html" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.kreslavsky.com/2009/04/powershell-script-to-create-snapshot-of-all-vms-hyper-v.html"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><pre>$VSMgtSvc=Get-WmiObject -ComputerName localhost
-NameSpace &quot;rootvirtualization&quot;
-Class &quot;MsVM_virtualSystemManagementService&quot;
get-wmiobject -computername localhost -Namespace rootVirtualization
-query &quot;Select * from MSVM_Computersystem where Description like
'%Virtual%' &quot; | foreach-object {$VSMgtSvc.psbase.invokeMethod
(&quot;CreateVirtualSystemSnapshot&quot;,@($_,$Null,$null)) }</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kreslavsky.com/2009/04/powershell-script-to-create-snapshot-of-all-vms-hyper-v.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Group Using PowerShell ADUC, dsadd or admod</title>
		<link>http://www.kreslavsky.com/2009/03/widows-2003-2008-ad-create-group-aduc-dsadd-admod-powershell.html</link>
		<comments>http://www.kreslavsky.com/2009/03/widows-2003-2008-ad-create-group-aduc-dsadd-admod-powershell.html#comments</comments>
		<pubDate>Mon, 23 Mar 2009 18:37:30 +0000</pubDate>
		<dc:creator>Gil Kreslavsky</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Server 2003]]></category>
		<category><![CDATA[Server 2008]]></category>
		<category><![CDATA[Command Line Interface]]></category>
		<category><![CDATA[create group active directory]]></category>
		<category><![CDATA[create group script]]></category>
		<category><![CDATA[Create group via powershell]]></category>
		<category><![CDATA[Directory Users]]></category>
		<category><![CDATA[Dn]]></category>
		<category><![CDATA[Finance Users]]></category>
		<category><![CDATA[Global Distribution Group]]></category>
		<category><![CDATA[Global Domain]]></category>
		<category><![CDATA[Global Security]]></category>
		<category><![CDATA[Graphical User Interface]]></category>
		<category><![CDATA[Group Description]]></category>
		<category><![CDATA[Group Type]]></category>
		<category><![CDATA[Left Pane]]></category>
		<category><![CDATA[Local Security]]></category>
		<category><![CDATA[Numeric Value]]></category>
		<category><![CDATA[Objectclass]]></category>
		<category><![CDATA[Parent Container]]></category>
		<category><![CDATA[Security Group]]></category>
		<category><![CDATA[Universal Distribution]]></category>
		<category><![CDATA[Universal Security]]></category>

		<guid isPermaLink="false">http://www.kreslavsky.com/2009/03/widows-2003-2008-ad-create-group-aduc-dsadd-admod-powershell.html</guid>
		<description><![CDATA[Tweet Creating a Group Using a graphical user interface Open the Active Directory Users and Computers . In the left pane, browse to the parent container of the new group, right-click on it, and select New Group. Enter the name of the group and select the group type (global, domain local, or universal) and group type (security or distribution). Click OK. Using dsadd in command-line interface dsadd group &#8220;&#60;GroupDN&#62;&#8221; -scope &#60;GroupScope&#62; -secgrp yes&#124;no -desc &#8220;&#60;GroupDesc&#62;&#8220; Where &#60;GroupDN&#62; replace with DN of the group , Where &#60;GroupScope&#62; use one of the above l – for domain local g – for global u – for universal Where –secgroup yes if the group is a security group no for any other Where desc fill group description Using dsadd in command-line interface &#62; admod -b &#8220;&#60;GroupDN&#62;&#8221; objectClass::group groupType:: &#8220;&#60;GroupType&#62;&#8221; sAMAccountName::&#8221;&#60;Pre-Windows2000Name&#62;&#8221; -add Example: We will create global security group called &#8220;Accounting&#8221; in Accounting OU in testdomain.com &#62; dsadd group "cn=Accounting,ou=Accounting,dc=testdomain,dc=com"-scope global- secgrp yes &#62; admod-b "cn=Accounting,ou=Accounting,dc=testdomain,dc=com" groupType::-2147483646 sAMAccountName::"Finance Users" -add When using AdMod, you need specify the numeric value for group type, These values are predefined in Active Directory Universal Distribution Group Value – “8” Universal Security Group Value &#8211; “–2147483640” Domain Local Distribution Group Value &#8211; “4” Domain Local Security Group Value &#8211; “–2147483644” Global Distribution Group Value &#8211; “2” Global Security Group Value &#8211; “–2147483646” Create Group Using VBScript Example bellow shows how to create a global security group. ' ------ CONFIGURATION ------ strGroupParentDN = "&#60;GroupParentDN&#62;" ' e.g. ou=Groups,dc=testdomain,dc=com strGroupName = "&#60;GroupName&#62;" ' e.g. Accounting strGroupDescr = "&#60;GroupDesc&#62;" ' e.g. Accounting group ' ------ END CONFIGURATION --------- ' Constants taken from ADS_GROUP_TYPE_ENUM Const ADS_GROUP_TYPE_GLOBAL_GROUP = 2 Const ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP = 4 Const ADS_GROUP_TYPE_SECURITY_ENABLED = -2147483648 Const ADS_GROUP_TYPE_UNIVERSAL_GROUP = 8 set objOU = GetObject("LDAP://" &#38; strGroupParentDN) set objGroup = objOU.Create("group","cn=" &#38; strGroupName) objGroup.Put "groupType", ADS_GROUP_TYPE_GLOBAL_GROUP _ Or ADS_GROUP_TYPE_SECURITY_ENABLED objGroup.Put "sAMAccountName", strGroupName objGroup.Put "description", strGroupDescr objGroup.SetInfo Create Group Using PowerShell To create a group using the Quest cmdlets, use the following syntax: new-QADGroup -ParentContainer &#8216;&#60;Parent OU DN&#62;&#8216; -name &#8216;&#60;GroupName&#62;&#8216; -samaccountname &#8216;&#60;GroupName&#62; -grouptype &#8216;Distribution&#8217; -groupscope &#8216;Universal&#8217; Where &#60;Parent OU DN&#62; – Fill OU DN Where &#60;GroupName&#62; – Fill Group Name After –grouptype – set group type (Distribution or Security) After –groupscope – set if (Universal, Domain Local)]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.kreslavsky.com%2F2009%2F03%2Fwidows-2003-2008-ad-create-group-aduc-dsadd-admod-powershell.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.kreslavsky.com/2009/03/widows-2003-2008-ad-create-group-aduc-dsadd-admod-powershell.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.kreslavsky.com/2009/03/widows-2003-2008-ad-create-group-aduc-dsadd-admod-powershell.html"  data-text="Create Group Using PowerShell ADUC, dsadd or admod" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.kreslavsky.com/2009/03/widows-2003-2008-ad-create-group-aduc-dsadd-admod-powershell.html" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.kreslavsky.com/2009/03/widows-2003-2008-ad-create-group-aduc-dsadd-admod-powershell.html"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><h4>Creating a Group Using a graphical user interface</h4>
<ol>
<li>Open the Active Directory Users and Computers .</li>
<li>In the left pane, browse to the parent container of the new group, right-click on it, and select New Group.</li>
<li>Enter the name of the group and select the group type (global, domain local, or universal) and group type (security or distribution).</li>
<li>Click OK.</li>
</ol>
<p><a name="using_a_command-line_interface-id143"></a></p>
<h4>Using dsadd in command-line interface</h4>
<p><em>dsadd group &#8220;<tt>&lt;GroupDN&gt;</tt>&#8221; -scope <tt>&lt;GroupScope&gt;</tt> -secgrp yes|no -desc &#8220;<tt>&lt;GroupDesc&gt;</tt>&#8220;</em></p>
<p>Where <tt><em>&lt;GroupDN&gt;</em></tt><a name="of the"></a> replace with DN of the group ,</p>
<p>Where <tt><em>&lt;GroupScope&gt;</em></tt> use one of the above</p>
<ul>
<li><tt>l – for domain local</tt></li>
<li><tt>g – for global</tt></li>
<li><tt>u<span style="font-family: Lucida Sans Unicode;"> – for </span></tt>universal</li>
</ul>
<p><tt>Where –secgroup</tt></p>
<ul>
<li><tt>yes</tt> if the group is a security group</li>
<li>n<tt>o</tt> for any other</li>
</ul>
<p>Where<tt> desc</tt> fill group description</p>
<h4>Using dsadd in command-line interface</h4>
<p><em>&gt; admod -b &#8220;<tt>&lt;GroupDN&gt;</tt>&#8221; objectClass::group groupType::<br />
&#8220;<tt>&lt;GroupType&gt;</tt>&#8221; sAMAccountName::&#8221;<tt>&lt;Pre-Windows2000Name&gt;</tt>&#8221; -add</em></p>
<p><strong>Example:</strong> We will create global security group called &#8220;Accounting&#8221; in Accounting OU in testdomain.com<a name="can use"></a></p>
<pre>&gt; dsadd group "cn=Accounting,ou=Accounting,dc=testdomain,dc=com"-scope global-
secgrp yes</pre>
<pre>&gt; admod-b "cn=Accounting,ou=Accounting,dc=testdomain,dc=com" groupType::-2147483646
sAMAccountName::"Finance Users" -add</pre>
<p><a name="case of"></a>When using AdMod, you need specify the numeric value for group type, These values are predefined in Active Directory</p>
<p><a name="numeric_values_for_group_types"></a></p>
<p>Universal Distribution Group Value – “8”</p>
<p>Universal Security Group Value &#8211; “–2147483640”</p>
<p><a name="Distribution Group"></a>Domain Local Distribution Group Value &#8211; “4”</p>
<p><a name="Security Group"></a>Domain Local Security Group Value &#8211; “–2147483644”</p>
<p>Global Distribution Group Value &#8211; “2”</p>
<p>Global Security Group Value &#8211; “–2147483646”</p>
<h4>Create Group Using VBScript</h4>
<pre><strong>Example bellow shows how to create a global security group.</strong></pre>
<table style="width: 546px;" border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td width="544" valign="top">
<pre>' ------  CONFIGURATION ------
strGroupParentDN = "<tt><em>&lt;GroupParentDN&gt;</em></tt>" ' e.g. ou=Groups,dc=testdomain,dc=com
strGroupName     = "<tt><em>&lt;GroupName&gt;</em></tt>"     ' e.g. Accounting
strGroupDescr    = "<tt><em>&lt;GroupDesc&gt;</em></tt>"     ' e.g. Accounting group
' ------ END CONFIGURATION ---------</pre>
<pre>' Constants taken from ADS_GROUP_TYPE_ENUM
Const ADS_GROUP_TYPE_GLOBAL_GROUP       = 2
Const ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP = 4
Const ADS_GROUP_TYPE_SECURITY_ENABLED   = -2147483648
Const ADS_GROUP_TYPE_UNIVERSAL_GROUP    = 8</pre>
<pre>set objOU = GetObject("LDAP://" &amp; strGroupParentDN)
set objGroup = objOU.Create("group","cn=" &amp; strGroupName)
objGroup.Put "groupType", ADS_GROUP_TYPE_GLOBAL_GROUP _
                         Or ADS_GROUP_TYPE_SECURITY_ENABLED
objGroup.Put "sAMAccountName", strGroupName
objGroup.Put "description", strGroupDescr
objGroup.SetInfo</pre>
</td>
</tr>
</tbody>
</table>
<p><a name="using_powershell-id116"></a></p>
<h4>Create Group Using PowerShell</h4>
<p><a name="Quest cmdlets"></a>To create a group using the Quest cmdlets, use the following syntax:<a name="I_indexterm7_d1e28870"></a></p>
<table style="width: 549px;" border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td width="547" valign="top">new-QADGroup -ParentContainer &#8216;<tt><em>&lt;Parent OU DN&gt;</em></tt>&#8216; -name &#8216;<tt><em>&lt;GroupName&gt;</em></tt>&#8216; -samaccountname &#8216;<tt><em>&lt;GroupName&gt;</em></tt> -grouptype &#8216;Distribution&#8217; -groupscope &#8216;Universal&#8217;</td>
</tr>
</tbody>
</table>
<pre>Where <tt><em>&lt;Parent OU DN&gt; – Fill OU DN</em></tt></pre>
<pre><tt></tt>Where <tt><em>&lt;GroupName&gt;</em></tt> – Fill Group Name</pre>
<pre>After –grouptype – set group type (Distribution or Security)</pre>
<pre>After –groupscope – set if (Universal, Domain Local)</pre>
<p><a name="the following"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kreslavsky.com/2009/03/widows-2003-2008-ad-create-group-aduc-dsadd-admod-powershell.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell script to find all Local Users on a remote computer</title>
		<link>http://www.kreslavsky.com/2009/03/powershell-script-to-find-all-local-users-on-a-remote-computer.html</link>
		<comments>http://www.kreslavsky.com/2009/03/powershell-script-to-find-all-local-users-on-a-remote-computer.html#comments</comments>
		<pubDate>Mon, 23 Mar 2009 16:53:00 +0000</pubDate>
		<dc:creator>Gil Kreslavsky</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Server 2008]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[locate local users]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.kreslavsky.com/2009/03/powershell-script-to-find-all-local-users-on-a-remote-computer.html</guid>
		<description><![CDATA[Tweet $strComputer = &#34;ComputerName&#34; $computer = [ADSI](&#34;WinNT://&#34; + $strComputer + &#34;,computer&#34;) $computer.name $Users = $computer.psbase.children &#124;where{$_.psbase.schemaclassname -eq &#34;User&#34;} foreach ($member in $Users.psbase.syncroot) {$member.name}]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.kreslavsky.com%2F2009%2F03%2Fpowershell-script-to-find-all-local-users-on-a-remote-computer.html&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.kreslavsky.com/2009/03/powershell-script-to-find-all-local-users-on-a-remote-computer.html"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.kreslavsky.com/2009/03/powershell-script-to-find-all-local-users-on-a-remote-computer.html"  data-text="PowerShell script to find all Local Users on a remote computer" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.kreslavsky.com/2009/03/powershell-script-to-find-all-local-users-on-a-remote-computer.html" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.kreslavsky.com/2009/03/powershell-script-to-find-all-local-users-on-a-remote-computer.html"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><table cellspacing="0" cellpadding="2" width="400" border="0">
<tbody>
<tr>
<td valign="top" width="400">
<p>$strComputer = &quot;ComputerName&quot;           <br />$computer = [ADSI](&quot;WinNT://&quot; + $strComputer + &quot;,computer&quot;)            <br />$computer.name            <br />$Users = $computer.psbase.children |where{$_.psbase.schemaclassname -eq &quot;User&quot;}            <br />foreach ($member in $Users.psbase.syncroot)            <br />{$member.name} </p>
</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.kreslavsky.com/2009/03/powershell-script-to-find-all-local-users-on-a-remote-computer.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

