tag:blogger.com,1999:blog-7580090655729703212024-03-08T07:16:30.136-05:00My Admin JournalEdhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.comBlogger35125tag:blogger.com,1999:blog-758009065572970321.post-8911248145315736562017-06-27T12:00:00.002-04:002017-06-27T12:00:58.167-04:00Replacement Motherboard causes DC server to not allow login.Recently I had a server that had to have a motherboard replaced. It was a Dell server for anyone who cares. I won't go into the drama around this issue, but basically the Windows Server 2012 was forcing the time on the server. We thought it was the motherboard BIOS doing it but actually it was the Windows OS.<br />
<br />
The main issue here is the would reboot, and the time would be January, 1, 1981, or some weird number.<br />
<br />
Needless to say since this was a Domain Controller and the time from when it was last on and the new time are soooo off, it would not let you log in.<br />
<br />
To fix this, just boot into safe mode, log in, change the time and then reboot the system.<br />
<br />
Problem solved.Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-6526888713853633362017-06-27T11:53:00.005-04:002017-06-27T11:53:54.654-04:00Server 2012 R2 Evaluation won't register<div>
Building new server you run into things sometimes that are annoying or weird. One of those can registration and activation. </div>
<div>
<br /></div>
<div>
Building some new 2012 R2 Standard server and I couldn't register the server. It kept saying the activation code was wrong. </div>
<div>
<br /></div>
<div>
Well there is a VERY easy fix for this. </div>
<div>
<br /></div>
<div>
I found it here.<br />https://social.technet.microsoft.com/Forums/windows/en-US/4211c642-b15d-49ea-8124-f0628aa0f92e/activate-windows-server-2012-evaluation-standard-version-with-a-product-key-oem?forum=winserver8gen&prof=required</div>
<div>
<br /></div>
<div>
Run this code to change it from evaluation.</div>
<div>
<br /></div>
<div>
<div>
<b>DISM /online /Set-Edition:<edition ID> /ProductKey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX /AcceptEula</b></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Change <edition ID> to the edition you have the licence for eg.</div>
<div>
<br /></div>
<div>
<b>DISM /online /Set-Edition:ServerStandard /ProductKey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX /AcceptEula</b></div>
</div>
<div>
<b><br /></b></div>
<div>
You will need to reboot, so keep that in mind. </div>
<div>
<br /></div>
<div>
The one thing that the source where i found this doesn't tell you is, you still need to activate your server with your key. </div>
<div>
<br /></div>
<div>
So go to the Server Manager > Local Server > Properties > Click Activate next to Product ID > Enter your information.</div>
<div>
<br /></div>
<div>
Enjoy.</div>
<div>
<br /></div>
<div>
<br /></div>
Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-34679715561252633072016-12-08T10:16:00.002-05:002016-12-08T10:22:11.295-05:00Fresh Windows 7 install won't update<h2>
Fresh Windows 7 install won't update</h2>
<div>
<br /></div>
<div>
If you have installed a fresh Windows 7 recently you might have run across an issue where it won't finish running Windows Update. It just hangs and runs and churns and seems to never finish. There is a resolution, and it was ultimately found at <a href="https://www.bleepingcomputer.com/forums/t/607544/windows-could-not-search-for-new-updates/" target="_blank">https://www.bleepingcomputer.com/forums/t/607544/windows-could-not-search-for-new-updates/</a>. </div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Here is the resolution and break down of that forum update.</div>
<div>
<br /></div>
<h2>
The Resolution</h2>
<div>
I won't go into why this doesn't work, or how MS screwed up, I will just put the fix here. </div>
<div>
<br /></div>
<div>
<ol>
<li>Install SP1 if you haven't, and restart.<br /><a href="https://www.microsoft.com/en-us/download/details.aspx?id=5842" target="_blank">https://www.microsoft.com/en-us/download/details.aspx?id=5842</a></li>
<li>Install the latest windows update, use Method 2 where you just download and install the update, and restart.<br /><a href="https://support.microsoft.com/en-us/kb/3050265" target="_blank">https://support.microsoft.com/en-us/kb/3050265</a></li>
<li>Install Update for Windows 7 for x64-based Systems (KB3102810), and restart.<br /><a href="https://www.microsoft.com/en-us/download/details.aspx?id=49540" target="_blank">https://www.microsoft.com/en-us/download/details.aspx?id=49540</a></li>
<li>Last install IE 11, and restart.<br /><a href="https://support.microsoft.com/en-us/help/18520/download-internet-explorer-11-offline-installer" target="_blank">https://support.microsoft.com/en-us/help/18520/download-internet-explorer-11-offline-installer</a> </li>
</ol>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
After all the restarts and the installs try and run Windows Update again.<br />
<br />
<b>NOTE it will still take what seems like for ever still, this is because it's downloading over 200 updates to your machine. </b></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Hope this helps. Let me know if this does or doesn't work, I would like to know and I am sure other will also. </div>
Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-5933312875726748642016-02-24T14:28:00.004-05:002016-02-26T09:14:22.106-05:00Quasi-Failover DHCP 2008 R2<div class="MsoNormal">
<span style="color: #1f497d;">I was given a client recently that was running out of IP addresses on their DHCP server. </span></div>
<div class="MsoNormal">
<span style="color: #1f497d;"><br /></span></div>
<div class="MsoNormal">
<span style="color: #1f497d;">After some investigation I discovered that they had 2 DHCP server on the same AD and on the same network. Let say the network is 192.168.1.0, it had a subnet mask of 255.255.0.0. No really it does have that subnet mask. Anyways, the 2 DHCP servers are giving out the same scope of 192.168.1.1 - 192.168.1.254. DHCP1 was giving an exclusion of 192.168.1.1 - 192.168.1.170 and DHCP2 had an exclusion of 192.168.170 - 254. Of course there were other exclusions for servers and printers but you get the point. </span></div>
<div class="MsoNormal">
<span style="color: #1f497d;"><br /></span></div>
<div class="MsoNormal">
<span style="color: #1f497d;">After looking a little bit deeper I noticed that the DHCP1 server was not giving out any leases. This didn't make sense until I fully thought about what was happening here. </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #1f497d;">The reason DHCP2 server was the only one giving out IP addresses is because it is, for lack of a
better term, faster. The reason is because once a machine has made contact with a DHCP server, even
if it’s out of addresses, it will NOT try a different DHCP server. It will keep
trying that same DHCP server for an address. This is why the DHCP1 is not
giving out leases, its to slow to answer. <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #1f497d;">So, since DHCP2 is
always the fastest, it always replies first, even if its full. The one way of
testing, and verifying, this is to turn off the DHCP2 services on DHCP2,
momentarily, and do a request for an address from a device. Then look at DHCP1 to
see if it gave out the address to that device. Of course we tested this and it worked as I expected. <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #1f497d;">Doing an “ipconfig /release” and
then an “ipconfig /renew” on a computer would give you the request needed for
testing. I would not do this on a computer that already has an address that you
need to use to turn the DHCP services back on, maybe do this on a temp PC.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #1f497d;">So basically in this configuration there is a
quasi-failover DHCP system in place. If DHCP2 is offline then DHCP1 would pick up and start handing out addresses. Of course this is not the best way to setup a failover DHCP environment, but, it kinda works. Here is the correct way:</span></div>
<div class="MsoNormal">
<span style="color: #1f497d;"> <a href="https://technet.microsoft.com/en-us/library/hh831385.aspx">https://technet.microsoft.com/en-us/library/hh831385.aspx</a></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #1f497d;">I hope this helps someone in their endeavour of trying to figure out why a DHCP might not be giving out leases. </span></div>
Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-49471593592214122582016-02-24T12:29:00.003-05:002016-02-24T12:30:15.485-05:00New-MailboxExportRequest not recognizedIf you go and try to use New-MailboxExportRequest and get "<i><b>New-MailboxExportRequest' is not recognized as the name of a cmdlet</b></i>. That's because your user is not part of the ManagementRole.<br />
<br />
To fix this run the below command in PowerShell from the Exchange server.<br />
<br />
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">New-ManagementRoleAssignment</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: navy;">-Role</span> <span style="color: darkred;">"Mailbox
Import Export"</span> <span style="color: navy;">-user</span> <span style="color: blueviolet;">UserName</span></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "lucida console"; font-size: 9.0pt;"><span style="color: blueviolet;"><br /></span></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<span style="background-color: white; color: blueviolet; font-family: "lucida console"; font-size: 12px;">UserName </span>is the that you are using to run the command new-mailboxexportrequest.<br />
<br />
Log out then log back in and you should be fine to to go.<br />
<br />
<br />
<i><span style="color: #999999;"><br /></span></i>
<i><span style="color: #999999;">Solution found at:<br /><a href="https://social.technet.microsoft.com/Forums/exchange/en-US/d6bbff4b-8be0-4b4f-925d-1c5db5c31cc4/newmailboxexportrequest-is-not-recognized-as-the-name-of-a-cmdlet?forum=exchangesvrgenerallegacy">https://social.technet.microsoft.com/Forums/exchange/en-US/d6bbff4b-8be0-4b4f-925d-1c5db5c31cc4/newmailboxexportrequest-is-not-recognized-as-the-name-of-a-cmdlet?forum=exchangesvrgenerallegacy </a></span></i>Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-76584381385795400802016-02-08T09:59:00.003-05:002016-02-08T09:59:24.801-05:00Trojan-Downloader.Win32.VB.eql (Translated)<h2 id="TechnicalDetails" style="background-color: white; box-sizing: border-box; margin: 0px 0px 1.6rem; padding: 0px; text-rendering: optimizeLegibility;">
<span style="color: #006d55; font-family: LGMedium, Arial Narrow Bold, Arial, Helvetica, sans-serif;"><span style="font-size: 51.2px; line-height: 49.152px;">Trojan-Downloader.Win32.VB.eql</span></span></h2>
<span style="color: #006d55; font-family: LGMedium, Arial Narrow Bold, Arial, Helvetica, sans-serif;"><span style="line-height: 49.152px;"><br /></span></span><span style="color: #006d55; font-family: LGMedium, Arial Narrow Bold, Arial, Helvetica, sans-serif;"><span style="line-height: 49.152px;">Translated from<br />https://securelist.social-kaspersky.com/ru/descriptions/Trojan-Downloader.Win32.VB.eql </span></span><br />
<span style="color: #006d55; font-family: LGMedium, Arial Narrow Bold, Arial, Helvetica, sans-serif;"><span style="font-size: 51.2px; line-height: 49.152px;"><br /></span></span>
<h2 id="TechnicalDetails" style="background-color: white; box-sizing: border-box; color: #006d55; font-family: LGMedium, 'Arial Narrow Bold', Arial, Helvetica, sans-serif; font-size: 3.2rem; line-height: 1.2; margin: 0px 0px 1.6rem; padding: 0px; text-rendering: optimizeLegibility;">
<span style="box-sizing: border-box;">Technical details</span></h2>
<h2 id="RemovalInstructions" style="background-color: white; box-sizing: border-box; color: #006d55; font-family: LGMedium, 'Arial Narrow Bold', Arial, Helvetica, sans-serif; font-size: 3.2rem; line-height: 1.2; margin: 0px 0px 1.6rem; padding: 0px; text-rendering: optimizeLegibility;">
<span style="box-sizing: border-box;"><div style="box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; line-height: 1.7rem; margin-bottom: 10px; padding: 0px; word-wrap: break-word;">
<span style="box-sizing: border-box;"><span style="box-sizing: border-box;">This Trojan downloads without your knowledge on your computer other software. </span><span style="box-sizing: border-box;">The program is a Windows application (PE EXE-file). </span><span style="box-sizing: border-box;">Its size is 1509125 bytes.</span></span></div>
</span></h2>
<h3 style="background-color: white; box-sizing: border-box; color: #006d55; font-family: LGMedium, 'Arial Narrow Bold', Arial, Helvetica, sans-serif; font-size: 2.6rem; line-height: 1.2; margin: 0px 0px 1.6rem; padding: 0px; text-rendering: optimizeLegibility;">
<span style="box-sizing: border-box;">Installation</span></h3>
<h2 style="background-color: white; box-sizing: border-box; color: #006d55; font-family: LGMedium, 'Arial Narrow Bold', Arial, Helvetica, sans-serif; font-size: 3.2rem; line-height: 1.2; margin: 0px 0px 1.6rem; padding: 0px; text-rendering: optimizeLegibility;">
<span style="box-sizing: border-box;"><div style="box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; line-height: 1.7rem; margin-bottom: 10px; padding: 0px; word-wrap: break-word;">
<span style="box-sizing: border-box;"><span style="box-sizing: border-box;">Once launched, the Trojan copies its body to the Windows system directory under the name "WINSP00L.EXE":</span></span></div>
<pre style="background: rgb(51, 51, 51); box-sizing: border-box; color: red; font-family: 'Courier New', Courier, Verdana; font-size: 13px; font-stretch: normal; font-weight: normal; line-height: 1.4; margin-bottom: 1em; overflow: auto; padding: 0px;"><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">% System% \ WINSP00L.EXE</span></span></pre>
<span style="box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; line-height: 21.125px;"><span style="box-sizing: border-box;">To start automatically each time you start the system, the Trojan adds a link to its executable file in the system registry:</span></span><pre style="background: rgb(51, 51, 51); box-sizing: border-box; color: red; font-family: 'Courier New', Courier, Verdana; font-size: 13px; font-stretch: normal; font-weight: normal; line-height: 1.4; margin-bottom: 1em; overflow: auto; padding: 0px;"><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">[HKLM \ Software \ Microsoft \ Windows \ CurrentVersion \ Run]</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
"WINSP00L" = "% System% \ WINSP00L.EXE"</span></span></pre>
</span></h2>
<h2 id="Payload" style="background-color: white; box-sizing: border-box; color: #006d55; font-family: LGMedium, 'Arial Narrow Bold', Arial, Helvetica, sans-serif; font-size: 3.2rem; line-height: 1.2; margin: 0px 0px 1.6rem; padding: 0px; text-rendering: optimizeLegibility;">
<span style="box-sizing: border-box;">Load</span></h2>
<h2 style="background-color: white; box-sizing: border-box; color: #006d55; font-family: LGMedium, 'Arial Narrow Bold', Arial, Helvetica, sans-serif; font-size: 3.2rem; line-height: 1.2; margin: 0px 0px 1.6rem; padding: 0px; text-rendering: optimizeLegibility;">
<span style="box-sizing: border-box;"><div style="box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; line-height: 1.7rem; margin-bottom: 10px; padding: 0px; word-wrap: break-word;">
<span style="box-sizing: border-box;"><span style="box-sizing: border-box;">Once launched, the Trojan extracts from its body to the catalog "E_4" in the temporary directory of the current user the following files:</span></span></div>
<pre style="background: rgb(51, 51, 51); box-sizing: border-box; color: red; font-family: 'Courier New', Courier, Verdana; font-size: 13px; font-stretch: normal; font-weight: normal; line-height: 1.4; margin-bottom: 1em; overflow: auto; padding: 0px;"><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">% Temp% \ E_4 \ krnln.fnr - 1110016 bytes</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
% Temp% \ E_4 \ shell.fne - 61440 bytes</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
% Temp% \ E_4 \ eAPI.fne - 335872 bytes</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
% Temp% \ E_4 \ internet.fne - 196608 bytes</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
% Temp% \ E_4 \ spec.fne - 86016 bytes</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
% Temp% \ E_4 \ RegEx.fne - 167936 bytes</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
% Temp% \ E_4 \ dp1.fne - 126,976 bytes</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
% Temp% \ E_4 \ com.run - 278528 bytes</span></span></pre>
<span style="box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; line-height: 21.125px;"><span style="box-sizing: border-box;">Then copy them to the Windows system directory under the same name:</span></span><pre style="background: rgb(51, 51, 51); box-sizing: border-box; color: red; font-family: 'Courier New', Courier, Verdana; font-size: 13px; font-stretch: normal; font-weight: normal; line-height: 1.4; margin-bottom: 1em; overflow: auto; padding: 0px;"><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">% System% \ krnln.fnr</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
% System% \ shell.fne</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
% System% \ eAPI.fne</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
% System% \ internet.fne</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
% System% \ spec.fne</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
% System% \ RegEx.fne</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
% System% \ dp1.fne</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
% System% \ com.run</span></span></pre>
<span style="box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; line-height: 21.125px;"><span style="box-sizing: border-box;">In addition, it removes the Windows system directory files:</span></span><pre style="background: rgb(51, 51, 51); box-sizing: border-box; color: red; font-family: 'Courier New', Courier, Verdana; font-size: 13px; font-stretch: normal; font-weight: normal; line-height: 1.4; margin-bottom: 1em; overflow: auto; padding: 0px;"><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">% System% \ ul.dll - 2404 bytes</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
% System% \ og.dll - 692 bytes</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
% System% \ og.edt - 512 bytes</span></span></pre>
<span style="box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; line-height: 21.125px;"><span style="box-sizing: border-box;">After completing these steps, the Trojan accesses the following address:</span></span><pre style="background: rgb(51, 51, 51); box-sizing: border-box; color: red; font-family: 'Courier New', Courier, Verdana; font-size: 13px; font-stretch: normal; font-weight: normal; line-height: 1.4; margin-bottom: 1em; overflow: auto; padding: 0px;"><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">http: //www.*****base.cn/install.htm pn = M080410?</span></span></pre>
<span style="box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; line-height: 21.125px;"><span style="box-sizing: border-box;">At the time of writing, this link was not working. </span><span style="box-sizing: border-box;">The file is located on this link is stored in the temporary Internet files directory and launched for execution. </span><span style="box-sizing: border-box;">Filename - random. </span><span style="box-sizing: border-box;">And also drawn to the following address:</span></span><pre style="background: rgb(51, 51, 51); box-sizing: border-box; color: red; font-family: 'Courier New', Courier, Verdana; font-size: 13px; font-stretch: normal; font-weight: normal; line-height: 1.4; margin-bottom: 1em; overflow: auto; padding: 0px;"><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">http://www.microsoft.com</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
http://hi.baidu.com/siletoyou</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
http://www.baihe.googlepages.com/ul.htm</span></span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">
http://www.bloguser.googlepages.com/au.htm</span></span></pre>
<span style="box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; line-height: 21.125px;"><span style="box-sizing: border-box;">After that, remove the file from its body with a name composed of the current date and time, for example 20090929153554.exe and places it in the Windows system directory:</span></span><pre style="background: rgb(51, 51, 51); box-sizing: border-box; color: red; font-family: 'Courier New', Courier, Verdana; font-size: 13px; font-stretch: normal; font-weight: normal; line-height: 1.4; margin-bottom: 1em; overflow: auto; padding: 0px;"><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">% System% \ 20090929153554.exe</span></span></pre>
<span style="box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; line-height: 21.125px;"><span style="box-sizing: border-box;">This file has a size of 9216 bytes. </span></span><br style="box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; line-height: 21.125px;" /><span style="box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; line-height: 21.125px;"><span style="box-sizing: border-box;">The extracted file gets executed and then deleted. </span></span><br style="box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; line-height: 21.125px;" /><span style="box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; line-height: 21.125px;"><span style="box-sizing: border-box;">In addition, the Trojan spreads via removable media under the name "Recycled.exe". </span><span style="box-sizing: border-box;">"Autorun.inf" file is also created to automatically run the Trojan file in the root directory of removable media.</span></span></span></h2>
<div>
<span style="box-sizing: border-box;"><span style="box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal; line-height: 21.125px;"><span style="box-sizing: border-box;"><br /></span></span></span></div>
<h2 id="RemovalInstructions" style="background-color: white; box-sizing: border-box; color: #006d55; font-family: LGMedium, 'Arial Narrow Bold', Arial, Helvetica, sans-serif; font-size: 3.2rem; line-height: 1.2; margin: 0px 0px 1.6rem; padding: 0px; text-rendering: optimizeLegibility;">
<span style="box-sizing: border-box;">Removal Instructions</span></h2>
<div style="background-color: white; box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.7rem; margin-bottom: 10px; padding: 0px; word-wrap: break-word;">
<span style="box-sizing: border-box;">If your PC was not protected by Antivirus and got infected with this malware, then remove it, proceed as follows:</span></div>
<ol style="background-color: white; box-sizing: border-box; color: #666666; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 21.125px; margin: 0px 0px 12px 24px; padding: 0px;">
<li style="box-sizing: border-box;"><span style="box-sizing: border-box;">Using </span><a href="http://support.kaspersky.ru/faq/?qid=208635583" style="box-sizing: border-box; color: #666666; font-size: 1.3rem; outline: 0px; padding: 0px 0px 20px; text-decoration: none; transition: all 0.1s ease-in-out;" target="blank"><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">Task Manager to</span></span></a><span style="box-sizing: border-box;"> terminate the Trojan process:</span><pre style="background: rgb(51, 51, 51); box-sizing: border-box; color: red; font-family: 'Courier New', Courier, Verdana; font-stretch: normal; line-height: 1.4; margin-bottom: 1em; overflow: auto; padding: 0px;"><span style="box-sizing: border-box;">WINSP00L.EXE</span></pre>
</li>
<li style="box-sizing: border-box;"><span style="box-sizing: border-box;">Delete the original Trojan file (its location on the infected computer will depend on how the program originally penetrated the victim machine).</span></li>
<li style="box-sizing: border-box;"><span style="box-sizing: border-box;">Delete the copy of the Trojan:</span><pre style="background: rgb(51, 51, 51); box-sizing: border-box; color: red; font-family: 'Courier New', Courier, Verdana; font-stretch: normal; line-height: 1.4; margin-bottom: 1em; overflow: auto; padding: 0px;"><span style="box-sizing: border-box;">% System% \ WINSP00L.EXE</span></pre>
</li>
<li style="box-sizing: border-box;"><span style="box-sizing: border-box;">Remove files and directories created by the Trojan:</span><pre style="background: rgb(51, 51, 51); box-sizing: border-box; color: red; font-family: 'Courier New', Courier, Verdana; font-stretch: normal; line-height: 1.4; margin-bottom: 1em; overflow: auto; padding: 0px;"><span style="box-sizing: border-box;">% Temp% \ E_4 \ krnln.fnr</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% Temp% \ E_4 \ shell.fne</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% Temp% \ E_4 \ eAPI.fne</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% Temp% \ E_4 \ internet.fne</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% Temp% \ E_4 \ spec.fne</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% Temp% \ E_4 \ RegEx.fne</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% Temp% \ E_4 \ dp1.fne</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% Temp% \ E_4 \ com.run</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% Temp% \ E_4</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% System% \ krnln.fnya</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% System% \ shell.fne</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% System% \ eAPI.fne</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% System% \ internet.fne</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% System% \ spec.fne</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% System% \ RegEx.fne</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% System% \ dp1.fne</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% System% \ com.run</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% System% \ ul.dll</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% System% \ og.dll</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
% System% \ og.edt</span></pre>
<div style="box-sizing: border-box; font-size: 1.3rem; line-height: 1.7rem; margin-bottom: 10px; padding: 0px; word-wrap: break-word;">
<span style="box-sizing: border-box;">Remove key </span><a href="http://support.kaspersky.ru/faq/?qid=208635566" style="box-sizing: border-box; color: #666666; font-size: 1.3rem; outline: 0px; padding: 0px 0px 20px; text-decoration: none; transition: all 0.1s ease-in-out;" target="blank"><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">registry</span></span></a><span style="box-sizing: border-box;"> :</span></div>
<pre style="background: rgb(51, 51, 51); box-sizing: border-box; color: red; font-family: 'Courier New', Courier, Verdana; font-stretch: normal; line-height: 1.4; margin-bottom: 1em; overflow: auto; padding: 0px;"><span style="box-sizing: border-box;">[HKLM \ Software \ Microsoft \ Windows \ CurrentVersion \ Run]</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
"WINSP00L" = "% System% \ WINSP00L.EXE"</span></pre>
</li>
<li style="box-sizing: border-box;"><span style="box-sizing: border-box;">Check removable media for files:</span><pre style="background: rgb(51, 51, 51); box-sizing: border-box; color: red; font-family: 'Courier New', Courier, Verdana; font-stretch: normal; line-height: 1.4; margin-bottom: 1em; overflow: auto; padding: 0px;"><span style="box-sizing: border-box;">Recycled.exe</span><span style="box-sizing: border-box;"></span><span style="box-sizing: border-box;">
autorun.inf</span></pre>
<span style="box-sizing: border-box;">In case of detection - remove them.</span></li>
<li style="box-sizing: border-box;"><span style="box-sizing: border-box;">Clear Temporary Internet Files directory, containing infected files ( </span><a href="http://support.kaspersky.ru/viruses/solutions?qid=180593120" style="box-sizing: border-box; color: #666666; font-size: 1.3rem; outline: 0px; padding: 0px 0px 20px; text-decoration: none; transition: all 0.1s ease-in-out;"><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">How to delete infected files from Temporary Internet Files folder?</span></span></a><span style="box-sizing: border-box;"> ):</span></li>
<li style="box-sizing: border-box;"><span style="box-sizing: border-box;">And perform a full scan of your computer with Kaspersky Antivirus Update your antivirus databases ( </span><a href="http://www.kaspersky.ru/trials" style="box-sizing: border-box; color: #666666; font-size: 1.3rem; outline: 0px; padding: 0px 0px 20px; text-decoration: none; transition: all 0.1s ease-in-out;"><span style="box-sizing: border-box;"><span style="box-sizing: border-box;">download a trial version</span></span></a><span style="box-sizing: border-box;"> ).</span></li>
</ol>
Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-69595480778686946602016-02-02T10:58:00.000-05:002016-02-02T10:58:46.318-05:00Robocopy to the backup rescue<h2>
Robocopy to the backup rescue</h2>
<div>
<br /></div>
<div>
So recently I had a client that had a SBS 2008 box that had a RAID issue. It had what known as a Punctured RAID , I will call it PR in this post. You can more on that here: <a href="http://www.dell.com/support/Article/us/en/04/438291/EN">http://www.dell.com/support/Article/us/en/04/438291/EN</a>. The wonderful thing about a PR is they rear their ugly head till its too late. Well this client was too late. <br />
<br />
The main reason I found out about this PR is that this clients Backup Exec kept failing. After fighting with the Backup Exec for over a week I finally found in the error logs something about this PR. This is what was making the Backup Exec fail. I could get into a lengthy discussion on this and at some point in time I might do that. </div>
<div>
<br /></div>
<div>
Needless to say because we couldn't use anything we threw at this server to back it up with out failing, and we tried a lot of options, I decided to use robocopy to try and keep at least a file level backup running for this server till we came up with a final solution for this issue. </div>
<div>
<br /></div>
<div>
So this is the script I ended up making. I ran this as a nightly scheduled task with System user privileges. </div>
<div>
<br /></div>
<div>
I know the script is kinda hacky and could be written better and more efficiently but it has a lot going on in it and I wanted to share. </div>
<div>
<br /></div>
<div>
So basically it stops some services, robocopys files to an external drive then starts the services back up. </div>
<div>
<br /></div>
<div>
With the mir option in the robocopy it made the copy very fast every night because it only grabbed what had been modified.</div>
<div>
<br /></div>
<div>
I used "net stop" and "net start" for some of the services.</div>
<div>
I also used Powershell command Stop-Service and Start-Services to start/start other services.</div>
<div>
<br /></div>
<div>
I broke out the main directories in the c: drive so that i could log what was happening in each directory when the robocopy ran.</div>
<div>
In the robocopy sections I used the options:</div>
<div>
/MIR :: MIRror a directory tree (equivalent to /E plus /PURGE).</div>
<div>
/XJD :: eXclude Junction points for Directories.</div>
<div>
<div>
/R:n :: number of Retries on failed copies: default 1 million.</div>
<div>
/W:n :: Wait time between retries: default is 30 seconds.</div>
</div>
<div>
/TEE :: output to console window, as well as the log file</div>
<div>
/LOG:file :: output status to LOG file (overwrite existing log).</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">net</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: blueviolet;">stop</span>
<span style="color: blueviolet;">msexchangeadtopology</span> <span style="color: blueviolet;">/y</span> <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">net</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: blueviolet;">stop</span>
<span style="color: blueviolet;">msftesql-exchange</span> <span style="color: blueviolet;">/y</span> <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">net</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: blueviolet;">stop</span>
<span style="color: blueviolet;">msexchangeis</span> <span style="color: blueviolet;">/y</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">net</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: blueviolet;">stop</span>
<span style="color: blueviolet;">msexchangesa</span> <span style="color: blueviolet;">/y</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">net</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: blueviolet;">stop</span>
<span style="color: blueviolet;">iisadmin</span> <span style="color: blueviolet;">/y</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">PowerShell.exe</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: navy;">-Command</span>
<span style="color: darkred;">"Stop-Service *sql* -Force"</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "lucida console"; font-size: 9.0pt;"><span style="color: darkred;"><br /></span></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "lucida console"; font-size: 9.0pt;"><span style="color: darkred;"><br /></span></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "lucida console"; font-size: 9.0pt;"><span style="color: darkred;"><br /></span></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">robocopy</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: darkred;">"c:\Boot"</span> <span style="color: darkred;">"F:\Backuprobocopy\Boot"</span>
<span style="color: blueviolet;">/MIR</span> <span style="color: blueviolet;">/XJD</span> <span style="color: blueviolet;">/w:1</span> <span style="color: blueviolet;">/r:1</span> <span style="color: blueviolet;">/V</span> <span style="color: blueviolet;">/tee</span> <span style="color: blueviolet;">/log:"f:\backuprobocopyBoot.log"</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">robocopy</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: darkred;">"c:\dell"</span> <span style="color: darkred;">"F:\Backuprobocopy\dell"</span>
<span style="color: blueviolet;">/MIR</span> <span style="color: blueviolet;">/XJD</span> <span style="color: blueviolet;">/w:1</span> <span style="color: blueviolet;">/r:1</span> <span style="color: blueviolet;">/V</span> <span style="color: blueviolet;">/tee</span> <span style="color: blueviolet;">/log:"f:\backuprobocopydell.log"</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">robocopy</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: darkred;">"c:\drivers"</span> <span style="color: darkred;">"F:\Backuprobocopy\drivers"</span>
<span style="color: blueviolet;">/MIR</span> <span style="color: blueviolet;">/XJD</span> <span style="color: blueviolet;">/w:1</span> <span style="color: blueviolet;">/r:1</span> <span style="color: blueviolet;">/V</span> <span style="color: blueviolet;">/tee</span> <span style="color: blueviolet;">/log:"f:\backuprobocopydrivers.log"</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">robocopy</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: darkred;">"c:\ExchangeSetupLogs"</span> <span style="color: darkred;">"F:\Backuprobocopy\ExchangeSetupLogs"</span>
<span style="color: blueviolet;">/MIR</span> <span style="color: blueviolet;">/XJD</span> <span style="color: blueviolet;">/w:1</span> <span style="color: blueviolet;">/r:1</span> <span style="color: blueviolet;">/V</span> <span style="color: blueviolet;">/tee</span> <span style="color: blueviolet;">/log:"f:\backuprobocopyExchangeSetupLogs.log"</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">robocopy</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: darkred;">"c:\inetpub"</span> <span style="color: darkred;">"F:\Backuprobocopy\inetpub"</span>
<span style="color: blueviolet;">/MIR</span> <span style="color: blueviolet;">/XJD</span> <span style="color: blueviolet;">/w:1</span> <span style="color: blueviolet;">/r:1</span> <span style="color: blueviolet;">/V</span> <span style="color: blueviolet;">/tee</span> <span style="color: blueviolet;">/log:"f:\backuprobocopyinetpub.log"</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">robocopy</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: darkred;">"c:\OpenManage"</span> <span style="color: darkred;">"F:\Backuprobocopy\OpenManage"</span>
<span style="color: blueviolet;">/MIR</span> <span style="color: blueviolet;">/XJD</span> <span style="color: blueviolet;">/w:1</span> <span style="color: blueviolet;">/r:1</span> <span style="color: blueviolet;">/V</span> <span style="color: blueviolet;">/tee</span> <span style="color: blueviolet;">/log:"f:\backuprobocopyOpenManage.log"</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">robocopy</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: darkred;">"c:\PerfLogs"</span> <span style="color: darkred;">"F:\Backuprobocopy\PerfLogs"</span>
<span style="color: blueviolet;">/MIR</span> <span style="color: blueviolet;">/XJD</span> <span style="color: blueviolet;">/w:1</span> <span style="color: blueviolet;">/r:1</span> <span style="color: blueviolet;">/V</span> <span style="color: blueviolet;">/tee</span> <span style="color: blueviolet;">/log:"f:\backuprobocopyPerfLogs.log"</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">robocopy</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: darkred;">"c:\Program
Files"</span> <span style="color: darkred;">"F:\Backuprobocopy\Program Files"</span> <span style="color: blueviolet;">/MIR</span> <span style="color: blueviolet;">/XJD</span> <span style="color: blueviolet;">/w:1</span> <span style="color: blueviolet;">/r:1</span> <span style="color: blueviolet;">/V</span> <span style="color: blueviolet;">/tee</span> <span style="color: blueviolet;">/log:"f:\backuprobocopyProgram
Files.log"</span> <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">robocopy</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: darkred;">"c:\Program
Files (x86)"</span> <span style="color: darkred;">"F:\Backuprobocopy\Program Files (x86)"</span> <span style="color: blueviolet;">/MIR</span> <span style="color: blueviolet;">/XJD</span> <span style="color: blueviolet;">/w:1</span> <span style="color: blueviolet;">/r:1</span> <span style="color: blueviolet;">/V</span> <span style="color: blueviolet;">/tee</span> <span style="color: blueviolet;">/log:"f:\backuprobocopyProgram
Files (x86).log"</span> <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">robocopy</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: darkred;">"c:\ProgramData"</span> <span style="color: darkred;">"F:\Backuprobocopy\ProgramData"</span>
<span style="color: blueviolet;">/MIR</span> <span style="color: blueviolet;">/XJD</span> <span style="color: blueviolet;">/w:1</span> <span style="color: blueviolet;">/r:1</span> <span style="color: blueviolet;">/V</span> <span style="color: blueviolet;">/tee</span> <span style="color: blueviolet;">/log:"f:\backuprobocopyProgramData.log"</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">robocopy</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: darkred;">"c:\Scripts"</span> <span style="color: darkred;">"F:\Backuprobocopy\Scripts"</span>
<span style="color: blueviolet;">/MIR</span> <span style="color: blueviolet;">/XJD</span> <span style="color: blueviolet;">/w:1</span> <span style="color: blueviolet;">/r:1</span> <span style="color: blueviolet;">/V</span> <span style="color: blueviolet;">/tee</span> <span style="color: blueviolet;">/log:"f:\backuprobocopyScripts.log"</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">robocopy</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: darkred;">"c:\Shared
Data"</span> <span style="color: darkred;">"F:\Backuprobocopy\Shared Data"</span> <span style="color: blueviolet;">/MIR</span> <span style="color: blueviolet;">/XJD</span> <span style="color: blueviolet;">/w:1</span> <span style="color: blueviolet;">/r:1</span>
<span style="color: blueviolet;">/V</span> <span style="color: blueviolet;">/tee</span>
<span style="color: blueviolet;">/log:"f:\backuprobocopyShared
Data.log"</span> <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">robocopy</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: darkred;">"c:\Users"</span> <span style="color: darkred;">"F:\Backuprobocopy\Users"</span>
<span style="color: blueviolet;">/MIR</span> <span style="color: blueviolet;">/XJD</span> <span style="color: blueviolet;">/w:1</span> <span style="color: blueviolet;">/r:1</span> <span style="color: blueviolet;">/V</span> <span style="color: blueviolet;">/tee</span> <span style="color: blueviolet;">/log:"f:\backuprobocopyUsers.log"</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">robocopy</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: darkred;">"c:\Windows"</span> <span style="color: darkred;">"F:\Backuprobocopy\Windows"</span>
<span style="color: blueviolet;">/MIR</span> <span style="color: blueviolet;">/XJD</span> <span style="color: blueviolet;">/w:1</span> <span style="color: blueviolet;">/r:1</span> <span style="color: blueviolet;">/V</span> <span style="color: blueviolet;">/tee</span> <span style="color: blueviolet;">/log:"f:\backuprobocopyWindows.log"</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">rem</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: blueviolet;">robocopy</span>
<span style="color: darkred;">"c:\WSUS"</span> <span style="color: darkred;">"F:\Backuprobocopy\WSUS"</span>
<span style="color: blueviolet;">/MIR</span> <span style="color: blueviolet;">/XJD</span> <span style="color: blueviolet;">/w:1</span> <span style="color: blueviolet;">/r:1</span> <span style="color: blueviolet;">/V</span> <span style="color: blueviolet;">/tee</span> <span style="color: blueviolet;">/log:"f:\backuprobocopyWSUS.log"</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "lucida console"; font-size: 9.0pt;"><br /></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "lucida console"; font-size: 9.0pt;"><br /></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">net</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: blueviolet;">start</span>
<span style="color: blueviolet;">msexchangeadtopology</span> <span style="color: blueviolet;">/y</span> <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">net</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: blueviolet;">start</span>
<span style="color: blueviolet;">msftesql-exchange</span> <span style="color: blueviolet;">/y</span> <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">net</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: blueviolet;">start</span>
<span style="color: blueviolet;">msexchangeis</span> <span style="color: blueviolet;">/y</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">net</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: blueviolet;">start</span>
<span style="color: blueviolet;">msexchangesa</span> <span style="color: blueviolet;">/y</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">net</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: blueviolet;">start</span>
<span style="color: blueviolet;">iisadmin</span> <span style="color: blueviolet;">/y</span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">PowerShell.exe</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: navy;">-Command</span>
<span style="color: darkred;">"Start-Service -name """</span><span style="color: blueviolet;">MSsql*""" "</span></span><span style="font-family: "lucida console"; font-size: 9pt;"> </span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9.0pt;">PowerShell.exe</span><span style="font-family: "lucida console"; font-size: 9.0pt;"> <span style="color: navy;">-Command</span>
<span style="color: darkred;">"Start-Service -name """</span><span style="color: blueviolet;">MSExchange*""" "</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "lucida console"; font-size: 9pt;">PowerShell.exe</span><span style="font-family: "lucida console"; font-size: 9pt;"> <span style="color: navy;">-Command</span>
<span style="color: darkred;">"Start-Service -name """</span><span style="color: blueviolet;">BackupExec*""" "</span></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal">
<br /></div>
</div>
<div>
<br /></div>
<div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
</div>
Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-66829043065132035932016-01-14T10:29:00.000-05:002016-01-14T10:29:14.262-05:00Get Exchange Server Database Size and Mailbox Size<h2>
Get Exchange Server Database Size and Mailbox Size</h2>
<div>
<br /></div>
<div>
This is something you would be simple, and it is, if you know the commands. Unfortunately if you have an Exchange 2007 it is different than a 2010. </div>
<div>
<br /></div>
<div>
In my environment I have both so my script decides which it is and spits out the report for 2007 or 2010. </div>
<div>
<br /></div>
<div>
One of the reasons I am writing this is to DRILL into my head that these scripts MUST be run as administrator, not run by an administrator.. I mean Right Click the powershell and "Run As Administrator". If you do not run as administrator your database will return 0. Yes it returns 0. </div>
<div>
<br /></div>
<div>
So.. here is the script. Enjoy. </div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">Get-MailboxStatistics</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: navy;">-Server</span> <span style="color: orangered;">$env:computername</span>
<span style="color: darkgrey;">|</span> <span style="color: blue;">Select</span> <span style="color: blueviolet;">DisplayName</span><span style="color: darkgrey;">,</span>
<span style="color: blueviolet;">ItemCount</span><span style="color: darkgrey;">,</span>
<span style="color: blueviolet;">TotalItemSize</span> <span style="color: darkgrey;">|</span>
<span style="color: blue;">Sort-Object</span> <span style="color: blueviolet;">TotalItemSize</span>
<span style="color: navy;">-Descending</span> <span style="color: darkgrey;">|</span>
<span style="color: blue;">Export-CSV</span> <span style="color: blueviolet;">C:\temp\MBSizes.csv</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: orangered; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">$TheVersion</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkgrey;">=</span> <span style="color: blue;">Get-ExchangeServer</span>
<span style="color: darkgrey;">|</span> <span style="color: blue;">select</span> <span style="color: blueviolet;">*</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: darkblue; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">if</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> (<span style="color: orangered;">$TheVersion</span><span style="color: darkgrey;">.</span>AdminDisplayVersion<span style="color: darkgrey;">.</span>major
<span style="color: darkgrey;">-like</span> <span style="color: darkred;">"14"</span>){<span style="color: orangered;">$version14</span> <span style="color: darkgrey;">=</span>
<span style="color: darkred;">"yes"</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: blue;">Get-MailboxDatabase</span>
<span style="color: navy;">-Status</span> <span style="color: darkgrey;">|</span> <span style="color: blue;">select</span> <span style="color: blueviolet;">ServerName</span><span style="color: darkgrey;">,</span><span style="color: blueviolet;">Name</span><span style="color: darkgrey;">,</span><span style="color: blueviolet;">DatabaseSize</span>
<span style="color: darkgrey;">|</span> <span style="color: blue;">Export-CSV</span>
<span style="color: blueviolet;">C:\temp\DBSize.csv</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">}<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: darkblue; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">else</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: blue;">Get-MailboxDatabase</span>
<span style="color: darkgrey;">|</span> <span style="color: blue;">foreach-object</span>
{<span style="color: blue;">add-member</span> <span style="color: navy;">-inputobject</span>
<span style="color: orangered;">$_</span> <span style="color: navy;">-membertype</span>
<span style="color: blueviolet;">noteproperty</span> <span style="color: navy;">-name</span>
<span style="color: blueviolet;">mailboxdbsizeinGB</span> <span style="color: navy;">-value</span> (<span style="color: darkgrey;">[</span><span style="color: teal;">math</span><span style="color: darkgrey;">]::</span>Round((<span style="color: darkgrey;">[</span><span style="color: teal;">int64</span><span style="color: darkgrey;">]</span>(<span style="color: blue;">get-wmiobject</span> <span style="color: blueviolet;">cim_datafile</span> <span style="color: navy;">-computername</span>
<span style="color: orangered;">$_</span><span style="color: darkgrey;">.</span>server
<span style="color: navy;">-filter</span> (<span style="color: darkred;">'name='''</span>
<span style="color: darkgrey;">+</span> <span style="color: orangered;">$_</span><span style="color: darkgrey;">.</span>edbfilepath<span style="color: darkgrey;">.</span>pathname<span style="color: darkgrey;">.</span>replace(<span style="color: darkred;">"\"</span><span style="color: darkgrey;">,</span><span style="color: darkred;">"\\"</span>)
<span style="color: darkgrey;">+</span> <span style="color: darkred;">''''</span>))<span style="color: darkgrey;">.</span>filesize <span style="color: darkgrey;">/</span> <span style="color: purple;">1GB</span>)<span style="color: darkgrey;">,</span><span style="color: purple;">2</span>)) <span style="color: navy;">-passthru</span>} <span style="color: darkgrey;">|</span> <span style="color: blue;">Sort-Object</span> <span style="color: blueviolet;">mailboxdbsizeinGB</span>
<span style="color: navy;">-Descending</span> <span style="color: darkgrey;">|</span>
<span style="color: blue;">select</span> <span style="color: blueviolet;">identity</span><span style="color: darkgrey;">,</span><span style="color: blueviolet;">mailboxdbsizeinGB</span>
<span style="color: darkgrey;">|</span> <span style="color: blue;">Export-CSV</span>
<span style="color: navy;">-NoTypeInformation</span> <span style="color: blueviolet;">C:\temp\DBSize.csv</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">}<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal">
<br /></div>
</div>
Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-26723088457408585662015-10-16T10:27:00.002-04:002015-10-16T10:27:40.325-04:00Download MP3s with PowershellSo I found a site with some MP3s that I wanted but didn't want to download but didn't want to right click.. Save as.. blah blah.. so after some searching and modifing some scripts i made this.<br />
<br />
<br />
Change the 2 variables <span style="color: orangered; font-family: 'Lucida Console'; font-size: 9pt; line-height: 107%;">$theurl</span> ; the website URL, and <span style="color: orangered; font-family: 'Lucida Console'; font-size: 9pt; line-height: 107%;">$storagedir</span> ; the place you want to store them and watch it go. It has some thing built into it that takes care of url variables, direct url, and some url encoding issues. I tried to comment it as much as I could.<br />
<br />
<br />
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: darkgreen; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">#
=================================================================================</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: darkgreen; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"># =
=</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: darkgreen; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"># = Variables to change. Begin =</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: darkgreen; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"># =
=</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: darkgreen; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">#
=================================================================================</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: orangered; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">$theurl</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkgrey;">=</span> <span style="color: darkred;">"http://www.sky-animes.com/music/LQ/7185"</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: orangered; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">$storagedir</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkgrey;">=</span> <span style="color: darkred;">"C:\source\mp3\FullMetal"</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: darkgreen; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">#
=================================================================================</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: darkgreen; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"># =
=</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: darkgreen; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"># = Variables to change. End =</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: darkgreen; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"># =
=</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: darkgreen; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">#
=================================================================================</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: orangered; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">$response</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkgrey;">=</span> <span style="color: blue;">Invoke-WebRequest</span> <span style="color: navy;">-Uri</span>
<span style="color: orangered;">$theurl</span>
<span style="color: navy;">-UseBasicParsing</span> <span style="color: navy;">-Verbose</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: orangered; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">$links</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkgrey;">=</span> <span style="color: orangered;">$response</span><span style="color: darkgrey;">.</span>Links<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: orangered; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">$imgurlinks</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkgrey;">=</span> @()<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: orangered; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">$webclient</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkgrey;">=</span> <span style="color: blue;">New-Object</span> <span style="color: blueviolet;">System.Net.WebClient</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">Write-Output</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkred;">"-------------------------------------------------------------------------"</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">Write-Output</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkred;">"-------------------------------------------------------------------------"</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: orangered; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">$response</span><span style="color: darkgrey; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">.</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">Links<span style="color: darkgrey;">.</span>href<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">Write-Output</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkred;">"-------------------------------------------------------------------------"</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">Write-Output</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkred;">"-------------------------------------------------------------------------"</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">md</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: orangered;">$storagedir</span>
<span style="color: navy;">-ErrorAction</span> <span style="color: blueviolet;">SilentlyContinue</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: darkblue; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">ForEach</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> (<span style="color: orangered;">$link</span>
<span style="color: darkblue;">in</span> <span style="color: orangered;">$links</span>){
<span style="color: darkgreen;">#loop through all the hrefs on the page with a
ForEach</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: orangered;">$href</span> <span style="color: darkgrey;">=</span> <span style="color: orangered;">$link</span><span style="color: darkgrey;">.</span>href <span style="color: darkgreen;">#put the href
to Variable.</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkblue;">if</span> (<span style="color: orangered;">$href</span> <span style="color: darkgrey;">-like</span> <span style="color: darkred;">"*.mp3"</span> ) { <span style="color: darkgreen;">#Look
for only mp3's hrefs</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: orangered;">$filename</span>
<span style="color: darkgrey;">=</span> <span style="color: orangered;">$href</span><span style="color: darkgrey;">.</span>Split(<span style="color: darkred;">"/"</span>)<span style="color: darkgrey;">[</span><span style="color: purple;">-1</span><span style="color: darkgrey;">]</span> <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkgreen;">#Write-Output
"Href: " $href</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkgreen;">#Write-Output
"FileName: " $filename</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkblue;">if</span>
(<span style="color: orangered;">$filename</span> <span style="color: darkgrey;">-like</span>
<span style="color: darkred;">"*?*"</span>){ <span style="color: darkgreen;">#does
the filename have a query?</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: orangered;">$filename2</span>
<span style="color: darkgrey;">=</span> <span style="color: orangered;">$filename</span><span style="color: darkgrey;">.</span>Split(<span style="color: darkred;">"?"</span>)<span style="color: darkgrey;">[</span><span style="color: purple;">0</span><span style="color: darkgrey;">]</span> <span style="color: darkgreen;">#make the
filename2 the filename without any queries</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> } <span style="color: darkgreen;">#End If</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkblue;">else</span>{<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: orangered;">$filename2</span>
<span style="color: darkgrey;">=</span> <span style="color: orangered;">$filename</span>
<span style="color: darkgreen;">#since no queries were found just make the
filename2 the name of the orginal filename</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> } <span style="color: darkgreen;"># End
Else</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkblue;">if</span>(<span style="color: orangered;">$href</span> <span style="color: darkgrey;">-contains</span>
<span style="color: darkred;">"http://"</span>){ <span style="color: darkgreen;">#does the href have a direct path to the file? if not
lets try and add in the orignating url to it so it can find it. </span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: orangered;">$newhref</span>
<span style="color: darkgrey;">=</span> <span style="color: orangered;">$href</span>
<span style="color: darkgreen;">#No need to mess with the href.. just pass it to
the newhref and move along.</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> } <span style="color: darkgreen;">#End
http:// if</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: darkblue;">else</span>{
<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: orangered;">$newhref</span>
<span style="color: darkgrey;">=</span> <span style="color: orangered;">$theurl</span>
<span style="color: darkgrey;">+</span> <span style="color: darkred;">"\"</span>
<span style="color: darkgrey;">+</span> <span style="color: orangered;">$href</span>
<span style="color: darkgreen;">#put together theUrl and the Href to make a path
to try.</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> } <span style="color: darkgreen;">#End
http:// else</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: orangered;">$newFile</span>
<span style="color: darkgrey;">=</span> <span style="color: orangered;">$filename2</span><span style="color: darkgrey;">.</span>Replace(<span style="color: darkred;">"%20"</span><span style="color: darkgrey;">,</span><span style="color: darkred;">"-"</span>)
<span style="color: darkgreen;"># Replace %20 url encoded spaces with an
Underscore for the new mp3 file.</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: orangered;">$newFile</span>
<span style="color: darkgrey;">=</span> <span style="color: orangered;">$newFile</span><span style="color: darkgrey;">.</span>Replace(<span style="color: darkred;">"&amp;"</span><span style="color: darkgrey;">,</span><span style="color: darkred;">"-and-"</span>)
<span style="color: darkgreen;"># Replace &amp; url encoded spaces with an
"-and-" for the new mp3 file.</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: orangered;">$newFile</span>
<span style="color: darkgrey;">=</span> <span style="color: orangered;">$newFile</span><span style="color: darkgrey;">.</span>Replace(<span style="color: darkred;">"---"</span><span style="color: darkgrey;">,</span><span style="color: darkred;">"-"</span>)
<span style="color: darkgreen;"># Replace &amp; url encoded spaces with an
"-and-" for the new mp3 file.</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: orangered;">$newFile</span>
<span style="color: darkgrey;">=</span> <span style="color: darkred;">"</span><span style="color: orangered;">$storagedir</span><span style="color: darkred;">\</span><span style="color: orangered;">$newFile</span><span style="color: darkred;">"</span>
<span style="color: darkgreen;">#put together the path and the file of where to
put the file when downloaded.</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: orangered;">$newhref</span>
<span style="color: darkgrey;">=</span> <span style="color: orangered;">$newhref</span><span style="color: darkgrey;">.</span>Replace(<span style="color: darkred;">"&amp;"</span><span style="color: darkgrey;">,</span><span style="color: darkred;">"&"</span>)<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: blue;">Write-Output</span>
<span style="color: darkred;">"Href Location: "</span> <span style="color: orangered;">$newhref</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: blue;">Write-Output</span>
<span style="color: darkred;">"Download Location: "</span> <span style="color: orangered;">$newFile</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: orangered;">$webclient</span><span style="color: darkgrey;">.</span>DownloadFile(<span style="color: orangered;">$newhref</span><span style="color: darkgrey;">,</span><span style="color: orangered;">$newFile</span>) <span style="color: darkgreen;">#download the file using the href and the file we just
put together above. </span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> } <span style="color: darkgreen;">#end MP3
If.</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">}
<span style="color: darkgreen;">#end ForEach</span><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";">explorer</span><span style="font-family: "Lucida Console"; font-size: 9.0pt; mso-bidi-font-family: "Lucida Console";"> <span style="color: orangered;">$storagedir</span>
<span style="color: darkgreen;">#open the output folder <o:p></o:p></span></span></div>
<br />
<div class="MsoNormal">
<br /></div>
<br />
<br />
<br />
<br />
<br />
<br />Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com3tag:blogger.com,1999:blog-758009065572970321.post-49833155827353901452015-09-10T10:06:00.001-04:002015-09-10T10:24:10.120-04:00Turn off those Firewalls–Remotely–With PowerShell<p>Yet again I was given a task at work. This task was to turn off the Firewalls on hundreds of servers. So instead of logging into each one manually and changing the profiles on all the Firewall Profiles; Domain, Private and Public. I decided let us let PowerShell shine again.Now, they didn’t want the Firewall Services stopped, just the Profile states to be off. So after a little research and some help from some co-workers I put this script together. </p> <p>Let’s talk about something thing through before I go into the script. The easiest way to turn off these Profile states is to run. </p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#8b0000">netsh advfirewall set allprofiles state off </font></font></span></p> <p>This of course needs to be run locally on the machine. So I figured why not just use psexec to run the script. So I made a loop for the servers, looped it on the psexec and away it ran.. It ran VERY slowly. I had hundreds of these to run through. This would not work. So I decided to try and use PowerShell Invoke-Command. This required to have a session started using Enter-PSSession. Which of course gave this error. </p> <p class="MsoNormal" style="background: #012456; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#ff0000"> </font></font></span></span></p> <p class="MsoNormal" style="background: #012456; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#ff0000">Enter-PSSession : Connecting to remote server Server01 failed with the following error message : WinRM cannot process the request </font></font></span></p> <p class="MsoNormal" style="background: #012456; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#ff0000"> </font></font></span></span></p> <p>Well that’s not going to work because I need to have the WinRM service installed. I don’t have the much time to get approvals to install the WinRM service on all these machines. So I remembered one of my coworkers had run scripts against a remote machine the other week using PowerShell. So I asked for his secret. The secret was Invoke-WmiMethod. Here is the code simply put. </p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#0000ff"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">Invoke-WmiMethod</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#000080">-class</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Win32_process</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-name</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Create</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-ArgumentList</font></span><font color="#000000"> (“CMD.EXE /C netsh advfirewall set allprofiles state off”</font><font color="#000000">) –</font><span style="color: "><font color="#000080">ComputerName</font></span><font color="#000000"> </font></font><span style="color: "><font color="#ff4500"><font style="font-size: 9pt">Server01 </font><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span></font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#ff4500"> </font></font></span></span></p> <p>This actually runs the script against the server with no Invoke-Command or other service to be installed. So I set off to write the full script and it is FAST. Sooo much faster than I was hoping for. </p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#ff4500"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$command</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"netsh advfirewall set allprofiles state off"</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$cmd</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"CMD.EXE /C "</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+</font></span></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$command</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#00008b"><font style="font-size: 9pt">ForEach</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> (</font><span style="color: "><font color="#ff4500">$server</font></span><font color="#000000"> </font><span style="color: "><font color="#00008b">in</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-Content</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"c:\scripts\computers.txt"</font></span><font color="#000000">)</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">{</font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$theProc</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Invoke-WmiMethod</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-class</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Win32_process</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-name</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Create</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-ArgumentList</font></span><font color="#000000"> (</font><span style="color: "><font color="#ff4500">$cmd</font></span><font color="#000000">) </font><span style="color: "><font color="#000080">-ComputerName</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#00008b"><font style="font-size: 9pt">If</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000">(</font><span style="color: "><font color="#ff4500">$theProc</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">ReturnValue </font><span style="color: "><font color="#a9a9a9">-eq</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"0"</font></span><font color="#000000">){</font><span style="color: "><font color="#0000ff">write-host</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#8b0000">"</font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000"> - Completed successfully"</font></span><font color="#000000">}</font><span style="color: "><font color="#00008b">else</font></span><font color="#000000">{</font><span style="color: "><font color="#0000ff">write-host</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#8b0000">"</font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000"> - Completed UNsuccessfully"</font></span><font color="#000000">}</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">} </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p>Now one of the downfalls of this is, you don’t know if the script worked. Of course you can go see on the server if the script did what it was supposed to do, but that is not what I am talking about. Basically you don’t get the output of the cmd. All you get is ReturnValue of 0 if the command went through correctly. Not that your script ran successfully. Just that your little cmd soldier has been sent into the field with the operations it was told to do successfully.</p> Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com1tag:blogger.com,1999:blog-758009065572970321.post-49147136502272603532015-09-02T14:42:00.001-04:002015-09-02T14:42:10.904-04:00PowerShell – Hanging Get-WmiObject<p> </p> <p>I ran into something that I didn’t know was an issue with Get-WmiObject. I have been using Get-WmiObject for quite sometime so this was a shock to me. I had written a script to grab the description from servers and dump them to a gridview. </p> <p>I wanted to run this on 1400 servers. Meaning know it was going to take awhile. When I ended up running it, it took too long, actually waaaay to long. The reason? Some of the Get-WmiObject calls were hanging for what ever reason. No problem I thought lets assign the timeout argument to the Get-WmiObject? Where is the timeout argument? ??? After a bit of searching and reading I learned there is no way to set a timeout to the Get-WmiObject commandlet. </p> <p>After some more reading I learned that the best way to handing this is to setup the Get-WmiObject as a Job. The job can handle the Get-WmiObject process and if it takes longer than you think it should, kill the job and move on. </p> <p>I don’t have the old way I was running the script but this is the new way.. I tried to comment it as much as I could.</p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># try this and catch it if it fails</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#00008b">try</font></span><font color="#000000"> {</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># Set the try to stop if it error out</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$ErrorActionPreference</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">'Stop'</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font color="#006400"><font style="font-size: 9pt"># start the Job and assign it to a variable..</font><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span></font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="color: "><font color="#006400"><span style="mso-spacerun: yes"></span></font></span></font></span> </p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># -scriptBlock -- assign the -scriptblock argument to show what to run.. this is where the </font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="color: "><font style="font-size: 9pt" color="#006400"> # get-wmiobject is run. This is encapsualted in {}</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font color="#006400" face="Lucida Console"><span style="color: "></span></font></span> </p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># param<span style="mso-spacerun: yes"> </span>-- set the param to pass along the server name from the -ArgumentList to the </font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="color: "><font style="font-size: 9pt" color="#006400"> # Get-WmiObject commandlet</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font color="#006400" face="Lucida Console"><span style="color: "></span></font></span> </p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># -ArgumentList pass in the server information.</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font color="#006400" face="Lucida Console"><span style="color: "></span></font></span> </p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># | Wait-Job<span style="mso-spacerun: yes"> </span>-Timeout 2 - This tells the job to wait for 2 seconds.</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$job</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">start-job</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-scriptBlock</font></span><font color="#000000"> {</font><span style="color: "><font color="#00008b">param</font></span><font color="#000000"> (</font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">string</font></span><span style="color: "><font color="#a9a9a9">]</font></span><span style="color: "><font color="#ff4500">$server</font></span><font color="#000000">) </font><span style="color: "><font color="#0000ff">Get-WmiObject</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-Class</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Win32_OperatingSystem</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-ComputerName</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$server</font></span><font color="#000000"> } </font><span style="color: "><font color="#000080">-ArgumentList</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$server</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Wait-Job</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#000080">-Timeout</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#800080">2</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># This dumps out the job information to a variable to use later</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$results</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$job</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Receive-Job</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">select</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8a2be2">Description</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># If the Job state is not completed then it was and error, so write out an error for the </font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="color: "><font style="font-size: 9pt" color="#006400"> # try/catch to catch. </font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#00008b">if</font></span><font color="#000000"> (</font><span style="color: "><font color="#ff4500">$job</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">state </font><span style="color: "><font color="#a9a9a9">-ne</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Completed"</font></span><font color="#000000">) {</font><span style="color: "><font color="#0000ff">Write-Error</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Error"</font></span><font color="#000000">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># This is the where we put the variables into an array.</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$List</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+=</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">pscustomobject</font></span><span style="color: "><font color="#a9a9a9">]</font></span><font color="#000000">@{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'ComputerName'</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Description'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$results</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Description</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#00008b">catch</font></span><font color="#000000"> {</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400">#catch if there is an error and if there is write that there was one in the lsit array.. </font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$List</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+=</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">pscustomobject</font></span><span style="color: "><font color="#a9a9a9">]</font></span><font color="#000000">@{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'ComputerName'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Description'</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"Error"</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt; line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000"> </font></font></p> <p>Here is the full script. </p> <p> </p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#get the list of servers to scan from serverlist.txt</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$serverlist</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"C:\scripts\computers.txt"</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$List</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> @()</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$i</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#800080">0</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$fileCount</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#800080">0</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#get the count of servers for updates to the user.</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$fileCount</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> (</font><span style="color: "><font color="#0000ff">Get-Content</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$serverlist</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Measure-Object</font></span><font color="#000000">)</font><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Count</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#Loop the server list.</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#00008b"><font style="font-size: 9pt">foreach</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> (</font><span style="color: "><font color="#ff4500">$server</font></span><font color="#000000"> </font><span style="color: "><font color="#00008b">in</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-Content</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$serverlist</font></span><font color="#000000">) {</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#increment the number of records proccessed</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$i</font></font></span><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt" color="#a9a9a9">++</font></span></font><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#Write to the screen whats happening.</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">Write-Progress</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Connecting to server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># try this and catch it if it fails</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#00008b">try</font></span><font color="#000000"> {</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># Set the try to stop if it error out</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$ErrorActionPreference</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">'Stop'</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font color="#006400"><font style="font-size: 9pt"># start the Job and assign it to a variable..</font><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span></font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># -scriptBlock -- assign the -scriptblock argument to show what to run.. this is where the get-wmiobject is run. This is encapsualted in {}</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># param<span style="mso-spacerun: yes"> </span>-- set the param to pass along the server name from the -ArgumentList to the Get-WmiObject commandlet</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># -ArgumentList pass in the server information.</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># | Wait-Job<span style="mso-spacerun: yes"> </span>-Timeout 2 - This tells the job to wait for 2 seconds.</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$job</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">start-job</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-scriptBlock</font></span><font color="#000000"> {</font><span style="color: "><font color="#00008b">param</font></span><font color="#000000"> (</font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">string</font></span><span style="color: "><font color="#a9a9a9">]</font></span><span style="color: "><font color="#ff4500">$server</font></span><font color="#000000">) </font><span style="color: "><font color="#0000ff">Get-WmiObject</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-Class</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Win32_OperatingSystem</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-ComputerName</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$server</font></span><font color="#000000"> } </font><span style="color: "><font color="#000080">-ArgumentList</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$server</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Wait-Job</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#000080">-Timeout</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#800080">2</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># This dumps out the job information to a variable to use later</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$results</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$job</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Receive-Job</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">select</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8a2be2">Description</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># If the Job state is not completed then it was and error, so write out an error for the try/catch to catch. </font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt"><span style="mso-spacerun: yes"> </span></font></font><font style="font-size: 9pt"><span style="color: "><font color="#00008b">if</font></span><font color="#000000"> (</font><span style="color: "><font color="#ff4500">$job</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">state </font><span style="color: "><font color="#a9a9a9">-ne</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Completed"</font></span><font color="#000000">) {</font><span style="color: "><font color="#0000ff">Write-Error</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Error"</font></span><font color="#000000">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400"># This is the where we put the variables into an array.</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$List</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+=</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">pscustomobject</font></span><span style="color: "><font color="#a9a9a9">]</font></span><font color="#000000">@{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'ComputerName'</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Description'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$results</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Description</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#00008b">catch</font></span><font color="#000000"> {</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400">#catch if there is an error and if there is write that there was one in the lsit array.. </font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$List</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+=</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">pscustomobject</font></span><span style="color: "><font color="#a9a9a9">]</font></span><font color="#000000">@{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'ComputerName'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Description'</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"Error"</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">}</font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$List</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#0000ff">Out-GridView </font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="color: "> </span></span></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt; line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000"> </font></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt; line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000"> </font></font></p> Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com1tag:blogger.com,1999:blog-758009065572970321.post-19078357812826308002015-08-26T13:44:00.001-04:002015-08-26T13:44:37.131-04:00PowerShell - Gathering IPs from servers<blockquote></blockquote> <p> </p> <p>Needed to gather all the IPs on a bunch of remote servers. </p> <p>Here is my script to pull all the IPs from a server and dump each IP to a CSV file with each IP on its own row.</p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">##### Set Variables #######</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$fileCount</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#800080">0</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$List</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> @()</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$i</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">0</font></span><font color="#000000"> </font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#get the list of servers to scan from serverlist.txt</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$serverlist</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"C:\scripts\computers.txt"</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#get the count of servers for updates to the user.</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$fileCount</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> (</font><span style="color: "><font color="#0000ff">Get-Content</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$serverlist</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Measure-Object</font></span><font color="#000000">)</font><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Count</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#Loop the server list.</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#00008b"><font style="font-size: 9pt">foreach</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> (</font><span style="color: "><font color="#ff4500">$server</font></span><font color="#000000"> </font><span style="color: "><font color="#00008b">in</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-Content</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$serverlist</font></span><font color="#000000">) {</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#increment the number of records proccessed</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$i</font></font></span><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt" color="#a9a9a9">++</font></span></font><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#Write to the screen whats happening.</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">Write-Progress</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Connecting to server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#do a try if there is an issue spit out the error.</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#00008b"><font style="font-size: 9pt">try</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt" color="#000000"> {</font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400">#IF there is an error stop and go to the next record.</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$ErrorActionPreference</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">'Stop'</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$configs</font></span><span style="color: "><font color="#a9a9a9">=</font></span><span style="color: "><font color="#0000ff">Get-WmiObject</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-ComputerName</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$server</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">win32_networkadapterconfiguration</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">select</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">IPaddress</font></span><span style="color: "><font color="#a9a9a9">,</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">ServiceName</font></span><span style="color: "><font color="#a9a9a9">,</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Description</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">where</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">IPaddress</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-ne</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$null</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#0000ff">Write-Progress</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400">#Set the array for the output.</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#00008b">if</font></span><font color="#000000">(</font><span style="color: "><font color="#ff4500">$configs</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">IPaddress</font><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Count </font><span style="color: "><font color="#a9a9a9">-eq</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">1</font></span><font color="#000000">){</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$List</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+=</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">pscustomobject</font></span><span style="color: "><font color="#a9a9a9">]</font></span><font color="#000000">@{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'ComputerName'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'IPaddress'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$configs</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">IPaddress</font><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Item(</font><span style="color: "><font color="#800080">0</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Description'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$configs</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Description</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#00008b">else</font></span><font color="#000000">{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#00008b">for</font></span><font color="#000000">(</font><span style="color: "><font color="#ff4500">$thecount</font></span><span style="color: "><font color="#a9a9a9">=</font></span><span style="color: "><font color="#800080">1</font></span><font color="#000000">; </font><span style="color: "><font color="#ff4500">$theCount</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">-le</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$configs</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">IPaddress</font><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Count){</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$List</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+=</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">pscustomobject</font></span><span style="color: "><font color="#a9a9a9">]</font></span><font color="#000000">@{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'ComputerName'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'IPaddress'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$configs</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">IPaddress</font><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Item(</font><span style="color: "><font color="#ff4500">$thecount</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">-</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">1</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Description'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$configs</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Description</font><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Item(</font><span style="color: "><font color="#ff4500">$thecount</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">-</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">1</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$thecount</font></span></font><span style="color: "><font style="font-size: 9pt" color="#a9a9a9">++</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">} </font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#00008b">catch</font></span><font color="#000000"> {</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$List</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+=</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">pscustomobject</font></span><span style="color: "><font color="#a9a9a9">]</font></span><font color="#000000">@{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'ComputerName'</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'IPaddress'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"Error"</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'ServiceName'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"Error"</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Description'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"Error"</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">} </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">write-progress</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"Completed."</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$randomString</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-Date</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-format</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8a2be2">M.d.yyyy.HH.mm.ss</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#00008b"><font style="font-size: 9pt">try</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt" color="#000000">{</font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">md</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"c:\scripts\export\"</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">}</font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#00008b"><font style="font-size: 9pt">Catch</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt" color="#000000">{</font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">}</font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$csvFileName</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">'c:\scripts\export\'</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$randomString</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">'_GetServerIPs.csv'</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$csvFileName</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt" color="#000000"> </font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$List</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Export-Csv</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$csvFileName</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#000080">-noType</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">Invoke-Item</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$csvFileName</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="margin: 0in 0in 8pt; line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000"> </font></font></p> Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-81017953105863513532015-08-25T10:49:00.001-04:002015-08-25T10:49:12.645-04:00Out-GridView vs. Export-Csv<p>This question is something that came to me recently. It came to me because I have a wonderful script that dumps out server specs to a Out-GridView. The Out-GridView works great for quickly seeing information in a grid. The one down fall I have noticed is when selecting the data from it and copying it to me a program like Excel the header rows do not come with the copy. </p> <p>Well with the script I talked about earlier I almost always end up viewing the data in Excel. So, I figured why not skip the copy paste to excel step. </p> <p>$List is the data that has been collected previous to this point that I want to export.<br><br>This is how I viewed the data before. </p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$List</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Out-GridView</font></span></font><span style="mso-spacerun: yes"><font style="font-size: 9pt" color="#000000"> </font></span></span></font></p> <p>Ok, so lets change the output.</p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$List</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Export-Csv</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">‘c:\scripts\export\export.csv </font></span></span></font></p> <p>Well that worked it dumped the information to a csv and I open it in excel it has the headers.</p> <p>At this point I said why am I opening Excel and then opening it in excel. Lets automate it.</p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">Invoke-Item</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">‘c:\scripts\export\export.csv</font></span></span></font></p> <p>This works great except for some reason there is some file header information. The header information was:</p> <p><strong>#TYPE System.Management.Automation.PSCustomObject</strong> <p>I found out this is the type of the output and can be removed with the –notype option like this. </p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">Invoke-Item</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">‘c:\scripts\export\export.csv –noType </font></span></span></font></p> <p>This worked nicely but I wanted to clean it up in a couple of ways.</p> <ol> <li>Create the directory that the script will go to.</li> <ol> <li>Catch the error it if it is already made.</li></ol> <li>Create the file dynamically so that we can keep a history of the files</li> <ol> <li>this will be done dynamically with the get-date cmdlet.</li></ol></ol> <p>This is what I ended up with. </p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt"> </font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$randomString</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-Date</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-format</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8a2be2">M.d.yyyy.HH.mm.ss</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#00008b"><font style="font-size: 9pt">try</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt" color="#000000">{</font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">md</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"c:\scripts\export\"</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">}</font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#00008b"><font style="font-size: 9pt">Catch</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt" color="#000000">{</font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">}</font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$csvFileName</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">'c:\scripts\export\'</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$randomString</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">'_GetSpecsExport.csv'</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$csvFileName</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt" color="#000000"> </font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$List</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Export-Csv</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$csvFileName</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#000080">-noType</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">Invoke-Item</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$csvFileName </font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font color="#ff4500" face="Lucida Console"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="color: "></span></span></font> </p> <p>Here is the whole script for anyone who wants to see it. </p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400"># Get Server Hardware specs</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400"># 2015 Edward </font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400"># CPU / RAM / Disk Size / IP Address</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">##### Set Variables #######</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$fileCount</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#800080">0</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$List</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> @()</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$i</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">0</font></span><font color="#000000"> </font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#get the list of servers to scan from serverlist.txt</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$serverlist</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"C:\scripts\computers.txt"</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#get the count of servers for updates to the user.</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$fileCount</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> (</font><span style="color: "><font color="#0000ff">Get-Content</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$serverlist</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Measure-Object</font></span><font color="#000000">)</font><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Count</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#Loop the server list.</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#00008b"><font style="font-size: 9pt">foreach</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> (</font><span style="color: "><font color="#ff4500">$server</font></span><font color="#000000"> </font><span style="color: "><font color="#00008b">in</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-Content</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$serverlist</font></span><font color="#000000">) {</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#increment the number of records proccessed</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$i</font></font></span><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt" color="#a9a9a9">++</font></span></font><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#Write to the screen whats happening.</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">Write-Progress</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Connecting to server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#do a try if there is an issue spit out the error.</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#00008b"><font style="font-size: 9pt">try</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt" color="#000000"> {</font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400">#IF there is an error stop and go to the next record.</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$ErrorActionPreference</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">'Stop'</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$bios</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-WmiObject</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Win32_BIOS</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-ComputerName</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#0000ff">Write-Progress</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000"> -<span style="mso-spacerun: yes"> </span>getting BIOS information"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#0000ff">Write-Progress</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000"> - getting Processor information"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$Proc</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-WmiObject</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Win32_processor</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-ComputerName</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$server</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Select-Object</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-First</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#800080">1</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#0000ff">Write-Progress</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000"> - getting Memory information"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$memory</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-WmiObject</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Win32_physicalmemory</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-ComputerName</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#0000ff">Write-Progress</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000"> - getting System information"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$system</font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-WmiObject</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Win32_ComputerSystem</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-ComputerName</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#0000ff">Write-Progress</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000"> - getting Disk information"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$disks</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-WmiObject</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-class</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Win32_LogicalDisk</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-ComputerName</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$server</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-Filter</font></span><font color="#000000"> {</font><span style="color: "><font color="#0000ff">DriveType=3</font></span><font color="#000000">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$disklist</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">" "</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#00008b">foreach</font></span><font color="#000000"> (</font><span style="color: "><font color="#ff4500">$disk</font></span><font color="#000000"> </font><span style="color: "><font color="#00008b">in</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$disks</font></span><font color="#000000">) {</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#00008b">IF</font></span><font color="#000000"> (</font><span style="color: "><font color="#ff4500">$disklist</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">-eq</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">" "</font></span><font color="#000000">){</font><span style="color: "><font color="#ff4500">$putAcomma</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">""</font></span><font color="#000000">} </font><span style="color: "><font color="#00008b">ELSE</font></span><font color="#000000"> {</font><span style="color: "><font color="#ff4500">$putAcomma</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">", "</font></span><font color="#000000">}</font></font><span style="mso-spacerun: yes"><font style="font-size: 9pt" color="#000000"> </font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$size</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">math</font></span><span style="color: "><font color="#a9a9a9">]::</font></span><font color="#000000">Round((</font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">int64</font></span><span style="color: "><font color="#a9a9a9">]</font></span><span style="color: "><font color="#ff4500">$disk</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Size </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">1073741824</font></span><font color="#000000">))</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$disklist</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$disklist</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$putAcomma</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$disk</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">DeviceID </font><span style="color: "><font color="#a9a9a9">+</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">" "</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">string</font></span><span style="color: "><font color="#a9a9a9">]</font></span><span style="color: "><font color="#ff4500">$size</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">" GB"</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#0000ff">Write-Progress</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400">#Set the array for the output.</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$List</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+=</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">pscustomobject</font></span><span style="color: "><font color="#a9a9a9">]</font></span><font color="#000000">@{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'ComputerName'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Manufacturer'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$bios</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Manufacturer</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Model'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$system</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Model</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'BIOS Version'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$bios</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Version</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Serial Number'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$bios</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">SerialNumber</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Processor Number'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$system</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">NumberOfProcessors</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Processor Name'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$proc</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">name</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'CPUs'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$system</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">NumberOfLogicalProcessors</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Speed (MHZ)'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$proc</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">CurrentClockSpeed</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'RAM (GB)'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$system</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">TotalPhysicalMemory </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">1GB</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">-as</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">int</font></span></font><span style="color: "><font style="font-size: 9pt" color="#a9a9a9">]</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Used RAM slot'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$memory</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">count</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'DiskList'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$disklist</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">} </font></font><font style="font-size: 9pt"><span style="color: "><font color="#00008b">catch</font></span><font color="#000000"> {</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$List</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+=</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">pscustomobject</font></span><span style="color: "><font color="#a9a9a9">]</font></span><font color="#000000">@{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'ComputerName'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'CPUs'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">" ERROR "</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Speed (MHZ)'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">" ERROR "</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'RAM (GB)'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">" ERROR "</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'DiskList'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$error</font></span><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#800080">0</font></span><span style="color: "><font color="#a9a9a9">].</font></span><font color="#000000">exception</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">} </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">write-progress</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"Completed."</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$randomString</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-Date</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-format</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8a2be2">M.d.yyyy.HH.mm.ss</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#00008b"><font style="font-size: 9pt">try</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt" color="#000000">{</font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">md</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"c:\scripts\export\"</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">}</font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#00008b"><font style="font-size: 9pt">Catch</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt" color="#000000">{</font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">}</font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$csvFileName</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">'c:\scripts\export\'</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$randomString</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">'_GetSpecsExport.csv'</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$csvFileName</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt" color="#000000"> </font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$List</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Export-Csv</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$csvFileName</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#000080">-noType</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">Invoke-Item</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$csvFileName</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com1tag:blogger.com,1999:blog-758009065572970321.post-18025932357353842202015-08-13T15:24:00.001-04:002015-08-13T15:24:33.922-04:00Get Server Hardware specs–PowerShell<p> </p> <p> </p> <p>This script loops through a text list and get information using Get-WmiObject. Then dumps it to an array then to a Grid View.</p> <p> </p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400"># Get Server Hardware specs</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400"># 2015 Edward </font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400"># CPU / RAM / Disk Size / IP Address</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">##### Set Variables #######</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$fileCount</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#800080">0</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$List</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> @()</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$i</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">0</font></span><font color="#000000"> </font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#get the list of servers to scan from serverlist.txt</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$serverlist</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"C:\scripts\computers.txt"</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#get the count of servers for updates to the user.</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$fileCount</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> (</font><span style="color: "><font color="#0000ff">Get-Content</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$serverlist</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Measure-Object</font></span><font color="#000000">)</font><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Count</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#Loop the server list.</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#00008b"><font style="font-size: 9pt">foreach</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> (</font><span style="color: "><font color="#ff4500">$server</font></span><font color="#000000"> </font><span style="color: "><font color="#00008b">in</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-Content</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$serverlist</font></span><font color="#000000">) {</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#increment the number of records proccessed</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$i</font></font></span><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt" color="#a9a9a9">++</font></span></font><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#Write to the screen whats happening.</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">Write-Progress</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Connecting to server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#do a try if there is an issue spit out the error.</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#00008b"><font style="font-size: 9pt">try</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt" color="#000000"> {</font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400">#IF there is an error stop and go to the next record.</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$ErrorActionPreference</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">'Stop'</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$bios</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-WmiObject</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Win32_BIOS</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-ComputerName</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#0000ff">Write-Progress</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000"> -<span style="mso-spacerun: yes"> </span>getting BIOS information"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#0000ff">Write-Progress</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000"> - getting Processor information"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$Proc</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-WmiObject</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Win32_processor</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-ComputerName</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$server</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Select-Object</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-First</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#800080">1</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#0000ff">Write-Progress</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000"> - getting Memory information"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$memory</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-WmiObject</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Win32_physicalmemory</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-ComputerName</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#0000ff">Write-Progress</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000"> - getting System information"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$system</font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-WmiObject</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Win32_ComputerSystem</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-ComputerName</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#0000ff">Write-Progress</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000"> - getting Disk information"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$disks</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-WmiObject</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-class</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Win32_LogicalDisk</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-ComputerName</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$server</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-Filter</font></span><font color="#000000"> {</font><span style="color: "><font color="#0000ff">DriveType=3</font></span><font color="#000000">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$disklist</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">" "</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#00008b">foreach</font></span><font color="#000000"> (</font><span style="color: "><font color="#ff4500">$disk</font></span><font color="#000000"> </font><span style="color: "><font color="#00008b">in</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$disks</font></span><font color="#000000">) {</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#00008b">IF</font></span><font color="#000000"> (</font><span style="color: "><font color="#ff4500">$disklist</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">-eq</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">" "</font></span><font color="#000000">){</font><span style="color: "><font color="#ff4500">$putAcomma</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">""</font></span><font color="#000000">} </font><span style="color: "><font color="#00008b">ELSE</font></span><font color="#000000"> {</font><span style="color: "><font color="#ff4500">$putAcomma</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">", "</font></span><font color="#000000">}</font></font><span style="mso-spacerun: yes"><font style="font-size: 9pt" color="#000000"> </font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$size</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">math</font></span><span style="color: "><font color="#a9a9a9">]::</font></span><font color="#000000">Round((</font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">int64</font></span><span style="color: "><font color="#a9a9a9">]</font></span><span style="color: "><font color="#ff4500">$disk</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Size </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">1073741824</font></span><font color="#000000">))</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$disklist</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$disklist</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$putAcomma</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$disk</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">DeviceID </font><span style="color: "><font color="#a9a9a9">+</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">" "</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">string</font></span><span style="color: "><font color="#a9a9a9">]</font></span><span style="color: "><font color="#ff4500">$size</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">" GB"</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#0000ff">Write-Progress</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning server </font></span><span style="color: "><font color="#ff4500">$server</font></span><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-status</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Scanning: </font></span><span style="color: "><font color="#ff4500">$i</font></span><span style="color: "><font color="#8b0000"> of </font></span><font color="#000000">$(</font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)</font><span style="color: "><font color="#8b0000">"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-percentComplete</font></span><font color="#000000"> ((</font><span style="color: "><font color="#ff4500">$i</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fileCount</font></span><font color="#000000">)<span style="mso-spacerun: yes"> </span></font><span style="color: "><font color="#a9a9a9">*</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">100</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#006400">#Set the array for the output.</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$List</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+=</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">pscustomobject</font></span><span style="color: "><font color="#a9a9a9">]</font></span><font color="#000000">@{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'ComputerName'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Manufacturer'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$bios</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Manufacturer</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Model'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$system</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Model</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'BIOS Version'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$bios</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Version</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Serial Number'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$bios</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">SerialNumber</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Processor Number'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$system</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">NumberOfProcessors</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Processor Name'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$proc</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">name</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'CPUs'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$system</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">NumberOfLogicalProcessors</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Speed (MHZ)'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$proc</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">CurrentClockSpeed</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'RAM (GB)'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$system</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">TotalPhysicalMemory </font><span style="color: "><font color="#a9a9a9">/</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">1GB</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">-as</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">int</font></span></font><span style="color: "><font style="font-size: 9pt" color="#a9a9a9">]</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Used RAM slot'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$memory</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">count</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'DiskList'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$disklist</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">} </font></font><font style="font-size: 9pt"><span style="color: "><font color="#00008b">catch</font></span><font color="#000000"> {</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$List</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+=</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">pscustomobject</font></span><span style="color: "><font color="#a9a9a9">]</font></span><font color="#000000">@{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'ComputerName'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$server</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'CPUs'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">" ERROR "</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Speed (MHZ)'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">" ERROR "</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'RAM (GB)'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">" ERROR "</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'DiskList'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$error</font></span><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#800080">0</font></span><span style="color: "><font color="#a9a9a9">].</font></span><font color="#000000">exception</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">} </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">write-progress</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#000080">-activity</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"Completed."</font></span><font color="#000000"> </font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$List</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#0000ff">Out-GridView</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="color: "><font style="font-size: 9pt" color="#0000ff"> </font></span></span></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt; line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000"> </font></font></p> Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-55893333036535737232015-08-13T11:11:00.001-04:002015-08-13T11:13:36.367-04:00Get latest file from directory<p> </p> <p>I used this script to look at a list of users Home directories to see if people were using them. That way I could question whether that person was even working with us anymore.</p> <p>This script does NOT do a recursive search. It only searches the directory you supply. </p> <p>The script takes its input from a text file, dirList.txt in the script. It is one directory per line in the text file. </p> <p> </p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#ff4500"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$ErrorActionPreference</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"SilentlyContinue"</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$theContent</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-Content</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"C:\Scripts\dirList.txt"</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$List</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> @()</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#00008b"><font style="font-size: 9pt">ForEach</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> (</font><span style="color: "><font color="#ff4500">$theDir</font></span><font color="#000000"> </font><span style="color: "><font color="#00008b">in</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$theContent</font></span><font color="#000000">){</font></font></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#00008b">try</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$thecount</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> (</font><span style="color: "><font color="#0000ff">dir</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$theDir</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">measure</font></span><font color="#000000">)</font><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Count</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#00008b">If</font></span><font color="#000000">(</font><span style="color: "><font color="#ff4500">$thecount</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">-eq</font></span><font color="#000000"> </font><span style="color: "><font color="#800080">0</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$List</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+=</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">pscustomobject</font></span><span style="color: "><font color="#a9a9a9">]</font></span><font color="#000000">@{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Directory'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$theDir</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Dir Object Count'</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"0"</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'FileName'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"Empty Directory"</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'type'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">""</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Date'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">""</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#00008b">else</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$latest</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-ChildItem</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-Path</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$theDir</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#000080">-ErrorAction</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">Stop</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Sort-Object</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">LastAccessTime</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-Descending</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Select-Object</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-First</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#800080">1</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$List</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+=</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">pscustomobject</font></span><span style="color: "><font color="#a9a9a9">]</font></span><font color="#000000">@{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Directory'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$theDir</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Dir Object Count'</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$thecount</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'FileName'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$latest</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Name</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'type'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$latest</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">GetType()</font><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">Name</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Date'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$latest</font></span><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">LastAccessTime</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="mso-spacerun: yes"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><span style="color: "><font style="font-size: 9pt" color="#00008b">catch</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#ff4500">$List</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">+=</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">[</font></span><span style="color: "><font color="#008080">pscustomobject</font></span><span style="color: "><font color="#a9a9a9">]</font></span><font color="#000000">@{</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Directory'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$theDir</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Dir Object Count'</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">""</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'FileName'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">"No Directory or no access"</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'type'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">""</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><span style="mso-spacerun: yes"><font color="#000000"><font style="font-size: 9pt"> </font></font></span><font style="font-size: 9pt"><span style="color: "><font color="#8b0000">'Date'</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">""</font></span></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><span style="mso-spacerun: yes"><font style="font-size: 9pt"> </font></span><font style="font-size: 9pt">}</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">}</font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$List</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#0000ff">Out-GridView</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="color: "><font style="font-size: 9pt" color="#0000ff"> </font></span></span></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt; line-height: 12pt"><span style="mso-spacerun: yes"><font face="Calibri"><font style="font-size: 11pt" color="#000000"> </font></font></span></p> Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-17640343795360490402015-08-12T16:45:00.001-04:002015-08-12T16:46:48.664-04:00Get a directory child count PowerShell<p> </p> <p>Get a count of objects in a directory</p> <p>This gets you all items in the directory</p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><font style="font-size: 9pt"> </font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><font style="font-size: 9pt">(</font></font><font style="font-size: 9pt"><span style="color: "><font color="#0000ff">Get-ChildItem</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-path</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"c:\source\"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-Recurse</font></span><font color="#000000">)</font><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">count </font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font color="#000000" face="Lucida Console"></font></span> </p> <p>Adding the –include gives you the ability to filter the directory. For example I used –include *.*xl* to get a count of excel files. </p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><font style="font-size: 9pt"> </font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font color="#000000"><font style="font-size: 9pt">(</font></font><font style="font-size: 9pt"><span style="color: "><font color="#0000ff">Get-ChildItem</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-path</font></span><font color="#000000"> </font><span style="color: "><font color="#8b0000">"c:\source\"</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-Recurse</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-include</font></span><font color="#000000"> </font><span style="color: "><font color="#8a2be2">*.*xl*</font></span><font color="#000000">)</font><span style="color: "><font color="#a9a9a9">.</font></span><font color="#000000">count</font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt"><font color="#000000"> </font></font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""></span></p> Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-33786760247875120822015-08-12T16:38:00.001-04:002015-08-12T16:39:30.492-04:00Compare Directories PowerShell<p> </p> <p class="MsoNormal" style="margin: 0in 0in 8pt; line-height: 12pt"><font color="#000000" face="Calibri">This compares to 2 directories and tells you what side they are on. </font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt; line-height: 12pt"><font color="#000000" face="Calibri">Warning DO NOT use this on a large folder structure of like 1 million files/directories. </font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt"></font></font></span></font> </p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$intialDir</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#0000ff">Read-Host</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-Prompt</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">'First path?'</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$secondDir</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><span style="mso-spacerun: yes"><font color="#000000"> </font></span><span style="color: "><font color="#0000ff">Read-Host</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-Prompt</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#8b0000">'Second path?'</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$fso</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-ChildItem</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-Recurse</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-path</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$intialDir</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#ff4500"><font style="font-size: 9pt">$fsoBU</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color: "><font color="#0000ff">Get-ChildItem</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-Recurse</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-path</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#ff4500">$secondDir</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font face="Lucida Console"><font style="font-size: 9pt" color="#000000"> </font></font></span></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; color: ; mso-bidi-font-family: "Lucida Console""><font color="#0000ff"><font style="font-size: 9pt">Compare-Object</font></font></span><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><font style="font-size: 9pt"><font color="#000000"> </font><span style="color: "><font color="#000080">-ReferenceObject</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fso</font></span><font color="#000000"> </font><span style="color: "><font color="#000080">-DifferenceObject</font></span><font color="#000000"> </font><span style="color: "><font color="#ff4500">$fsoBU</font></span><font color="#000000"> </font><span style="color: "><font color="#a9a9a9">|</font></span><font color="#000000"> </font></font><span style="color: "><font style="font-size: 9pt" color="#0000ff">Out-GridView</font></span></span></font></p> <p class="MsoNormal" style="background: white; margin: 0in 0in 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><font face="Lucida Console"><span style="font-family: ; mso-bidi-font-family: "Lucida Console""><span style="color: "><font style="font-size: 9pt" color="#0000ff"> </font></span></span></font></p> <p class="MsoNormal" style="margin: 0in 0in 8pt; line-height: 12pt"><font face="Calibri"><font style="font-size: 11pt" color="#000000"> </font></font></p> Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-50815378107468149282015-08-12T14:20:00.001-04:002015-08-12T14:20:56.612-04:00VBSFindReplaceExcel<div class="tr_bq">
This is a script I made to find and replace server information in excel files.</div>
<br />
<i>The one thing this script does not search is macros</i><br />
<br />
<br />
<h3>
Script basics.</h3>
<br />
<ul>
<li>Get a path to search </li>
<li>put path of all the excel files in variable</li>
<li>loop through the variables</li>
<li>looks to see if excel file is locked .. if it is fail this excel (this could be changed to open it based on password but we didn't need to do this)</li>
<li>looks and unlocks workbook based on list of predefined passwords if need be - records what one worked - if it was locked and none worked fail that excel file.</li>
<li>Unhide worksheets if needed</li>
<li>unlocks all worksheets if need be. - if it was locked and none worked fail that excel file.</li>
<li>loop through connections looking for servers based on an array of possibilities - if none matched nothing changed</li>
<li>loop through objWorkbook.LinkSources to search for servers based on an array of possibilities - if none matched nothing changed</li>
<li>if nothing was changed close the excel file without saving </li>
<li>put back worksheets to the way they were if they, either hidden or locked if needed</li>
<li>put workbook back to the way it should be.. lock it if need be.</li>
<li>save workbook since if was changed</li>
</ul>
<h3>
<b>NOTE</b></h3>
<ul>
<li>there is a read only mode</li>
<li>almost everything is logged to a text file</li>
<li>there is a default password option</li>
</ul>
<div>
<br /></div>
<div>
<br /></div>
<br />
<blockquote style="background-color: #faebbc;">
On Error Resume Next<br />
' ----------- Variable area ---------------<br />
' Set the variable names<br />
Dim objWorkbookTestExcelFilePassword, nullWBPass, replacedLinktext,aLinks, dt, objNetwork, strLocalDrive, strRemoteShare, correctPassword, needsToBeReprotectedWorkbook, thisNeverGotUnlocked, NewPassword, strDrive, listOfFiles, rehide, outCurrentFile, somethingFound, runLive<br />
' how Many To Loop through<br />
' Change this number to change the amount of things to search through.<br />
' 0 is really 1, 1 is 2, and so on.<br />
'========================================================<br />
Dim rngSearch(0)<br />
dim rngReplace(0)<br />
<br />
' Search replacements<br />
rngSearch(0) = "\\serv1\blah\"<br />
rngReplace(0) = "\\newSever\share\blah\"<br />
'========================================================<br />
' Uncomment or comment to add to the search array.<br />
' rngSearch is what you are searching for.<br />
' rngReplace is what will be replaced based on its cosponsoring search.<br />
'========================================================<br />
<br />
' rngSearch(0) = "\\serv2\blah\<br />
' rngReplace(0) = "\\newSever2\share\blah\"<br />
' rngSearch(1) = "\\serv3\blah\"<br />
' rngReplace(1) = "\\newSever3\share\blah\"<br />
' rngSearch(1) = "\\serv4\blah\"<br />
' rngReplace(1) = "\\newSever4\share\blah\"<br />
' rngSearch(2) = "\\serv5\blah\"<br />
' rngReplace(2) = "\\newSever5\share\blah\"<br />
' rngSearch(3) = "\\serv6\blah\"<br />
' rngReplace(3) = "\\newSever6\share\blah\"<br />
<br />
'========================================================<br />
<br />
' Set this to "True" to make the script actually change the things it finds and save.<br />
' This could be in the beginning script to ask if you want to run the script live instead of being hard coded. Maybe later.<br />
runLive = "False"<br />
<br />
<br />
<br />
<br />
<br />
' Password List<br />
listOfPasses = Split("pass,password1,qwerty,1234,3456,121312,PASSSWORDS",",")<br />
' New Default Password to use per group<br />
changeDefaultPassword = "False"<br />
NewPassword = "D3f@ultP@ssw0rd"<br />
'set the Count of the amount of files to 0 so it can start counting them<br />
countMe = 0<br />
' This is the drive that will be mounted when the script starts<br />
strDrive = "Z:"<br />
' set what objNetwork is for mounting the drive<br />
Set objNetwork = WScript.CreateObject("WScript.Network")<br />
' Set the shell object<br />
Set oWshShell = CreateObject("WScript.Shell")<br />
' Set the File System object<br />
Set oFSO = CreateObject("Scripting.FileSystemObject")<br />
' Set the excel object<br />
Set objExcel = CreateObject("Excel.Application")<br />
'----------- Variable area - End ---------------<br />
<br />
<br />
<br />
' Function list = Begin=========================================<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Function Name: isWorkbookProtected<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Description: This looks at the workbook to see if its protected or not and a True or False<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Input: It needs the object of the workbook that is in question<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'isWorkbookProtected Begin ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Function isWorkbookProtected(WB)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Fx1 = False<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If WB.ProtectWindows Then Fx1 = True<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If WB.ProtectStructure Then Fx1 = True<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If Fx1 = False Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>isWorkbookProtected = Fx1<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'MsgBox "The workbook is not protected."<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>isWorkbookProtected = Fx1<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'MsgBox "The workbook is protected."<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End If<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>End Function<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'isWorkbookProtected End ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Function Name: isWorksheetProtected<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Description: This looks at the worksheet to see if its protected or not and a True or False<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Input: It needs the object of the worksheet that is in question<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'isWorksheetProtected Begin ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Function isWorksheetProtected(WS)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Fx2 = False<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If WS.ProtectContents Then Fx2 = True<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If WS.ProtectDrawingObjects Then Fx2 = True<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If WS.ProtectScenarios Then Fx2 = True<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If Fx1 = False Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>isWorksheetProtected = Fx2<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'MsgBox "The worksheet is not protected."<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>isWorksheetProtected = Fx2<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'MsgBox "The worksheet is protected."<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End If<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>End Function<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'isWorksheetProtected End ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Function Name: IsWriteAccessible<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Description: ' Strategy: Attempt to open the specified file in 'append' mode.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Does not appear to change the 'modified' date on the file.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Works with binary files as well as text files.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Only 'ForAppending' is needed here. Define these constants<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' outside of this function if you need them elsewhere in your source file.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Input: It needs the file that is in question<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'IsWriteAccessible Begin ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Function IsWriteAccessible(sFilePath)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Const ForReading = 1, ForWriting = 2, ForAppending = 8<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>IsWriteAccessible = False<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Dim oFso : Set oFso = CreateObject("Scripting.FileSystemObject")<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>On Error Resume Next<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Dim nErr : nErr = 0<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Dim sDesc : sDesc = ""<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Dim oFile : Set oFile = oFso.OpenTextFile(sFilePath, ForAppending)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If Err.Number = 0 Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>oFile.Close<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If Err Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>nErr = Err.Number<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>sDesc = Err.Description<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>IsWriteAccessible = True<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Select Case Err.Number<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Case 70<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Permission denied because:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' - file is open by another process<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' - read-only bit is set on file, *or*<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' - NTFS Access Control List settings (ACLs) on file<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' prevents access<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Case Else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' 52 - Bad file name or number<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' 53 - File not found<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' 76 - Path not found<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>nErr = Err.Number<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>sDesc = Err.Description<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End Select<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End If<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>On Error GoTo 0<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If nErr Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Err.Raise nErr, , sDesc<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End If<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End Function<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'IsWriteAccessible End ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Function list = End ========================================= <span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<br />
<br />
<br />
<br />
'----------- Create the log file ---------------<br />
' Set the current Day Time<br />
dt = now<br />
' Create the file system object<br />
Set objFSO=CreateObject("Scripting.FileSystemObject")<br />
<br />
<br />
'Create the log file name<br />
outLogFile="C:\EXCELFindReplaceVBS\RunLog - "& ((year(dt)*100 + month(dt))*100 + day(dt))*10000 + hour(dt)*100 + minute(dt)& ".txt"<br />
outCurrentFile="C:\EXCELFindReplaceVBS\Currentfile.txt"<br />
' Set the objFileLog to create the log file<br />
Set objFileLog = objFSO.CreateTextFile(outLogFile,True)<br />
<br />
' Log entry -------------<br />
objFileLog.Write "Time||TypeOfLog||FileNamePath||SheetInfo||PasswordInfo||Information" & vbCrLf<br />
' Log entry -------------<br />
objFileLog.Write Now & "||ScriptInfo|| || || ||Starting Script " & vbCrLf<br />
<br />
<br />
if runLive = "True" then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ScriptInfo|| || || ||Script running LIVE changes will be saved." & vbCrLf<br />
else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ScriptInfo|| || || ||Script running as READ-ONLY, saves will not be saved. " & vbCrLf<br />
end if<br />
<br />
<br />
<br />
'----------- Setup questions to set the search path ---------------<br />
' IS this a local drive<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>isItADrive = MsgBox("Is the drive you want to modify a local drive, like c:\? If its a share, like \\servername\share click no.",3,"Choose options")<br />
<br />
if isItADrive = vbCancel then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>MsgBox("You cancelled the dialogue box, quitting script.")<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Wscript.Quit<br />
end if<br />
<br />
<br />
<br />
if isItADrive = vbYes then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'WScript.Echo "yes its a drive"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>strRemoteShare = InputBox("Enter the path of the drive path you want to search, such as . Such as c:\folder\another Folder\","Enter Value", """z:\""")<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if strRemoteShare = "" then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>MsgBox("You cancelled the dialogue box, quitting script.")<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Wscript.Quit<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'WScript.Echo "no its not a drive"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Remove the drive if its mounted...<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dim filesys<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Set filesys = CreateObject("Scripting.FileSystemObject")<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If filesys.DriveExists(strDrive) Then <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objNetwork.RemoveNetworkDrive strDrive<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End If<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Set what the share path is<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>strRemoteShare = InputBox("Enter the path of the drive you want to search. Such as \\newSever\share\blah\","Enter Value", """\\newSever\share\blah\""")<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>if strRemoteShare = "" then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>MsgBox("You cancelled the dialogue box, quitting script.")<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Wscript.Quit<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'mount the share<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objNetwork.MapNetworkDrive strDrive, strRemoteShare, False<br />
end if<br />
<br />
' Log entry -------------<br />
objFileLog.Write Now & "||ScriptInfo || || || ||Getting Files List " & vbCrLf & vbCrLf<br />
<br />
<br />
'----------- Search the path given for excel files ---------------<br />
' Run a shell script for a directory search of excel files<br />
sTempFile = oWshShell.ExpandEnvironmentStrings("%Temp%\dir.txt")<br />
oWshShell.Run "cmd.exe /c dir /s /b " + strRemoteShare + "\*.xls* > """ & sTempFile & "", 1, True<br />
<br />
' Log entry -------------<br />
objFileLog.Write now & "||ScriptInfo|| || || ||Looping through the files now " & vbCrLf & vbCrLf<br />
' Dump output of the DIR search results to a variable list<br />
Set oList = oFSO.OpenTextFile(sTempFile, 1, False)<br />
aFiles = Split(oList.ReadAll, VbCrLf)<br />
oList.Close<br />
oFSO.DeleteFile sTempFile<br />
' make the alerts from excel not show for smoother scripting and speed<br />
objExcel.DisplayAlerts = False<br />
objExcel.AskToUpdateLinks = False<br />
objExcel.ScreenUpdating = False<br />
objExcel.Visible = True<br />
<br />
<br />
<br />
<br />
<br />
' Log entry -------------<br />
objFileLog.Write Now & "||ScriptInfo || || || || Found " & Ubound(aFiles) & " files to check." & vbCrLf & vbCrLf<br />
' Loop through the file names found<span class="Apple-tab-span" style="white-space: pre;"> </span>For Each sName In (aFiles)<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Check to make sure excel is running.. if not restart it.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If Not TypeName(objExcel) = "Object" Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'strMessage = "Excel Running."<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'strMessage = "Excel Not Running."<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Set objExcel = CreateObject("Excel.Application")<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||FileNamePath ||" & sName & " ||NA ||" & pass & " ||!!!! ERROR !!!! Restarted Excel. " & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End If<br />
<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Testing - This area for testing only.. can be removed when complete<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Do some counting<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>countMe = countMe + 1<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ScriptInfo ||" & sName & " ||NA || ||File number: " & countMe & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if countMe = "10000" then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' kill the script after # of excel files...<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'WScript.Echo "5000 excels opened and closed"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'WScript.Echo listOfFiles<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Exit For<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' write name of file to current log<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Set objCurrentFile = objFSO.CreateTextFile(outCurrentFile,True)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objCurrentFile.Write sName<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objCurrentFile.close<br />
<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' This is the check if the file is open checker.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if IsWriteAccessible(sName) = "True" Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>if sName = "" or Instr( Ucase(sName), "SYSTEM VOLUME INFORMATION") <> 0 then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Weed out the blank directory and backups in SYSTEM VOLUME INFORMATION directory from the search<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||WeedOutDir ||" & sName &" ||NA ||NA ||!!!!! Information !!!!! Skipping this directory." & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' make SURE the alerts from excel not show for smoother scripting and speed resetting them with each excel book<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objExcel.DisplayAlerts = False<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objExcel.AskToUpdateLinks = False<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objExcel.ScreenUpdating = False<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objExcel.Visible = True<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Verify that the Excel FILE is not protected. If it is kill it, record it and move on<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------------------------------------------------------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>On Error Resume Next<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>set objWorkbookTestExcelFilePassword = objExcel.workbooks.open(sName,,,,"xxxx234567890OPIJKHGFHJK90887trfsgdhfjsd89jfosduifjiodsjfo)")<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If Err.Number = 1004 Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'msgbox "This workbook has a password"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ErrorExcelFilePwd ||" & sName &" ||NA ||NA ||!!!!! ERROR !!!!! Excel File is protected - Skipping." & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objWorkbookTestExcelFilePassword.Close False<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'----------- Start working on the excel file -----------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Set what Excel file to open<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>set objWorkbook = objExcel.Workbooks.Open(sName)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objWorksheetCount = objWorkbook.Worksheets.Count<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Test the workbook for protection<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>isProtected = isWorkbookProtected(objWorkbook)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>somethingFound = "False"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>needsToBeReprotectedWorkbook = "False"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Is the workbook protected?<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if isProtected = "True" then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'if not nullWBPass = "True" then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for each pass in listOfPasses<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>objWorkbook.Unprotect(pass)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Err.Clear<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Now check that if it is unprotected.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>isStillProtected = isWorkbookProtected(objWorkbook)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'msgbox "Is it still protected" & isStillProtected<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>On Error Resume Next<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>if isStillProtected = "True" then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' try the next one<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' its unprotected<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'Record the protected password.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if changeDefaultPassword = "True" then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>correctPassword = NewPassword<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>correctPassword = pass<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'tell the script that it needs to be re-protected.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>needsToBeReprotectedWorkbook = "True"<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ExcelInfoWbUnlock ||" & sName & " ||NA ||" & pass & " ||Unlocked The Workbook " & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Found the correct password and recorded it.. get out of this loop<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>next<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'END IF<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>if needsToBeReprotectedWorkbook = "False" then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'Since this was locked and it could not be unlocked exit the loop<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ExcelErrorUnlock ||" & sName &" ||" & i & " ||NA || !!!!! ERROR !!!!! Never unlocked Workbook after trying all the passwords. Workbook Status = " & isWorkbookProtected & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objWorkbook.Close False<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'Exit For<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ExcelInfoWbNotLocked ||" & sName & " ||NA || NA ||Workbook is not locked." & vbCrLf<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>needsToBeReprotectedWorkbook = "False"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Connection string area<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'Begin - Loop Through the ODBC Connections<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>For Each ODBCConnection In objWorkbook.Connections<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'Begin - Connection String Change<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Reset the connectionStringxRepalced to nothing so that if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' something is found the script can tell the script to change the value.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>connectionStringxRepalced = ""<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'The counter Loop Variable<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>countNow = 0<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Set the connectionStringx variable to what the connection is<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>connectionStringx = ODBCConnection.ODBCConnection.Connection<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'Loop Through all possible server name changes<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for each x In rngSearch<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'Search in the string of connectionStringx using the text from<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If Not InStr(1,connectionStringx,rngSearch(countNow), VBTextCompare) = 0 Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'Create the new String to replace the old one.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>connectionStringxRepalced = replace(connectionStringx,rngSearch(countNow),rngReplace(countNow), 1, -1, vbTextCompare)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>If NOT connectionStringxRepalced = "" Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ConnectionStringOld|| " & sName &"|| ||NA ||" & connectionStringx & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ConnectionStringNew|| " & sName &"|| ||NA ||" & connectionStringxRepalced & vbCrLf<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>somethingFound = "True"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ConnectionString|| " & sName &"|| || || Replaced the information in the connection string" & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>With objWorkbook.Connections(ODBCConnection.Name).ODBCConnection<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>.Connection = connectionStringxRepalced<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End With<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Found the server in the connection script Exit the FOR loop.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Exit For<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End IF<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End If<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>countNow = countNow + 1<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Next <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'End - Connection String Change<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'Begin - Command String Change<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Reset the connectionCommandTextxReplaced to nothing so that if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' something is found the script can tell the script to change the value.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>connectionCommandTextxReplaced = ""<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'The counter Loop Variable<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>countNow = 0<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Set the connectionCommandx variable to what the connection is<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>connectionCommandx = ODBCConnection.ODBCConnection.CommandText<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'Loop Through all possible server name changes<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for each x In rngSearch<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'Search in the string of connectionCommandx using the text from<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If Not InStr(1,connectionCommandx,rngSearch(countNow), VBTextCompare) = 0 Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'Create the new String to replace the old one.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>connectionCommandTextxReplaced = replace(connectionCommandx,rngSearch(countNow),rngReplace(countNow), 1, -1, vbTextCompare)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>If NOT connectionCommandTextxReplaced = "" Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ConnectionCommandOld|| " & sName &"|| ||NA ||" & connectionCommandx & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ConnectionCommandNew|| " & sName &"|| ||NA ||" & connectionCommandTextxReplaced & vbCrLf<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>somethingFound = "True"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ConnectionCommand|| " & sName &"|| || || Replaced the information in the Command string" & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>With objWorkbook.Connections(ODBCConnection.Name).ODBCConnection<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>.CommandText = connectionCommandTextxReplaced<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End With<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Found the server in the connection script Exit the FOR loop.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Exit For<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End IF<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End If<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>countNow = countNow + 1<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Next <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'End - Command String Change<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>Next<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'End - Loop Through the ODBC Connections<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Clear the array from the last sheet loop<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Erase sheetsArray<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Erase sheetsArraySheetName<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Erase sheetArrayLocked<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Erase sheetArrayPassword<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Erase sheetArrayRehide<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Set the Array Length ----<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' *** NOTE ***********************************************<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' This will make the array 1 more than needed.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' The sheet count starts with 1 and arrays start at 0.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' So when the count of the excel workbook sheets is 10<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' and is set to the array the array will have 11 spots.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' *********************************************************<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ReDim sheetsArray(objWorksheetCount)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ReDim sheetsArraySheetName(objWorksheetCount)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ReDim sheetArrayLocked(objWorksheetCount)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ReDim sheetArrayPassword(objWorksheetCount)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ReDim sheetArrayRehide(objWorksheetCount)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Begin - WorkSheet Loop Section<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Set this to false if there are no sheets that need to be unprotected it doesn't<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' give a false positive.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>thisNeverGotUnlocked = "False"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>For i = objWorksheetCount To 1 Step -1<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Set the worksheets information for this worksheet<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Set objWorksheet = objWorkbook.Worksheets(i)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "|| ExcelWSOpen|| " & sName &"|| " & i & "||NA ||" & objWorksheet.name & vbCrLf<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>sheetsArraySheetName(i) = objWorksheet.Name<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>sheetsArray(i) = i<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Check to see if its hidden<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If objWorksheet.Visible = False Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ExcelWSUnhide|| " & sName &"|| " & i & "||NA ||" & objWorksheet.name & vbCrLf<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'Its hidden unhide it.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objWorksheet.Visible = True<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>rehide = "True"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>sheetArrayRehide(i) = "True"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>sheetsArraySheetName(i) = objWorksheet.Name<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ExcelWsNotHidden|| " & sName &"|| " & i & "||NA || " & objWorksheet.name & vbCrLf<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>rehide = "False"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>sheetArrayRehide(i) = "False"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>sheetsArraySheetName(i) = objWorksheet.Name<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'does this need to be unlocked?<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if isWorksheetProtected(objWorksheet) then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ExcelWsProtected|| " & sName &"|| " & i & "||NA || " & objWorksheet.name & vbCrLf<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Yes<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>sheetArrayLocked(i) = "True"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>sheetsArraySheetName(i) = objWorksheet.Name<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'set this to true because if it doesn't get unlocked then it needs to be sent.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' to the if statement below to close the excel file<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>thisNeverGotUnlocked = "True"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'-----------------------------------------------------------------------------------------------------------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Yes it is now let try and unprotected it with a blank password.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>On Error Resume next<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'objWorksheet.Unprotect<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'Err.Clear<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Now check that if it is unprotected.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'-----------------------------------------------------------------------------------------------------------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>for each pass in listOfPasses<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'Its going to error if the password is not right so ignore errors.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>On Error Resume Next<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objWorksheet.Unprotect(pass)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'error clear<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Err.Clear<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Now check that if it is unprotected.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>isSheetStillProtected = isWorksheetProtected(objWorksheet)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if isSheetStillProtected = "True" then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' try the next one<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' its unprotected<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if changeDefaultPassword = "True" then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ExcelWsWasUnlocked|| " & sName &"|| " & i & "|| " & pass & " ||Worksheet, " & objWorksheet.name & ", unlocked.. pass was: " & pass & " it will be set too " & NewPassword &vbCrLf<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'Since the changeDefaultPassword is true, then set it to default password<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>correctSheetPassword = NewPassword<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>sheetArrayPassword(i) = NewPassword<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ExcelWsWasUnlocked|| " & sName &"|| " & i & "|| " & pass & " ||Worksheet, " & objWorksheet.name & ", unlocked.. pass was: " & pass & vbCrLf<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'Record the protected password.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>correctSheetPassword = pass<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>sheetArrayPassword(i) = pass<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'tell the script that it needs to be re-protected.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>thisNeverGotUnlocked = "False"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>isSheetStillProtected = "False"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'Not needed anymore<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'needsToBeReprotectedWorksheet = isSheetStillProtected<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Exit For<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>next<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Kill Switch - there was a sheet that was locked but never got unlocked -<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' error out this workbook.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' If this did not get set to false in the for loop unlocking the sheet<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' it never got unlocked.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If thisNeverGotUnlocked = "True" then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ErrorWsPassword ||" & sName &" ||" & i & " || || " & objWorksheet.name & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objWorkbook.Close False<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Exit For<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'No need to unlock<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>sheetArrayLocked(i) = "False"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>sheetArrayPassword(i) = "NULL"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>sheetsArraySheetName(i) = objWorksheet.Name<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>end if<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Next<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' End - WorkSheet Loop Section<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Begin - If all the sheets did<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' not get unlocked exit the workbook loop<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if thisNeverGotUnlocked = "True" then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ErrorWsPassword ||" & sName &" ||" & i & " || || !!!! ERROR !!!! Exiting Workbook - Worksheet could not be unlocked.. Password unknown." & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objWorkbook.Close False<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Begin - Do the link change<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Const xlLinkTypeExcelLinks = 1<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Const xlExcelLinks = 1<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>aLinks = objWorkbook.LinkSources(xlLinkTypeExcelLinks)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If Not IsEmpty(aLinks) Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>For i = 1 To UBound(aLinks)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>countNow = 0 <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>for each x In rngSearch<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If Not InStr(1,aLinks(i),rngSearch(countNow), VBTextCompare) = 0 Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>somethingFound = "True"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>replacedLinktext = replace(aLinks(i),rngSearch(countNow),rngReplace(countNow), 1, -1, vbTextCompare)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ExcelReplaceLink|| " & sName &"|| || || From: " & aLinks(i) & " to: " & replacedLinktext & vbCrLf<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>objWorkbook.ChangeLink aLinks(i), replacedLinktext, xlLinkTypeExcelLinks<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Exit For<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End If<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>countNow = countNow + 1<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Next <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>next<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>End If<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' End - Do the link change<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Begin - Put Sheets back to the way they were<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>For i = objWorksheetCount To 1 Step -1<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>Set objWorksheet = objWorkbook.Worksheets(i)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Relock the worksheet if it was locked<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>if sheetArrayLocked(i) = "True" then <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>objWorksheet.Protect(sheetArrayPassword(i))<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "|| ExcelWsRelocked ||" & sName &" ||" & i & " ||" & correctSheetPassword & " ||Worksheet was re-unlock. " & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Rehide the hidden sheet<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if sheetArrayRehide(i) = "True" then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>objWorksheet.Visible = False<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>rehide = "False"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "|| ExcelWsReHidden|| " & sName &"|| " & i & "||NA ||Rehidden Worksheet," & objWorksheet.Name &", Visible = " & objWorksheet.Visible & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>next<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' End - Put Sheets back to the way they were<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Relock the workbook if it was locked<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>if needsToBeReprotectedWorkbook = "True" then <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>objWorkbook.Protect(correctPassword)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ExcelReprotect ||" & sName &" || ||" & correctPassword & " ||Workbook," & objWorksheet.Name &", re-unlock." & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Set what Excel file to close<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>If somethingFound = "True" Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Check to see if this is going to be saved.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if runLive = "True" Then<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objWorkbook.Save<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ExcelSaved ||" & sName &" || || ||Workbook saved, a change were made." & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objWorkbook.Close False<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ExcelNotSaved ||" & sName &" || || ||Workbook NOT saved, no change were made." & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objWorkbook.Close False<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ExcelWbClosed ||" & sName &" || || ||Workbook Closed " & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' End - If all the sheets did not get unlocked exit the workbook loop<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'-------------------------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' End if for password protected file<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>end if<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>' Else for if of accessible file<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Else<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry -------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write now & "||ErrorWbUn-Accessible ||" & sName &" ||NA ||NA ||!!!!! ERROR !!!!! Workbook not accessible." & vbCrLf<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objWorkbook.Close False<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' End If for if of accessible file<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>End If<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>' Log entry - Make a space in between Workbook records. ------------<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objFileLog.Write vbCrLf & vbCrLf & vbCrLf &vbCrLf<br />
Next<br />
<br />
' put excel alerts back on<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objExcel.DisplayAlerts = True<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objExcel.ScreenUpdating = True<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objExcel.AskToUpdateLinks = True<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objExcel.Visible = True<br />
' Disconnect the Drive<br />
if isItADrive = vbYes then<br />
else<br />
objNetwork.RemoveNetworkDrive strDrive<br />
end if<br />
msgbox "Processed " & countMe & " Excel Files."<br />
'Close the Log File<br />
objFileLog.Close</blockquote>
<br />
<br />
<br />
<br />Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com1tag:blogger.com,1999:blog-758009065572970321.post-67764154641567000312015-03-20T09:15:00.003-04:002015-03-20T09:15:41.408-04:00Get a list of IPs VIA System.Net.DnsSo needed to look up more IPs via scripts again. The last script I used worked great but didn't grab everything because of the environment I am in. So I took the rest of the systems I needed IPs for and noticed I could use nslookup to get the IPs. Of course nslookup is not made for automation so I went looking again. And again powershell came to the rescue.<br />
<br />
In the System.Net.Dns Class.<br />
<br />
The script i found came from this website.<br />
<a href="http://community.spiceworks.com/scripts/show/1201-powershell-script-dns-forward-lookup-script-with-auto-generate-excel-file">http://community.spiceworks.com/scripts/show/1201-powershell-script-dns-forward-lookup-script-with-auto-generate-excel-file</a><br />
<br />
Here is the script from that page. It basically grabs a list of names, or ips from text file you supply and it spits back out into an excel document.. SWEEET...<br />
<br />
<br />
<pre class="PowerShellColorizedScript" style="background-color: #eeeeee; clear: both; margin-bottom: 24px; overflow: auto; padding: 12px; tab-size: 4; word-wrap: normal;"><span style="font-family: Consolas, Monaco, Menlo, Courier, Verdana, sans-serif;"><span style="font-size: 14px; line-height: 24px;"> </span></span><span style="background-color: transparent; font-size: 14px; line-height: 24px;"><span style="font-family: Consolas, Monaco, Menlo, Courier, Verdana, sans-serif;">###########################################################################
#
# NAME: DNS Forward Lookup Script with Auto Generate Excel File
#
# AUTHOR: J.Malek (www.malekjakir.com) Email: malek dot one zero four zero at gmail dot com
#
# COMMENT: This script can be used to check list of Servers for Forward NSLookup to get the IP Addresses.
# Line#29 - Please Change the path of Servers.txt to your file location.
# NOTE: One server name per line.
#
# VERSION HISTORY:
# 1.0 2/17/2012 -
#
###########################################################################
$ErrorActionPreference = "silentlycontinue"
$a = New-Object -comobject Excel.Application
$a.visible = $True
$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)
$c.Cells.Item(1,1) = "Server Hostname"
$c.Cells.Item(1,2) = "IP Address"
$d = $c.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True
$intRow = 2
$colComputers = get-content "C:\SCRIPTS\DNS_Lookup\ForwardLookup\Servers.txt"
foreach ($strComputer in $colComputers)
{
$FWDIP = [System.Net.Dns]::GetHostAddresses($strComputer) | Add-Member -Name HostName -Value $strComputer -MemberType NoteProperty -PassThru | Select HostName, IPAddressToString
$c.Cells.Item($intRow,1) = $FWDIP.Hostname
$c.Cells.Item($intRow,2) = $FWDIP.IPAddressToString
$intRow = $intRow + 1
}
$d.EntireColumn.AutoFit()
cls
Write-Host "######## This Script is completed now ########"</span></span></pre>
Thank you internet..<br />
<br />
<br />Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-47562190212193591742015-03-19T10:07:00.001-04:002015-03-19T10:07:30.021-04:00Get IP addresses remotelySo recently had a task to get all the IPs from remote computers. Well it turns out this isn't as easy as it should be. After some major googleing I ended up using a PS script I found here, <a href="http://techibee.com/powershell/powershell-get-ip-address-subnet-gateway-dns-serves-and-mac-address-details-of-remote-computer/1367">http://techibee.com/powershell/powershell-get-ip-address-subnet-gateway-dns-serves-and-mac-address-details-of-remote-computer/1367</a>.<br />
<br />
Here is the script.<br />
<br />
<pre class="PowerShellColorizedScript" style="background-color: #eeeeee; clear: both; font-family: Consolas, Monaco, Menlo, Courier, Verdana, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 24px; overflow: auto; padding: 12px; tab-size: 4; word-wrap: normal;"><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">[</span><span style="color: lightblue; margin: 0px; padding: 0px; word-wrap: break-word;">cmdletbinding</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">(</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">)</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">]</span>
<span style="color: darkblue; margin: 0px; padding: 0px; word-wrap: break-word;">param</span> <span style="margin: 0px; padding: 0px; word-wrap: break-word;">(</span>
<span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">[</span><span style="color: lightblue; margin: 0px; padding: 0px; word-wrap: break-word;">parameter</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">(</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">ValueFromPipeline</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">=</span><span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$true</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">,</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">ValueFromPipelineByPropertyName</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">=</span><span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$true</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">)</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">]</span>
<span style="color: teal; margin: 0px; padding: 0px; word-wrap: break-word;">[string[]]</span><span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$ComputerName</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">=</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$env:computername</span>
<span style="margin: 0px; padding: 0px; word-wrap: break-word;">)</span>
<span style="color: darkblue; margin: 0px; padding: 0px; word-wrap: break-word;">begin</span> <span style="margin: 0px; padding: 0px; word-wrap: break-word;">{</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">}</span>
<span style="color: darkblue; margin: 0px; padding: 0px; word-wrap: break-word;">process</span> <span style="margin: 0px; padding: 0px; word-wrap: break-word;">{</span>
<span style="color: darkblue; margin: 0px; padding: 0px; word-wrap: break-word;">foreach</span> <span style="margin: 0px; padding: 0px; word-wrap: break-word;">(</span><span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$Computer</span> <span style="color: darkblue; margin: 0px; padding: 0px; word-wrap: break-word;">in</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$ComputerName</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">)</span> <span style="margin: 0px; padding: 0px; word-wrap: break-word;">{</span>
<span style="color: darkblue; margin: 0px; padding: 0px; word-wrap: break-word;">if</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">(</span><span style="color: blue; margin: 0px; padding: 0px; word-wrap: break-word;">Test-Connection</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-ComputerName</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$Computer</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-Count</span> <span style="color: purple; margin: 0px; padding: 0px; word-wrap: break-word;">1</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-ea</span> <span style="color: purple; margin: 0px; padding: 0px; word-wrap: break-word;">0</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">)</span> <span style="margin: 0px; padding: 0px; word-wrap: break-word;">{</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$Networks</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">=</span> <span style="color: blue; margin: 0px; padding: 0px; word-wrap: break-word;">Get-WmiObject</span> <span style="color: blueviolet; margin: 0px; padding: 0px; word-wrap: break-word;">Win32_NetworkAdapterConfiguration</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-ComputerName</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$Computer</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">|</span> <span style="color: blue; margin: 0px; padding: 0px; word-wrap: break-word;">?</span> <span style="margin: 0px; padding: 0px; word-wrap: break-word;">{</span><span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$_</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">.</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">IPEnabled</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">}</span>
<span style="color: darkblue; margin: 0px; padding: 0px; word-wrap: break-word;">foreach</span> <span style="margin: 0px; padding: 0px; word-wrap: break-word;">(</span><span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$Network</span> <span style="color: darkblue; margin: 0px; padding: 0px; word-wrap: break-word;">in</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$Networks</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">)</span> <span style="margin: 0px; padding: 0px; word-wrap: break-word;">{</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$IPAddress</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">=</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$Network</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">.</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">IpAddress</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">[</span><span style="color: purple; margin: 0px; padding: 0px; word-wrap: break-word;">0</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">]</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$SubnetMask</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">=</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$Network</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">.</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">IPSubnet</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">[</span><span style="color: purple; margin: 0px; padding: 0px; word-wrap: break-word;">0</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">]</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$DefaultGateway</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">=</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$Network</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">.</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">DefaultIPGateway</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$DNSServers</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">=</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$Network</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">.</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">DNSServerSearchOrder</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$IsDHCPEnabled</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">=</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$false</span>
<span style="color: darkblue; margin: 0px; padding: 0px; word-wrap: break-word;">If</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">(</span><span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$network</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">.</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">DHCPEnabled</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">)</span> <span style="margin: 0px; padding: 0px; word-wrap: break-word;">{</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$IsDHCPEnabled</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">=</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$true</span>
<span style="margin: 0px; padding: 0px; word-wrap: break-word;">}</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$MACAddress</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">=</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$Network</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">.</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">MACAddress</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$OutputObj</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">=</span> <span style="color: blue; margin: 0px; padding: 0px; word-wrap: break-word;">New-Object</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-Type</span> <span style="color: blueviolet; margin: 0px; padding: 0px; word-wrap: break-word;">PSObject</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$OutputObj</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">|</span> <span style="color: blue; margin: 0px; padding: 0px; word-wrap: break-word;">Add-Member</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-MemberType</span> <span style="color: blueviolet; margin: 0px; padding: 0px; word-wrap: break-word;">NoteProperty</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-Name</span> <span style="color: blueviolet; margin: 0px; padding: 0px; word-wrap: break-word;">ComputerName</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-Value</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$Computer</span><span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">.</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">ToUpper</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">(</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">)</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$OutputObj</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">|</span> <span style="color: blue; margin: 0px; padding: 0px; word-wrap: break-word;">Add-Member</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-MemberType</span> <span style="color: blueviolet; margin: 0px; padding: 0px; word-wrap: break-word;">NoteProperty</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-Name</span> <span style="color: blueviolet; margin: 0px; padding: 0px; word-wrap: break-word;">IPAddress</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-Value</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$IPAddress</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$OutputObj</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">|</span> <span style="color: blue; margin: 0px; padding: 0px; word-wrap: break-word;">Add-Member</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-MemberType</span> <span style="color: blueviolet; margin: 0px; padding: 0px; word-wrap: break-word;">NoteProperty</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-Name</span> <span style="color: blueviolet; margin: 0px; padding: 0px; word-wrap: break-word;">SubnetMask</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-Value</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$SubnetMask</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$OutputObj</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">|</span> <span style="color: blue; margin: 0px; padding: 0px; word-wrap: break-word;">Add-Member</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-MemberType</span> <span style="color: blueviolet; margin: 0px; padding: 0px; word-wrap: break-word;">NoteProperty</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-Name</span> <span style="color: blueviolet; margin: 0px; padding: 0px; word-wrap: break-word;">Gateway</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-Value</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$DefaultGateway</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$OutputObj</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">|</span> <span style="color: blue; margin: 0px; padding: 0px; word-wrap: break-word;">Add-Member</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-MemberType</span> <span style="color: blueviolet; margin: 0px; padding: 0px; word-wrap: break-word;">NoteProperty</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-Name</span> <span style="color: blueviolet; margin: 0px; padding: 0px; word-wrap: break-word;">IsDHCPEnabled</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-Value</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$IsDHCPEnabled</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$OutputObj</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">|</span> <span style="color: blue; margin: 0px; padding: 0px; word-wrap: break-word;">Add-Member</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-MemberType</span> <span style="color: blueviolet; margin: 0px; padding: 0px; word-wrap: break-word;">NoteProperty</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-Name</span> <span style="color: blueviolet; margin: 0px; padding: 0px; word-wrap: break-word;">DNSServers</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-Value</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$DNSServers</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$OutputObj</span> <span style="color: darkgrey; margin: 0px; padding: 0px; word-wrap: break-word;">|</span> <span style="color: blue; margin: 0px; padding: 0px; word-wrap: break-word;">Add-Member</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-MemberType</span> <span style="color: blueviolet; margin: 0px; padding: 0px; word-wrap: break-word;">NoteProperty</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-Name</span> <span style="color: blueviolet; margin: 0px; padding: 0px; word-wrap: break-word;">MACAddress</span> <span style="color: navy; margin: 0px; padding: 0px; word-wrap: break-word;">-Value</span> <span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$MACAddress</span>
<span style="color: orangered; margin: 0px; padding: 0px; word-wrap: break-word;">$OutputObj</span>
<span style="margin: 0px; padding: 0px; word-wrap: break-word;">}</span>
<span style="margin: 0px; padding: 0px; word-wrap: break-word;">}</span>
<span style="margin: 0px; padding: 0px; word-wrap: break-word;">}</span>
<span style="margin: 0px; padding: 0px; word-wrap: break-word;">}</span>
<span style="color: darkblue; margin: 0px; padding: 0px; word-wrap: break-word;">end</span> <span style="margin: 0px; padding: 0px; word-wrap: break-word;">{</span><span style="margin: 0px; padding: 0px; word-wrap: break-word;">}</span></pre>
I then used a txt file to input all the servers into the script. This was in the comments sections so I will add it in here..<br />
<br />
<pre class="PowerShellColorizedScript" style="background-color: #eeeeee; clear: both; margin-bottom: 24px; overflow: auto; padding: 12px; tab-size: 4; word-wrap: normal;"><span style="font-family: Consolas, Monaco, Menlo, Courier, Verdana, sans-serif;"><span style="font-size: 14px; line-height: 24px;">"get-Content c:\temp\computers.txt | Get-IpDetails.ps1 | ft -auto
where c:\temp\computers.txt is the file that contains computers list."
I used this:
</span></span><span style="background-color: transparent; font-size: 14px; line-height: 24px;"><span style="font-family: Consolas, Monaco, Menlo, Courier, Verdana, sans-serif;">get-Content .\computers.txt | .\Get-IpDetails.ps1 | ft -auto</span></span></pre>
<div style="background-color: white; font-family: Verdana, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 24px; padding: 0px; word-wrap: break-word;">
Also remember that you are running a scriptlet so you need to set this unless you have something else done on your system. </div>
<pre class="PowerShellColorizedScript" style="background-color: #eeeeee; clear: both; margin-bottom: 24px; overflow: auto; padding: 12px; tab-size: 4; word-wrap: normal;"><span style="font-family: Consolas, Monaco, Menlo, Courier, Verdana, sans-serif;"><span style="font-size: 14px; line-height: 24px;">Set-ExecutionPolicy Unrestricted</span></span></pre>
Enjoy.<br />
<br />Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com1tag:blogger.com,1999:blog-758009065572970321.post-48363037177883648622013-12-13T10:57:00.000-05:002013-12-19T09:57:57.548-05:00Error 0x80070002 occurred while verifying known folder<h2>
ISSUE:</h2>
Server is getting a general Warning message speradically a lot. Its a Warning so not a big deal but it does raise concern.<br />
Here is the error:<br />
<br />
<div style="background-color: white; height: 200px; overflow: auto; padding: 10px;">
- System<br />
- Provider<br />
[ Name] Microsoft-Windows-KnownFolders<br />
[ Guid] {8939299F-2315-4C5C-9B91-ABB86AA0627D}<br />
EventID 1002<br />
Version 0<br />
Level 3<br />
Task 0<br />
Opcode 0<br />
Keywords 0x8000000000000000<br />
- TimeCreated<br />
[ SystemTime] 2013-12-13T05:30:22.504632600Z<br />
EventRecordID 6590<br />
Correlation<br />
- Execution<br />
[ ProcessID] 10080<br />
[ ThreadID] 5392<br />
Channel Microsoft-Windows-Known Folders API Service<br />
Computer **********************<br />
- Security<br />
[ UserID] S-1-5-18<br />
- EventData<br />
hrError 0x80070003<br />
FolderId {B97D20BB-F46A-4C97-BA10-5E3608430854}<br />
Path C:\Windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup </div>
<br />
So yeah a lot of these are happening with various folders. <br />
<br />
<h2>
RESOLUTION:</h2>
I was doing some reading and found out that this specific error had to do with some folders missing in a default profile area. One of the readings fixes was, make the missing folders. What a great idea.<br />
<br />
There are several easy ways to make the folders:<br />
<br />
CMD<br />
Use can use the MD, make directory option.<br />
<br />
<div style="background-color: white; height: 200px; overflow: auto; padding: 10px;">
MD "C:\Windows\system32\config\systemprofile\AppData\Roaming\Microsoft\Windows\Start Menu\Programs"</div>
<br />
Windows Explorer<br />
Just go to the folder area and make the missing folder. Make sure you make the full path if more than one folder is missing.<br />
<br />
Copy the Default profile on the system.<br />
Every system has a profile that it uses as a template for making a new user profile. So I copied it and pasted it in the missing directory. Note: I did not verify that ALL the missing folders where there. I figured since its a warning, I will wait out the log file and see any othere missing folders show up.<br />
<br />
<br />
Update: welp that didn't work.. Still getting Error <br /><br />0x80070002 occurred while verifying known folder {b4bfcc3a-db2c-424c-b029-7fe99a87c641} with path 'C:\Windows\system32\config\systemprofile\Desktop'. <br /><br />and it does exist.<br />
<br />
So i did some more digging and ran across this post, <a href="http://tqaforum.net/discussion/37146/known-folders-errors-in-event-viewer/p4">http://tqaforum.net/discussion/37146/known-folders-errors-in-event-viewer/p4</a>, about how there are 2 system folders in windows 64 bit.. I totally forgot this. So I copied the folders to the SysWOW64. I am thinking this will fix the issue. We shall see.<br />
<br />Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com1tag:blogger.com,1999:blog-758009065572970321.post-70124947601365855052013-12-10T14:40:00.001-05:002013-12-10T14:44:54.683-05:00I want to make a single photo public on facebook.<h2>
ISSUE:</h2>
You are a good Facebook user and you have your photo albums not shared out to the public. Good job. Now you share some of them but not EVERYONE can see them. Maybe just friends or friends of friends.
<br />
<br />
<h2>
The Solution:</h2>
1. Click your "Photos" on Facebook, OR, click the photo you want to share if it's in front of you already, then go to Step 4 if you just opened the picture.
<br />
2. Go to "Your Photos"
<br />
3. Find the picture to share to the public<br />
4. Now click the "Edit" link.<br />
5. Now click the link beside "Done Editing" .
<br />
Then choose what viewing access you want to give.<br />
6. Click done Editing.
<br />
<br />
Now the share access has been changed.Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-13928397199650947052013-12-04T17:00:00.000-05:002013-12-05T12:43:46.792-05:00Windows Command-Line Reference A-Z List (not 2012)<br />
<h2>
INFO:</h2>
Here is nice little list of commands that can be run on windows from the command line. This applies to: Windows 7, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, and Windows Vista.<br />
<br />
<a href="http://technet.microsoft.com/en-us/library/cc772390(v=ws.10).aspx">http://technet.microsoft.com/en-us/library/cc772390(v=ws.10).aspx</a><br />
<br />
<h2>
<b>NOTES</b><span style="font-weight: normal;">: </span></h2>
<div>
Some of the commands only work for specific OS's. Example "Freedisk" is a Vista and Windows server 2008 command. So check before you try and use. </div>
Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-81371525662023000492013-12-04T16:48:00.001-05:002013-12-04T16:48:18.316-05:00Give me the info for the people of a group.I started to get where I wanted to go with a previous post of getting user information so I decided to break down some information.<br />
<br />
So I ended up with this nice little chunk of code that gave the members of a group.<br />
<br />
<i><b>The Code</b></i><br />
<div style="background-color: white; overflow: auto; padding: 10px;">
dsquery group -samid "AdminsGroup" | dsget group -members</div>
<br />
This gives a decent amount of info, but it's basically unusable for normal readable information.<br />
<br />
It gives back information something like this "CN=c-hean,OU=USERS,OU=ESF,OU=EN,OU=BIGOU,DC=STUPIDOMAIN,DC=COM".<br />
<br />
So I dug into things a little more and came up with this. Let's use the information from the previous script and add " | dsget user -display" to get the users information.<br />
<i>Read more about dsget user by going here. <a href="http://technet.microsoft.com/en-us/library/cc732535.aspx">http://technet.microsoft.com/en-us/library/cc732535.aspx</a></i><br />
<br />
<i><b>The Code</b></i><br />
<div style="background-color: white; overflow: auto; padding: 10px;">
dsquery group -samid "AdminsGroup" | dsget group -members | dsget user -display</div>
<br />
Now it cleans it up and displays the names of the users instead of the full Distinguished Name, like "Smith, Smith".<br />
<br />
There is a lot of other information you can get from your script by just changing a couple of the parameters. So for example if you want First Name, Middle Intial and Last Name just change it to this " -fn -mi -ln" instead of "-display". Now it shows "Bob R Smith".<br />
<h4>
<i style="font-weight: normal;"><b>The Code</b></i></h4>
<div style="background-color: white; overflow: auto; padding: 10px;">
dsquery group -samid "AdminsGroup" | dsget group -members | dsget user -fn -mi -ln</div>
<br />
<br />
<h2>
<b>NOTES:</b></h2>
Please note somethings that this might give you is an error if one of the "users" is actually a "group" in the group you searched. You will get something like this<i> "dsget failed:CN=Service Desk,OU=GROUPS,OU=ESF,OU=EN,OU=BIGOU,DC=STUPIDOMAIN,DC=COM".</i><br />
<i>:The object class of the target does not match the one specified on the command</i><br />
<i>line.".</i><br />
This tells us that the groups "Service Desk" failed to give us the information you are looking for because it is a "group" not a "user".<br />
<br />
I am sure there is a way around this but thats for another time.Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0tag:blogger.com,1999:blog-758009065572970321.post-60158799824567444962013-12-04T09:02:00.000-05:002013-12-04T09:05:27.140-05:00Outlook Sort Your Emails by Conversation in Outlook 2010<h2>
THINGS TO SHARE</h2>
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="background-color: transparent; float: right; text-align: right;"><tbody>
<tr><td style="text-align: center;"><a href="http://cdn.howtogeek.com/wp-content/uploads/2010/05/sshot20100524114516.png" imageanchor="1" style="clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" src="http://cdn.howtogeek.com/wp-content/uploads/2010/05/sshot20100524114516.png" height="320" width="228" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><div style="text-align: left;">
<i>Image from:</i></div>
<div style="text-align: left;">
<a href="https://www.blogger.com/%C2%A0http://www.howtogeek.com/howto/17937/sort-your-emails-by-conversation-in-outlook-2010/%C2%A0"><i>http://www.howtogeek.com/howto</i></a></div>
<div style="text-align: left;">
<a href="https://www.blogger.com/%C2%A0http://www.howtogeek.com/howto/17937/sort-your-emails-by-conversation-in-outlook-2010/%C2%A0"><i>/17937/sort-your-emails-by-</i></a></div>
<div style="text-align: left;">
<a href="https://www.blogger.com/%C2%A0http://www.howtogeek.com/howto/17937/sort-your-emails-by-conversation-in-outlook-2010/%C2%A0"></a><a href="https://www.blogger.com/%C2%A0http://www.howtogeek.com/howto/17937/sort-your-emails-by-conversation-in-outlook-2010/%C2%A0"><i>conversation-in-outlook-2010/ </i></a></div>
</td></tr>
</tbody></table>
I had come across something recently and had to share it.<br />
<br />
If you have Outlook 2010 you can set your folders to be in conversation views. With this view you can see emails that are associated to an email. This not only shows emails from the current folder but ANY folder in your email account.<br />
<br />
For example if you have a message come in from someone about something and you had filed the previous email about that topic in a separate folder, for organizational purposes, you will see that other email show as a conversation under that incoming message. <br />
<br />
It sounds more difficult than it really it is. It is actually VERY easy to do and VERY easy to undo if you don't like it.<br />
<br />
Check it out.<br />
<br />
I would do a whole write up on it but why when others have already. Here is a link to a good write up of it.<br />
<a href="http://www.howtogeek.com/howto/17937/sort-your-emails-by-conversation-in-outlook-2010/">http://www.howtogeek.com/howto/17937/sort-your-emails-by-conversation-in-outlook-2010/</a>Edhttp://www.blogger.com/profile/18020014571721334925noreply@blogger.com0