Mike Says Meh The blog of Sys Admin Mike Kauspedas

7Aug/150

Powershell script to collect a dump of a specific application pool

Procdump needs to be installed on the system. (procdump -i).


Import-Module WebAdministration
$apps = dir IIS:\AppPools\ | Select-Object -expand name
Write-host "Application Pools on this server:" -foregroundcolor red -backgroundcolor yellow
Write-Output $apps
$appname = Read-Host "Enter AppPool Name"
$apid = Get-WmiObject -NameSpace 'root\WebAdministration' -class 'WorkerProcess' -ComputerName 'LocalHost' | Where-Object {$_.AppPoolName -like "$appname"} | Select-Object -expand processId
procdump -ma -r $apid

First we import the webadmin module. Then list out the application pools on the server so you don't need to open IIS or run appcmd list wps. Then it asks you for the name of the app pool which you can now copy and paste from the list provided. Then it finds the process ID and invokes procdump to take a full user dump with reflection (-r) to prevent the application pool from going down.

I did some very minor testing by just running apache bench on a site to create a bunch of requests and then running this script to see if it brings it down. All my requests were successful and my DotNetNuke site didn't warm back up. I'm not 100% confident this is production safe, but at least it's ready for testing.

Filed under: Tech No Comments
29Jul/150

Replace command prompt with Windows Powershell in Windows 10

I'm an early adopter, yay! Well, actually I have a 2 in 1 laptop so Windows 10 seemed to make sense and I decided to upgrade today after reading about it. It's basically what Windows 8 should have been, although I like Win8 as well. Anywho, maybe this was availble in Win8 as well, but you can replace cmd with ps1!

1. Right click on your task bar and click properties.

2. Click on navigation and check the box to replace command prompt.

replace cmd with ps1

 

3. Now when you right click on the start menu button you will see Powershell instead of command prompt.

 

replace cmd with ps1 2

Filed under: Tech No Comments
15Jul/150

How to remove all partitions from a disk

Here is an old one that I have been using for years and never thought to document here on my site. Btw, I use this blog a lot for my own documentation. Reason 1 to blog in IT. Want to get rid of everything on a drive? I mean everything, all partitions, data, EVERYTHING. So keep this in mind. Because if you want to save anything make sure to back it up first. Also, this doesn't completely wipe the drive, it could still be recovered using some utilities. If you want a military grade wipe go shoot it a few times, or use one of those military grade drive wiper cleaners, or toss it in a really hot fire while you're camping. Probably easier to use the software drive wipers.

1. Open command prompt as administrator.

2. Type diskpart and hit enter.

3. Type list disk and hit enter.

4. View the disks in the list and type select disk X with X being the number of the disk you want to wipe. Be very careful, triple check that list because you don't want to wipe the wrong drive. In my example I had 3 disks attached to my system but I only wanted to wipe one.

5. After you select the disk just type clean and hit enter. Here is what you should see.

C:\Windows\system32>diskpart

Microsoft DiskPart version 6.3.9600

Copyright (C) 1999-2013 Microsoft Corporation.

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          167 GB      0 B
  Disk 1    Online          298 GB      0 B        *
  Disk 2    Online          465 GB      0 B

DISKPART> select disk 2

Disk 2 is now the selected disk.

DISKPART> clean

DiskPart succeeded in cleaning the disk.

6. Voila, it's like a brand new hard drive.

Filed under: Tech No Comments
17Jun/150

Show classic ASP errors in Azure

Here is the web.config to show classic ASP (.asp files) in Azure, or in my case Windows Azure Pack with websites.

<configuration>
   <system.webServer>
		<asp scriptErrorSentToBrowser="true"/>
		<httpErrors existingResponse="PassThrough"/>
		<!--<httpErrors errorMode="Detailed"/>-->
   </system.webServer>
</configuration>

I commented out detailed error messages. With that enabled it would not show the classic ASP errors.

Filed under: Tech No Comments
13Jun/150

Fix Failed to retrieve configuration information. in Windows Azure pack Websites

Did you try enabling failed request tracing for a web site in the admin portal for Windows Azure Pack: Websites? And now you're getting this error when you try to open the configure tab?

Failed to retrieve configuration information.: Please try again. If the problem persists, contact support.

WAP error

Thanks to a kind gentleman on the WAP forums I got the module needed in powershell to edit the websites config. Here is how to fix it.

  1. From the controller open powershell as administrator the run the commands below.
  2. > Import-Module websitesdev
  3. > Set-WebSitesSiteConfig -name <sitename> -RequestTracingEnabled $false

