 




<?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>The Multifunctioning DBA &#187; Windows Administration</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/dba/tag/windows-administration/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/dba</link>
	<description></description>
	<lastBuildDate>Wed, 06 Feb 2013 01:01:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Powershell Remove files</title>
		<link>http://itknowledgeexchange.techtarget.com/dba/powershell-remove-files/</link>
		<comments>http://itknowledgeexchange.techtarget.com/dba/powershell-remove-files/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 16:13:40 +0000</pubDate>
		<dc:creator>Colin Smith</dc:creator>
				<category><![CDATA[Microsoft Windows]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Administration]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/dba/?p=258</guid>
		<description><![CDATA[I have a server that attempts to backup up the SQL Server databases and it always fails because not enough space is available. This usually is not a big deal as I would run a SQL Clean up task before the backups run to remove the old files. In this case though I am using [...]]]></description>
				<content:encoded><![CDATA[<p>I have a server that attempts to backup up the SQL Server databases and it always fails because not enough space is available. This usually is not a big deal as I would run a SQL Clean up task before the backups run to remove the old files. In this case though I am using a third party utility to run the backups and it does not have that functionality. So, since I am no sqljockey yet, I have chosen Powershell as my tool. Here is what I have done.</p>
<pre><code>
</code>
<div style="padding: 4px;width: 700px;height: 150px;color: #000000;font-family: arial black;font-size: 10px;text-align: left">

$days = [datetime]::now.adddays(-7)
E:
cd \
cd Directory
ls | where {$_.name -like "*.bak"} | rm -force 
cd tranlogs
ls | where {$_.name -like "*trn"} | rm -force 
cd ../../Directory
ls | where {$_.name -like "*.bak"} | rm -force 
cd tranlogs
ls | where {$_.name -like "*bak"} | rm -force 
ls | where {$_.name -like "*txt"} | where{$_.creationtime -lt $days} | rm -force
c:


</div></pre>
<p>You can see that I simple cd to the directory that I have my backupfiles in and do an rm or Remove-object. I am also keeping 7 days worth of the txt log files that the backups create. Just in case I need them. Hope that helps. Enjoy</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/dba/powershell-remove-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random Password Script Powershell</title>
		<link>http://itknowledgeexchange.techtarget.com/dba/random-password-script-powershell/</link>
		<comments>http://itknowledgeexchange.techtarget.com/dba/random-password-script-powershell/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 20:56:53 +0000</pubDate>
		<dc:creator>Colin Smith</dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Passwords]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Windows Administration]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/dba/random-password-script-powershell/</guid>
		<description><![CDATA[I was recently asked if I could write a script that would create a random password based on a word list. The password needs to have a capital letter, a special character, and a number. The password also has to be made up of two seperate words that are in the word list. my words.csv [...]]]></description>
				<content:encoded><![CDATA[<p>I was recently asked if I could write a script that would create a random password based on a word list. The password needs to have a capital letter, a special character, and a number. The password also has to be made up of two seperate words that are in the word list.</p>
<p>my words.csv file is formatted as so</p>
<p>Number, Word</p>
<p>Here is what I did.</p>
<p>$symbols = &#8220;(&#8220;, &#8220;!&#8221;, &#8220;@&#8221;, &#8220;#&#8221;, &#8220;$&#8221;, &#8220;%&#8221;, &#8220;^&#8221;, &#8220;&amp;&#8221;, &#8220;*&#8221;, &#8220;_&#8221;, &#8220;+&#8221;, &#8220;=&#8221;, &#8220;?&#8221;, &#8220;/&#8221;, &#8220;~&#8221;, &#8220;;&#8221;, &#8220;:&#8221;, &#8220;,&#8221;, &#8220;&lt;&#8221;, &#8220;&gt;&#8221;, &#8220;\&#8221;, &#8220;)&#8221;, &#8220;.&#8221;<br />
$words = Import-Csv &#8220;\\path to word list\words.csv&#8221;<br />
$max = $words.Count</p>
<p>$first = New-Object system.Random<br />
$1value = $first.next(0, $max)<br />
$firstword = $words[$1value].word<br />
$firstword = $firstword.toupper()</p>
<p>Start-Sleep -milliseconds 20<br />
$second = New-Object system.Random<br />
$2value = $second.next(1, 23)<br />
$special = $symbols[$2value]</p>
<p>Start-Sleep -milliseconds 300<br />
$third = New-Object system.Random<br />
$3value = $third.next(0, $max)<br />
$secondword = $words[$3value].word</p>
<p>Start-Sleep -milliseconds 230<br />
$num = New-Object system.Random<br />
$4value = $num.next(0, $max)<br />
$4value = $words[$4value].number</p>
<p>$newpass = &#8220;$firstword$special$secondword$4value&#8221;</p>
<p>Echo &#8220;`n&#8221;<br />
$newpass<br />
Echo &#8220;`n&#8221;</p>
<p>So as you can see I am using the word list to pull the two words as well as the number value. In order to get my capital I am using the toupper() function on the first word, and for the special character I create an array of characters and then pick one to use.</p>
<p>Any comments or questions please let me know.</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/dba/random-password-script-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More with Quest AD Powershell CMDLETS</title>
		<link>http://itknowledgeexchange.techtarget.com/dba/more-with-quest-ad-powershell-cmdlets/</link>
		<comments>http://itknowledgeexchange.techtarget.com/dba/more-with-quest-ad-powershell-cmdlets/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 21:43:08 +0000</pubDate>
		<dc:creator>Colin Smith</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Domain Administration]]></category>
		<category><![CDATA[Microsoft Windows]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Administration]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/dba/more-with-quest-ad-powershell-cmdlets/</guid>
		<description><![CDATA[I am continuing work on the script that I am converting from VBScript to Powershell and I must say that it is going quite well with the help of the Quest cmdlets. In the script I want to go through a particular OU and delete any accounts that are currntly disabled, and were created a [...]]]></description>
				<content:encoded><![CDATA[<p>I am continuing work on the script that I am converting from VBScript to Powershell and I must say that it is going quite well with the help of the Quest cmdlets. In the script I want to go through a particular OU and delete any accounts that are currntly disabled, and were created a minimum of 180 days ago, and have not been used in a minimum of 180 days. I can do this with the following block of code.</p>
<p>$deletedays = &#8211; 180<br />
$deletedate = [datetime]::Now.AddDays($deletedays)</p>
<p>Get-QADUser -SearchRoot &#8220;pni.us.ad.gannett.com/PNI/Users/Disabled&#8221; | where{(($_.lastlogontimestamp.value -lt $deletedate) -and ($_.creationdate -lt $deletedate) -and ($_.AccountIsDisabled -eq &#8220;True&#8221;))}  | Tee-Object -filepath &#8220;c:\removedaccounts.txt&#8221; | Remove-QADObject -Force</p>
<p>So you will also notice that I am using the Tee-Object cmdlet. This is not a quest cmdlet but it is nice as I can log what accounts I am deleting with the Remove-QADObject cmdlet that is provided by Quest. Be careful when doing things like removing accounts in scripts and be sure to test completly. A good way to test is to use the -whatif clause. This will show you what would happen if you did run it.</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/dba/more-with-quest-ad-powershell-cmdlets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get List of all DC&#8217;s in your Domain</title>
		<link>http://itknowledgeexchange.techtarget.com/dba/get-list-of-all-dcs-in-your-domain/</link>
		<comments>http://itknowledgeexchange.techtarget.com/dba/get-list-of-all-dcs-in-your-domain/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 21:59:11 +0000</pubDate>
		<dc:creator>Colin Smith</dc:creator>
				<category><![CDATA[Domain Administration]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Windows Administration]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/dba/get-list-of-all-dcs-in-your-domain/</guid>
		<description><![CDATA[I am working on converting a vbscript that I wrote a couple of years ago into a powershell script. This script requires that I query all of the Domain Controllers in my domain to get the most up to date data that is possible. I used the Quest AD Commanlets and they made it easy. [...]]]></description>
				<content:encoded><![CDATA[<p>I am working on converting a vbscript that I wrote a couple of years ago into a powershell script. This script requires that I query all of the Domain Controllers in my domain to get the most up to date data that is possible. I used the Quest AD Commanlets and they made it easy. I have discussed these in the past and if you have not gotten them yet then go get them. They are at the following link:</p>
<p>http://www.quest.com/powershell/activeroles-server.aspx</p>
<p>to get a listing of your DC&#8217;s just do the following.</p>
<p>$dcs = Get-QADComputer -ComputerRole DomainController</p>
<p>now you have a listing of them in the $dcs variable and you can scan them all.</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/dba/get-list-of-all-dcs-in-your-domain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reboot a Remote Windows Host Remotely</title>
		<link>http://itknowledgeexchange.techtarget.com/dba/reboot-a-remote-windows-host-remotely/</link>
		<comments>http://itknowledgeexchange.techtarget.com/dba/reboot-a-remote-windows-host-remotely/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 15:38:38 +0000</pubDate>
		<dc:creator>Colin Smith</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Remote boot]]></category>
		<category><![CDATA[Windows Administration]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/dba/reboot-a-remote-windows-host-remotely/</guid>
		<description><![CDATA[Say you need to reboot a server and this is something that you would like to automate based on certain criteria. For instance, I might want to reboot a server if I can talk to the server but for somereason my SQL Server is not up and running. If everything is configured correctly the SQL [...]]]></description>
				<content:encoded><![CDATA[<p>Say you need to reboot a server and this is something that you would like to automate based on certain criteria. For instance, I might want to reboot a server if I can talk to the server but for somereason my SQL Server is not up and running. If everything is configured correctly the SQL Server should start up again on boot. So you can do something like the following.</p>
<p>$varname = Get-WmiObject Win32_OperatingSystem -computername &#8220;remotemachine&#8221;</p>
<p>$varname.reboot()</p>
<p>Now you can check your SQL Server once the machine is back up.</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/dba/reboot-a-remote-windows-host-remotely/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test a path in Powershell</title>
		<link>http://itknowledgeexchange.techtarget.com/dba/test-a-path-in-powershell/</link>
		<comments>http://itknowledgeexchange.techtarget.com/dba/test-a-path-in-powershell/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 15:28:40 +0000</pubDate>
		<dc:creator>Colin Smith</dc:creator>
				<category><![CDATA[Microsoft Windows]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Windows Administration]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/dba/test-a-path-in-powershell/</guid>
		<description><![CDATA[this is a simple thing but it can be very useful. I use this is many of my scripts. Sometimes I want to make sure that a file is available for me to append and if not then I would like to create a new one. Take a log file for example, if the file [...]]]></description>
				<content:encoded><![CDATA[<p>this is a simple thing but it can be very useful. I use this is many of my scripts. Sometimes I want to make sure that a file is available for me to append and if not then I would like to create a new one. Take a log file for example, if the file has been moved or deleted, perhaps it grew very large and needed to be removed, the script can just create a new one without running into any problems. If the file is still available though, then the script can just append the current file. here is an example:</p>
<p>if (!(test-path &#8220;H:\path\file.txt&#8221;))<br />
{<br />
New-Item -type File &#8220;H:\path\file.txt&#8221;<br />
}</p>
<p>This will check if the file exists and if not then it will create it.</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/dba/test-a-path-in-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Ping Servers Improved</title>
		<link>http://itknowledgeexchange.techtarget.com/dba/sql-ping-servers-improved/</link>
		<comments>http://itknowledgeexchange.techtarget.com/dba/sql-ping-servers-improved/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 16:15:56 +0000</pubDate>
		<dc:creator>Colin Smith</dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[DBA]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Windows Administration]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/dba/sql-ping-servers-improved/</guid>
		<description><![CDATA[Not long ago I did a post about pinging the interface of a server since you may encounter a problem connecting to WMI even if a server is up. The article is at http://itknowledgeexchange.techtarget.com/dba/powershell-ping/. So Like I describe in that post I did not want our DBA team to be paged about a SQL Server [...]]]></description>
				<content:encoded><![CDATA[<p>Not long ago I did a post about pinging the interface of a server since you may encounter a problem connecting to WMI even if a server is up. The article is at <a href="http://itknowledgeexchange.techtarget.com/dba/powershell-ping/">http://itknowledgeexchange.techtarget.com/dba/powershell-ping/</a>.</p>
<p>So Like I describe in that post I did not want our DBA team to be paged about a SQL Server being down when it was really an issue with the host server. In that case I would like the Windows Administration team to be notified so that they can take care of the issue. I also wanted to check on some other things about the server. I wanted to check the physical interface, check that the agent service is running, and also verify that connections to the database can be made. I have finished the script to do this and I will go over it with you a function at a time. First we will look at the Main function. This is where everything gets set up.</p>
<p><span style="font-size: 10pt;font-family: Courier New;color: green">#################################<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: green">####### Start Script ############<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: green">#################################<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: navy">$ErrorActionPreference</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;SilentlyContinue&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: purple">$time</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: cadetblue">Get-Date</span><span style="color: black"><br />
</span><span style="color: cadetblue">-displayhint</span><span style="color: black"><br />
</span><span style="color: blue">time</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: purple">$date</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: blue">date</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: cadetblue">New-PSDrive</span><span style="color: black"><br />
</span><span style="color: blue">i</span><span style="color: black"><br />
</span><span style="color: cadetblue">-PSProvider</span><span style="color: black"><br />
</span><span style="color: blue">filesystem</span><span style="color: black"><br />
</span><span style="color: cadetblue">-Root</span><span style="color: black"> \\SomeServer\SomeShare<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: blue">if</span><span style="color: black"> (</span><span style="color: cadetblue">test-path</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;i:\OUT\ping_with_service_check.txt&#8221;</span><span style="color: black">)<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black">{<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: cadetblue">Clear-Content</span><span style="color: black"><br />
</span><span style="color: cadetblue">-path</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;i:\OUT\ping_with_service_check.txt&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black">}<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: green">##Read in List of SQL Servers And set up all needed variables for script<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: purple">$NTusers</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;phx.it.systems.nt@pni.com&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: purple">$servers</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: cadetblue">Import-Csv</span><span style="color: black"><br />
</span><span style="color: cadetblue">-Path</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;i:\inputs\sqltab.txt&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: blue">foreach</span><span style="color: black"> (</span><span style="color: purple">$server</span><span style="color: black"><br />
</span><span style="color: blue">in</span><span style="color: black"><br />
</span><span style="color: purple">$servers</span><span style="color: black">)<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black">{<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$machine</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: purple">$server</span><span style="color: black">.</span><span style="color: saddlebrown">server</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$instance</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: purple">$server</span><span style="color: black">.</span><span style="color: saddlebrown">instance</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$torp</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: purple">$server</span><span style="color: black">.</span><span style="color: saddlebrown">torp</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$ping</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: purple">$server</span><span style="color: black">.</span><span style="color: saddlebrown">ping</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">if</span><span style="color: black"> (</span><span style="color: purple">$instance</span><span style="color: black"><br />
</span><span style="color: red">-eq</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;NULL&#8221;</span><span style="color: black">)<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black">{<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$SqlServer</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: purple">$server</span><span style="color: black">.</span><span style="color: saddlebrown">server</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$folder</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: purple">$server</span><span style="color: black">.</span><span style="color: saddlebrown">server</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$sqlagent</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;sqlserveragent&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$sqlserverservice</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;mssqlserver&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> }<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">else</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black">{<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$SqlServer</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;$machine\$instance&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$folder</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;$machine-$instance&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$sqlagent</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;sqlagent`$$instance&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$sqlserverservice</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;mssql`$$instance&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> }<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">echo</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;`n############################&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">echo</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;`n############################&#8221;</span><span style="color: black"> &gt;&gt; </span><span style="color: maroon">&#8220;i:\OUT\ping_with_service_check.txt&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$machine</span><span style="color: black"> &gt;&gt; </span><span style="color: maroon">&#8220;i:\OUT\ping_with_service_check.txt&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$machine</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">if</span><span style="color: black"> (</span><span style="color: purple">$ping</span><span style="color: black"><br />
</span><span style="color: red">-eq</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;Y&#8221;</span><span style="color: black">)<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> {<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">if</span><span style="color: black"> (</span><span style="color: cadetblue">test-path</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;i:\$folder\wmi_Failure.txt&#8221;</span><span style="color: black">)<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> {<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$wmierror</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"> 1<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$wminoemail</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"> 1<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$wmifile</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: cadetblue">Get-ChildItem</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;i:\$folder&#8221;</span><span style="color: black"><br />
</span><span style="color: blue">|</span><span style="color: black"><br />
</span><span style="color: blue">where</span><span style="color: black">{</span><span style="color: navy">$_</span><span style="color: black">.</span><span style="color: saddlebrown">name</span><span style="color: black"><br />
</span><span style="color: red">-eq</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;wmi_failure.txt&#8221;</span><span style="color: black">}<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"><br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$filetime</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: purple">$wmifile</span><span style="color: black">.</span><span style="color: saddlebrown">lastwritetime</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">if</span><span style="color: black">(</span><span style="color: purple">$filetime</span><span style="color: red">-le</span><span style="color: black"><br />
</span><span style="color: purple">$date</span><span style="color: black">.</span><span style="color: saddlebrown">AddDays</span><span style="color: black">(</span><span style="color: red">-</span><span style="color: black">1))<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> {<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">del</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;i:\$folder\wmi_Failure.txt&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> }<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> }<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">if</span><span style="color: black"> (</span><span style="color: red">!</span><span style="color: black">(</span><span style="color: cadetblue">test-path</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;i:\$folder\wmi_Failure.txt&#8221;</span><span style="color: black">))<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> {<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$wmierror</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"> 0<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$wminoemail</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"> 0<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> }<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">if</span><span style="color: black"> (</span><span style="color: cadetblue">test-path</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;i:\$folder\ping_Failure.txt&#8221;</span><span style="color: black">)<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> {<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$pingfail</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"> 1<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$pingnoemail</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"> 1<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$pingfile</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: cadetblue">Get-ChildItem</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;i:\$folder&#8221;</span><span style="color: black"><br />
</span><span style="color: blue">|</span><span style="color: black"><br />
</span><span style="color: blue">where</span><span style="color: black">{</span><span style="color: navy">$_</span><span style="color: black">.</span><span style="color: saddlebrown">name</span><span style="color: black"><br />
</span><span style="color: red">-eq</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;ping_failure.txt&#8221;</span><span style="color: black">}<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$pingfiletime</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: purple">$pingfile</span><span style="color: black">.</span><span style="color: saddlebrown">lastwritetime</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$pingfiletime</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"><br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">if</span><span style="color: black"> (</span><span style="color: purple">$pingfiletime</span><span style="color: black"><br />
</span><span style="color: red">-le</span><span style="color: black"><br />
</span><span style="color: purple">$date</span><span style="color: black">.</span><span style="color: saddlebrown">AddHours</span><span style="color: black">(</span><span style="color: red">-</span><span style="color: black">6))<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> {<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">echo</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;File was created more than 1 minute ago. $pingfiletime&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">del</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;i:\$folder\ping_failure.txt&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> }<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> }<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">if</span><span style="color: black"> (</span><span style="color: red">!</span><span style="color: black">(</span><span style="color: cadetblue">test-path</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;i:\$folder\ping_Failure.txt&#8221;</span><span style="color: black">))<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> {<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$pingfail</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"> 0<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$pingnoemail</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"> 0<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> }<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">if</span><span style="color: black"> (</span><span style="color: cadetblue">test-path</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;i:\$folder\agent_Failure.txt&#8221;</span><span style="color: black">)<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> {<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$agentfail</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"> 1<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> }<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">if</span><span style="color: black"> (</span><span style="color: red">!</span><span style="color: black">(</span><span style="color: cadetblue">test-path</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;i:\$folder\agent_Failure.txt&#8221;</span><span style="color: black">))<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> {<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: purple">$agentfail</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"> 0<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> }<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">Ping_Interface</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"><br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"> }<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">if</span><span style="color: black"> (</span><span style="color: purple">$ping</span><span style="color: black"><br />
</span><span style="color: red">-eq</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;N&#8221;</span><span style="color: black">)<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black">{<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black"><br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">echo</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;$sqlserver &#8211; is not being pinged at this time. Check SQLTAB&#8221;</span><span style="color: black"> &gt;&gt; </span><span style="text-decoration: underline;color: green">i:\OUT\ping_with_service_check.txt</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black"> </span><span style="color: blue">echo</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;############################&#8221;</span><span style="color: black"> &gt;&gt; </span><span style="color: maroon">&#8220;i:\OUT\ping_with_service_check.txt&#8221;</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black">}<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black">}<br />
</span></p>
<p><span style="font-size: 10pt;font-family: Courier New;color: black">Ok so you can see from looking at the script that this is where the script starts even though, you will see when you see the entire script, that this is the end of the script. That is because in Powershell you must define all functions before the script begins.<br />
</span></p>
<p>As you can see I start out by setting some things upand clearing out my log file. You could just keep appending to the file but I chose not to. You can also see that I set up a variable called $servers. This is populated by a .csv file that I have that has all the information about my SQL Servers that I am going to need for this script and for my other monitoring script. The heading of that file is as follows.</p>
<p>Monitor,Server,Instance,TorP,ErrorLog,Ping,OS2000</p>
<p>This way I know if I want to monitor the server, I may choose not to if it is out of commission for a while, I know the hostname, instance name, if it is Test or Production, if I want to run this Ping Servers Script on it and if it is running Windows Server 2000 as I can not run powershell locally on those servers.</p>
<p>Now that I have that variable populated I can start my loop. I start setting up each individual variable that I am going to need later on. Now I start looking for some touch files called wmi_failure.txt and ping_failure.txt. These are so I will know if either a wmi call or a physical interface ping failed on the last run of the script. On both of these I do not want to send out notification every 10 minutes but for wmi failures just once a day and for interface failures once every 6 hours. Now you may be asking why only every 6 hours if a servers interface is down since that means the server is basically useless. I would agree with you, but remember I wanted to notify our Windows Team about this issue and this was there call. No pages and only email us once every 6 hours about the issue. I was shocked at this response. Anyway, I look at the file if it is there and then I check how old it is based on the current time of the script running. If it has been passed the allotted amount of time then I remove that file and set the failure variables to 0 so the script will know to send out notifications about the failures should they still occur. Once I set all that up I can call my firs function if this script should be run against the server. That is noted by $ping being equal to Y or N. Next time I will show you my Ping_Interface function.</p>
<p>If you have any questions or comments about this script please let me know at <a href="http://sysadminsmith.com">http://sysadminsmith.com</a> and click the &#8216;Submit a Question&#8217; link to the right.</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/dba/sql-ping-servers-improved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Powershell Ping</title>
		<link>http://itknowledgeexchange.techtarget.com/dba/powershell-ping/</link>
		<comments>http://itknowledgeexchange.techtarget.com/dba/powershell-ping/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 17:14:05 +0000</pubDate>
		<dc:creator>Colin Smith</dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[DBA]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Windows Administration]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/dba/powershell-ping/</guid>
		<description><![CDATA[I have a script that goes out and pings all of my SQL Servers. This script, right now, simply makes a connection to the SQL Server instance. If I am able to connect I call it good and if not I send out notifications saying that the SQL Server is down. I found that more [...]]]></description>
				<content:encoded><![CDATA[<p>I have a script that goes out and pings all of my SQL Servers. This script, right now, simply makes a connection to the SQL Server instance. If I am able to connect I call it good and if not I send out notifications saying that the SQL Server is down. I found that more often than not I was getting these alerts because of some issue with the OS. This could be that the network interface was down, the server was powered off, or a number of other issues that could impact connecting to the SQL Server instance. My team usually ended up looking into it and having to call one of our Windows Systems Administrators in order to get the issue corrected.</p>
<p>The DBA Team did not really like that we got notified on OS issues before the Windows Team. The Windows Team was happy that we were letting them know of issues but they do not really like that the DBA team sees the problem before they do either. Because of this I decided to redo the SQL Ping Servers thing that I am going to do is to ping the servers interface and make sure that the server is up and responsive. If it is not then I as a DBA will not really be able to do anything anyway so if the ping fails I will just notify the Windows team directly. To do this Powershell needs to connect to WMI and look at the win32_pingstatus like so.</p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: purple">$pingresult</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: cadetblue">Get-WmiObject</span><span style="color: black"><br />
</span><span style="color: blue">win32_pingstatus</span><span style="color: black"><br />
</span><span style="color: red">-f</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;address=&#8217;$machine&#8217;&#8221;<br />
</span></span></p>
<p>This does work well but I ran into another issue. What if WMI of a server is not working for some reason? I have had this issue come up and then it may look like I cannot ping the physical interface on a server when in fact I can. I thought that I need a more effective way just to test the PING. Why not just use good old ping. So I did the following and it works great.</p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: purple">$pingresult</span><span style="color: black"><br />
</span><span style="color: red">=</span><span style="color: black"><br />
</span><span style="color: blue">ping</span><span style="color: black"><br />
</span><span style="color: cadetblue">pni-vmdbasql</span><span style="color: black"><br />
</span><span style="color: cadetblue">-n</span><span style="color: black"> 1<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: purple">$pingresult</span><span style="color: black"><br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: blue">if</span><span style="color: black"> (</span><span style="color: purple">$pingresult</span><span style="color: black"><br />
</span><span style="color: red">-like</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;*(0% loss*&#8221;</span><span style="color: black">)<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black">{</span><span style="color: blue">Echo</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;Ping Success&#8221;</span><span style="color: black">}<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: blue">if</span><span style="color: black"> ((</span><span style="color: purple">$pingresult</span><span style="color: black"><br />
</span><span style="color: red">-like</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;*100% loss*&#8221;</span><span style="color: black">) </span><span style="color: red">-or</span><span style="color: black"> (</span><span style="color: purple">$pingresult</span><span style="color: black"><br />
</span><span style="color: red">-like</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;*could not find host*&#8221;</span><span style="color: black">))<br />
</span></span></p>
<p><span style="font-size: 10pt;font-family: Courier New"><span style="color: black">{</span><span style="color: blue">echo</span><span style="color: black"><br />
</span><span style="color: maroon">&#8220;Ping Failed notify Systems Team&#8221;</span><span style="color: black">}<br />
</span></span></p>
<p>This way I can test the actual ping of the server. If the hostname cannot be resolved or if my loss is 100% then I consider this a failed test and I will notify the Windows Team. If I have 0% loss then I can move to my next function and continue with my basic health check of the SQL Server.</p>
<p>I will but more about this PING SQL Server script out when I have completed it. I just thought this was a very important distinction to make you aware of.</p>
<p>Any questions please head over to http://www.sysadminsmith.com and click on the &#8216;Submit a Question&#8217; link to the right.</p>
<p>Script and incorporate some more steps in it that will better determine what the cause of the issue is and will notify the appropriate team.</p>
<p>The first</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/dba/powershell-ping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scripting</title>
		<link>http://itknowledgeexchange.techtarget.com/dba/scripting/</link>
		<comments>http://itknowledgeexchange.techtarget.com/dba/scripting/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 21:57:08 +0000</pubDate>
		<dc:creator>Colin Smith</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows Administration]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/dba/scripting/</guid>
		<description><![CDATA[So I have people ask me all the time how I can get so much done in a day. I have to be honest with you, I do not really do that much. This is because I write scripts to do anything and everything for me if I have to do it more than once [...]]]></description>
				<content:encoded><![CDATA[<p><span style="font-size:12pt">So I have people ask me all the time how I can get so much done in a day. I have to be honest with you, I do not really do that much. This is because I write scripts to do anything and everything for me if I have to do it more than once I script it. If I think something might be useful I script it. I hate doing the same work over and over. Take something as simple as creating a new user on a domain. This is a very simple task in AD but it takes about 2 minutes per account. It is easy to find a script that will create mass accounts with some generic name. Why not take that same script and make it so it creates one account at a time or ten or whatever you need. You can make it so you type in the name of the user interactively or read names in from a list that you have. Simple things like that. Creating this account only takes 2 minutes in AD but I can do it in under 10 seconds.<br />
</span></p>
<p>When you work in the fast paced world like we do, especially in IT where everyone wants it now now now, every second counts. Saving just under 2 minutes does not seem like a lot but that is the just the beginning. If you save 5 minutes here and 10 there and 2 there then it adds up very fast so you can leave work an hour early, or you just make your boss think that you are that much better and more effective. It does not really matter if you are a Windows person or a Unix/Linux person. SCRIPT anything you can and save time.</p>
<p>I come from a Windows background and in this area the Unix/Linux admins are years ahead of the Windows users. I had done some automation using VBScript when I was a Windows Admin, but when I got into Unix for Database Admin, I quickly learned that scripting is the way. Now with Windows Powershell, Windows administrators can be much more effective in less time. Please learn a scripting language that is of use to you and that you understand. I prefer Powershell but VBscript is a good way to go if you like it better.</p>
<p>Good luck scripting and as always, if you have a question let me know by heading to <a href="http://sysadminsmith.com">http://sysadminsmith.com</a> and click the &#8216;Submit a Question&#8217; link on the right.</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/dba/scripting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free Space or Mount Points</title>
		<link>http://itknowledgeexchange.techtarget.com/dba/free-space-or-mount-points/</link>
		<comments>http://itknowledgeexchange.techtarget.com/dba/free-space-or-mount-points/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 17:20:03 +0000</pubDate>
		<dc:creator>Colin Smith</dc:creator>
				<category><![CDATA[Disk Space]]></category>
		<category><![CDATA[Mount Point]]></category>
		<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Windows Administration]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/dba/free-space-or-mount-points/</guid>
		<description><![CDATA[I had a question about getting free space of mount points on a windows server. The user had some Exchange servers with a huge chunk of san disk attached. Then he mounted drive letters into empty folders on that disk. This gave him multiple mount points on that one volume. Now he wants to be [...]]]></description>
				<content:encoded><![CDATA[<p>I had a question about getting free space of mount points on a windows server. The user had some Exchange servers with a huge chunk of san disk attached. Then he mounted drive letters into empty folders on that disk. This gave him multiple mount points on that one volume. Now he wants to be able to report on each mount point individually. I do not have any servers that have been set up this way and I am out of the office all week. I did find this post in anther forum though.</p>
<p>PS C:\WINDOWS&gt; gwmi win32_volume|where-object {$_.filesystem -match &#8220;ntfs&#8221;}|ft name,capacity,freespace</p>
<p>name capacity freespace</p>
<p>&#8212;- &#8212;&#8212;&#8211; &#8212;&#8212;&#8212;</p>
<p>C:\ 20973137920 12781355008</p>
<p>D:\ 88266911744 30121046016</p>
<p>E:\ 36410552320 11617628160</p>
<p>D:\Mounts\D02\ 1924139716608 1785309392896</p>
<p>D:\Mounts\D03\ 1099506044928 1016254210048</p>
<p>D:\Data\Shared\D01\ 2186130853888 697559801856</p>
<p>And here is a link to the forum that I found it. I have not attempted this as I do not have any servers with this type of mount point but try it and I hope that it works. I am not sure if it will though since win32_logical disk, I do not think it will report like this. I also know that you can try win32_mountpoint and this will get you a list of all your mounts. You may be able to do some work and math using that to figure out the free space. I will try to set this up once I return to the office and see if I can work something out if this does not work.</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/dba/free-space-or-mount-points/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