Replace sitename with your site name in the portal. The site name can be found under your Cloud > Websites and the name column.

WAP portal

Here is the output from my CN (controller server).

PS C:\Windows\system32> Import-Module websitesdev
PS C:\Windows\system32> Set-WebSitesSiteConfig -name bake -RequestTracingEnabled $false
Configuration for website bake has been updated.

Filed under: Tech No Comments
29May/150

Dynamic vs Fixed Disk Benchmarks – Dynamic is faster

In the past I've never noticed much gain from going to a fixed disk over dynamic so I decided to finally put it to the test. I tested with two different disk arrays, one a slow SATA using storage spaces (RAID1+0) and another using SSD in straight RAID 0. Each array has 4 disks. Each connected over SATA600. The speed of the disks ultimately doesn't matter, I just want to find out if fixed really is faster than dynamic. I'm using crystal disk mark 4.0.1 x64 inside a VM. I ran two tests each, 3 passes with a 1GB file.

I first tested with SSD and after the results I thought maybe it was just SSD since those disks are so fast anyway. Maybe no latency wipes out any performance loss you get with the overhead of dynamic.

Dynamic Test 1
Sequential Read (Q= 32,T= 1) :  5568.709 MB/s
Sequential Write (Q= 32,T= 1) :   662.037 MB/s
Random Read 4KiB (Q= 32,T= 1) :   139.494 MB/s [ 34056.2 IOPS]
Random Write 4KiB (Q= 32,T= 1) :   123.682 MB/s [ 30195.8 IOPS]
Sequential Read (T= 1) :   579.854 MB/s
Sequential Write (T= 1) :   576.732 MB/s
Random Read 4KiB (Q= 1,T= 1) :    19.219 MB/s [  4692.1 IOPS]
Random Write 4KiB (Q= 1,T= 1) :    34.639 MB/s [  8456.8 IOPS]

Dynamic Test 2
Sequential Read (Q= 32,T= 1) :  4511.435 MB/s
Sequential Write (Q= 32,T= 1) :   662.157 MB/s
Random Read 4KiB (Q= 32,T= 1) :   140.051 MB/s [ 34192.1 IOPS]
Random Write 4KiB (Q= 32,T= 1) :   123.475 MB/s [ 30145.3 IOPS]
Sequential Read (T= 1) :   576.089 MB/s
Sequential Write (T= 1) :   575.869 MB/s
Random Read 4KiB (Q= 1,T= 1) :    19.542 MB/s [  4771.0 IOPS]
Random Write 4KiB (Q= 1,T= 1) :    33.126 MB/s [  8087.4 IOPS]

Fixed Test 1
Sequential Read (Q= 32,T= 1) :   700.012 MB/s
Sequential Write (Q= 32,T= 1) :   659.203 MB/s
Random Read 4KiB (Q= 32,T= 1) :   140.867 MB/s [ 34391.4 IOPS]
Random Write 4KiB (Q= 32,T= 1) :   124.820 MB/s [ 30473.6 IOPS]
Sequential Read (T= 1) :   570.374 MB/s
Sequential Write (T= 1) :   570.917 MB/s
Random Read 4KiB (Q= 1,T= 1) :    18.859 MB/s [  4604.2 IOPS]
Random Write 4KiB (Q= 1,T= 1) :    34.872 MB/s [  8513.7 IOPS]

Fixed test 2
Sequential Read (Q= 32,T= 1) :   699.533 MB/s
Sequential Write (Q= 32,T= 1) :   656.096 MB/s
Random Read 4KiB (Q= 32,T= 1) :   141.714 MB/s [ 34598.1 IOPS]
Random Write 4KiB (Q= 32,T= 1) :   125.472 MB/s [ 30632.8 IOPS]
Sequential Read (T= 1) :   584.835 MB/s
Sequential Write (T= 1) :   568.106 MB/s
Random Read 4KiB (Q= 1,T= 1) :    18.880 MB/s [  4609.4 IOPS]
Random Write 4KiB (Q= 1,T= 1) :    35.024 MB/s [  8550.8 IOPS]

Slower SATA now. Read is awesome, incredibly high. But those numbers are consistent in SSD as well so I don't think it's a fluke.

Dynamic test 1
Sequential Read (Q= 32,T= 1) :  1768.289 MB/s
Sequential Write (Q= 32,T= 1) :    25.291 MB/s
Random Read 4KiB (Q= 32,T= 1) :     6.339 MB/s [  1547.6 IOPS]
Random Write 4KiB (Q= 32,T= 1) :     0.304 MB/s [    74.2 IOPS]
Sequential Read (T= 1) :    67.744 MB/s
Sequential Write (T= 1) :    26.213 MB/s
Random Read 4KiB (Q= 1,T= 1) :     0.593 MB/s [   144.8 IOPS]
Random Write 4KiB (Q= 1,T= 1) :     0.310 MB/s [    75.7 IOPS]

Dynamic test 2
Sequential Read (Q= 32,T= 1) :  1723.136 MB/s
Sequential Write (Q= 32,T= 1) :    25.242 MB/s
Random Read 4KiB (Q= 32,T= 1) :     6.186 MB/s [  1510.3 IOPS]
Random Write 4KiB (Q= 32,T= 1) :     0.315 MB/s [    76.9 IOPS]
Sequential Read (T= 1) :    66.275 MB/s
Sequential Write (T= 1) :    25.581 MB/s
Random Read 4KiB (Q= 1,T= 1) :     0.565 MB/s [   137.9 IOPS]
Random Write 4KiB (Q= 1,T= 1) :     0.312 MB/s [    76.2 IOPS]

Fixed test 1
Sequential Read (Q= 32,T= 1) :    67.003 MB/s
Sequential Write (Q= 32,T= 1) :    24.195 MB/s
Random Read 4KiB (Q= 32,T= 1) :     0.658 MB/s [   160.6 IOPS]
Random Write 4KiB (Q= 32,T= 1) :     0.264 MB/s [    64.5 IOPS]
Sequential Read (T= 1) :    65.013 MB/s
Sequential Write (T= 1) :    25.376 MB/s
Random Read 4KiB (Q= 1,T= 1) :     0.607 MB/s [   148.2 IOPS]
Random Write 4KiB (Q= 1,T= 1) :     0.263 MB/s [    64.2 IOPS]

Fixed test 2
Sequential Read (Q= 32,T= 1) :    77.594 MB/s
Sequential Write (Q= 32,T= 1) :    24.769 MB/s
Random Read 4KiB (Q= 32,T= 1) :     0.636 MB/s [   155.3 IOPS]
Random Write 4KiB (Q= 32,T= 1) :     0.261 MB/s [    63.7 IOPS]
Sequential Read (T= 1) :    65.016 MB/s
Sequential Write (T= 1) :    25.586 MB/s
Random Read 4KiB (Q= 1,T= 1) :     0.614 MB/s [   149.9 IOPS]
Random Write 4KiB (Q= 1,T= 1) :     0.269 MB/s [    65.7 IOPS]

I also did some more testing with Atto and got the same results. In each case Dynamic was always faster than fixed. I'm confused ...

Dynamic test

Testing dynamic vhdx

Testing dynamic vhdx

Fixed test

testing fixed vhdx

testing fixed vhdx

To be honest, they are pretty much even in performance, aside from those crazy read numbers. But it's also clear that dynamic edges out fixed. Maybe it's my environment or something else, because everything online says Fixed should be faster. There are even other bench marks.

Filed under: Tech No Comments
27May/150

Cannot add shared web worker role to Windows Azure Pack Websites

Ran into this issue after the CU6 update. Turns our it is an issue with the update. I believe Microsoft is pushing everyone to the new MMC console instead of the web portal for admin tasks. This could be part of that effort. If you are seeing these errors when adding a new web worker role in WAP:WS (Windows Azure Pack with the Websites role ) try adding the new role through the controller server.

My post to the azure forums is here.

Error in the web portal:
Please try again. If the problem persists, contact support.

Error in event logs (MgmtSvc-AdminSite) on the adminhub.
Error:ProtocolException: The remote server returned an unexpected response: (400) Bad Request.
<Exception>
<Type>ProtocolException</Type>
<Message>The remote server returned an unexpected response: (400) Bad Request.</Message>
<StackTrace><![CDATA[

And this. (I replaced the partial server name with MEHMEH)

Rest client received unsucessful response message with status code '404' and body '{"Code":"NotFound","Message":"Server MEHMEH is not accessible. Could not connect to the server 'MEHMEH'. This may be because the server is not available. Make sure the server name or address is correct and try again.","ExtendedCode":"10002","MessageTemplate":"Server {0} is not accessible.","Parameters":["MEHMEH"],"InnerErrors":null}'.

Work around:

  1. Login to the controller server.
  2. Open the Websites Management Console MMC.
  3. Click on Servers.
  4. Click Add Server from the right hand menu.
  5. Type in the name, choose the role (webworker), choose mode (shared), and choose large (WAP ignores this on shared roles).

  6. The role will add and immediately appear in the web portal as well.
Filed under: Tech No Comments
21May/150

Powershell to get all MAC addresses of each virtual machine on a host and export to tab delimited file

This will spit out the MAC address and name of each virtual machine on a host to a text file. You can then clean the file up and throw it in Excel. I had to use this to clean up duplicate MACs in two different clusters because I'm a bad sys admin and didn't change the MAC address pools on the hosts or SCVMM.

Get-VM|Get-VMNetworkAdapter | Select-Object VMName, MACAddress | Export-Csv -delimiter "`t" -path C:\macs.txt

It comes out looking like this and I just use a find and replace to remove all the " so I can throw it in Excel. Then I use Excel to find and sort duplicates.

#TYPE Selected.Microsoft.HyperV.PowerShell.VMNetworkAdapter
"VMName" "MacAddress"
"server01" "00155D0167E2"
"server02" "00155D0A65E1"

After you paste it into Excel you can use Conditional Formatting > Highlight Cell Rules > Duplicate Values. Then sort by the column with MAC addresses A>Z and look for the highlighted rows.

Filed under: Tech No Comments
21May/150

Use powershell to turn off IPSec Task Offloading on all Virtual Machines on a host

I know you came here to copy and paste so here it is. Run this on each host. Works on stand alone and in clusters.

Get-VM | Get-VMNetworkAdapter | Set-VMNetworkAdapter -IPsecOffloadMaximumSecurityAssociation 0

Very simple. Gets all virtual machines on a host, then their network adapters, then disables IPSec task offloading. This is equivalent to unchecking the box in the settings below.

You can also change that 0 (disable) to a different number to change the offload tasks. IE 333 or something. Not that I recommend that, I just like the number 3.

But wait, you only want to disable this on certain machines, and your machines all have similar names? Maybe you have virtual machines named MyVirtualMachine001 - MyVirtualMachine099. Here's the command with a select-object. Just change the name to whatever fits your environment and virtual machine names.

Get-VM | Where-Object {$_.Name -like "MyVirtualMachine0*"} | Get-VMNetworkAdapter | Set-VMNetworkAdapter -IPsecOffloadMaximumSecurityAssociation 0

Why disable this you ask? Well in my case we were having an issue with RDP being really slow on some virtual machines. We originally thought it was disk IO, but our IO numbers didn't add up. They just weren't bad enough to make a machine as slow as it was. Then we logged into console and realized that was a LOT faster. Our CTO at work found this and we started testing by disabling. RDP was much faster after disabling IPSec task offloading.

Update
These servers that had the RDP issue were actually part of Windows Azure Pack Websites. Turns out that disabling IPSec offloading didn't do the trick. We thought it did, but once we added the roles back into WAPWS they were slow again. Again, our CTO found the fix. On our local machines we are disabling UDP for the remote desktop client. This seems counter-intuitive since everywhere else online recommends enabling UDP for better performance. But I can't argue with the results, RDP is much faster and I'm not seeing a decrease in performance with other connections. To disable:

  1. Open local group policy editor on the machine you are connecting from (not the server).
  2. Navigate to Computer Config > Administrative Templates >  Windows Components > Remote Desktop Services > Remote Desktop Connection Client.
  3. Edit the rule titled "Turn off UDP on the client." Click enabled.

  4. The effect is immediate, just reconnect to the server through RDP. No need to restart your client.
Filed under: Tech No Comments
2May/150

The mother of all disk benches! 4 disk SSD array, server SSD array, storage spaces

I built a new disk array for my Hyper-V lab at home. Overkill? Yeah, but I got tired of waiting for VM's to boot, or build from deployment. When I study or learn something new I need efficiency! Plus there was a sale on 256GB drives and I found a little 4 disk hot swap box. For comparison I have a SSD array in a server, some single disks, and a 4 disk old SATA300 using Windows 8.1 storage spaces (software RAID).

My PC: Intel Core i5 4670K | 32GB DDR1600
I'm using Crystal disk mark for testing.

*Note: I use RAID 0, there is a write penalty but these are SSDs. Yes, data isn't important so redundancy, well, who cares. Although I do back it up with Backblaze which allows me to backup meaningless VHDs.
4 disk RAID 0 SSD Array. Sandisk SDSSDHP256G 256GB SATA600 SSD
Sequential Read (Q= 32,T= 1) : 1578.833 MB/s
Sequential Write (Q= 32,T= 1) : 1272.100 MB/s
Random Read 4KiB (Q= 32,T= 1) : 349.640 MB/s [ 85361.3 IOPS]
Random Write 4KiB (Q= 32,T= 1) : 318.789 MB/s [ 77829.3 IOPS]
Sequential Read (T= 1) : 1419.964 MB/s
Sequential Write (T= 1) : 1146.151 MB/s
Random Read 4KiB (Q= 1,T= 1) : 125.328 MB/s [ 30597.7 IOPS]
Random Write 4KiB (Q= 1,T= 1) : 100.152 MB/s [ 24451.2 IOPS]

Notice the increased read performance between the array and a single SSD disk, but how large the write penalty is with RAID 0.

Single SSD SATA600 OCZ-Agility 256GB
Sequential Read (Q= 32,T= 1) : 386.957 MB/s
Sequential Write (Q= 32,T= 1) : 209.348 MB/s
Random Read 4KiB (Q= 32,T= 1) : 262.283 MB/s [ 64033.9 IOPS]
Random Write 4KiB (Q= 32,T= 1) : 211.379 MB/s [ 51606.2 IOPS]
Sequential Read (T= 1) : 187.703 MB/s
Sequential Write (T= 1) : 211.817 MB/s
Random Read 4KiB (Q= 1,T= 1) : 18.627 MB/s [ 4547.6 IOPS]
Random Write 4KiB (Q= 1,T= 1) : 131.864 MB/s [ 32193.4 IOPS]

Single SATA Hybrid SATA600 ST750LX003-1AC154 750GB
Sequential Read (Q= 32,T= 1) : 104.197 MB/s
Sequential Write (Q= 32,T= 1) : 105.733 MB/s
Random Read 4KiB (Q= 32,T= 1) : 1.317 MB/s [ 321.5 IOPS]
Random Write 4KiB (Q= 32,T= 1) : 1.199 MB/s [ 292.7 IOPS]
Sequential Read (T= 1) : 104.002 MB/s
Sequential Write (T= 1) : 106.107 MB/s
Random Read 4KiB (Q= 1,T= 1) : 0.663 MB/s [ 161.9 IOPS]
Random Write 4KiB (Q= 1,T= 1) : 1.214 MB/s [ 296.4 IOPS]

Storage Spaces two-way mirror (RAID 10) 4 disk array SATA300 ST3750640AS 750GB
Sequential Read (Q= 32,T= 1) : 75.898 MB/s
Sequential Write (Q= 32,T= 1) : 24.826 MB/s
Random Read 4KiB (Q= 32,T= 1) : 0.649 MB/s [ 158.4 IOPS]
Random Write 4KiB (Q= 32,T= 1) : 0.284 MB/s [ 69.3 IOPS]
Sequential Read (T= 1) : 75.491 MB/s
Sequential Write (T= 1) : 26.843 MB/s
Random Read 4KiB (Q= 1,T= 1) : 0.651 MB/s [ 158.9 IOPS]
Random Write 4KiB (Q= 1,T= 1) : 0.284 MB/s [ 69.3 IOPS]

RAID 5 with 6 disk + hot spare. PERC H710P Mini SATA600
Sequential Read (Q= 32,T= 1) : 2855.447 MB/s
Sequential Write (Q= 32,T= 1) : 2016.346 MB/s
Random Read 4KiB (Q= 32,T= 1) : 349.066 MB/s [ 85221.2 IOPS]
Random Write 4KiB (Q= 32,T= 1) : 115.260 MB/s [ 28139.6 IOPS]
Sequential Read (T= 1) : 2185.178 MB/s
Sequential Write (T= 1) : 1794.224 MB/s
Random Read 4KiB (Q= 1,T= 1) : 60.030 MB/s [ 14655.8 IOPS]
Random Write 4KiB (Q= 1,T= 1) : 59.278 MB/s [ 14472.2 IOPS]

I'm going to have to work on the random reads and writes on this server. That should blow my home array out of the water.

Filed under: Tech No Comments