Update 2016-03-18: If you are on Windows 8 / Server 2012 or later, use the 'MediaType' attribute of the 'Get-PhysicalDisk' output. See the comments for more detail.
I was talking with some colleagues recently who were having trouble detecting if a disk was a Solid State Disk (SSD) or not in a lab environment. They wanted to run PowerShell scripts against the machines but found if the disk on the machine was a spindle disk it would cause an issue without a built-in delay. They wanted to detect if the disk was an SSD to remove the delay on machines that could handle it.
Easy I though. Just issue a Get-PhysicalDisk cmdlet and checkout the properties, no problem. Well that's what a PowerShell expert would think anyway. It turns out not to be the case.
After a lot of mucking about and searching I found there is no information reported from an ATA device to tell the operating system that it is an SSD. This makes sense I suppose seeing the concept of an SSD would have been unimaginable back when the interfaces were designed.
It turns out the best way to detect if an attached disk is an SSD or not is by reading two properties of the disk being, spindle speed (or rotation rate) and seek penalty. Neither of these properties are exposed by PowerShell or .NET.
Thanks to the Add-Type cmdlet and a guy from this blog (sorry, I can't find your name on the site), I created this PowerShell script to report if a disk is an SSD or not.
Simply copy the code to a script file and run it passing in a physical disk id number. It will return $true if the disk is an SSD, or $false if not. It will also return $false if exceptions occur in the Win32 DLL calls.
Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts
Wednesday, 1 April 2015
Monday, 13 January 2014
Delete Windows Driver Packages
Today I had a need to remove a driver from Windows 7 x64 on a Syspreped Operating System.
As it turned it is it very easy to do thanks to a built-in tool called pnputil.exe.
Simply run pnputil.exe -e to get a list of third party drivers. I piped the output of the command into a text file with pnputil.exe -e > pnputil.txt
Then search the new text file for the driver you need to delete.
Lastly, delete the driver package with this command pnputil.exe -d oem1234.inf
You will have to supply the correct file name for the above command to work.
This is all documented on TechNet here;
http://technet.microsoft.com/en-us/library/cc730875.aspx
As it turned it is it very easy to do thanks to a built-in tool called pnputil.exe.
Simply run pnputil.exe -e to get a list of third party drivers. I piped the output of the command into a text file with pnputil.exe -e > pnputil.txt
Then search the new text file for the driver you need to delete.
Lastly, delete the driver package with this command pnputil.exe -d oem1234.inf
You will have to supply the correct file name for the above command to work.
This is all documented on TechNet here;
http://technet.microsoft.com/en-us/library/cc730875.aspx
Thursday, 14 November 2013
Remove SkyDrive and Homegroup from Windows 8.1 File Explorer
Today I got sick of scrolling past SkyDrive and Homegroup nodes in the left pane of File Explorer in Windows 8.1. I did a search and found a good post on Lifehacker and another post from a forum on how to remove them from the Explorer window.
The root of the change is to set a registry key called Attributes to a value of 0. There is one problem though. The parent key called ShellFolder does not give read/write permissions to user accounts. You will need to take ownership of the ShellFolder key and give your user account read/write permissions to change the Attributes value.
The key of interest is
HKEY_CLASSES_ROOT\CLSID\{8E74D236-7F35-4720-B138-1FED0B85EA75}\ShellFolder
The services are;
After you have made the above changes simply reboot the machine and the explorer windows will look like this;
Ah, that's better. No SkyDrive or Homegroup tree nodes.
Removing SkyDrive
I am adding the details here for my own reference but here is the link to the article from Lifehacker titled How to Get Rid of SkyDrive in Windows 8.1 Explorer.The root of the change is to set a registry key called Attributes to a value of 0. There is one problem though. The parent key called ShellFolder does not give read/write permissions to user accounts. You will need to take ownership of the ShellFolder key and give your user account read/write permissions to change the Attributes value.
The key of interest is
HKEY_CLASSES_ROOT\CLSID\{8E74D236-7F35-4720-B138-1FED0B85EA75}\ShellFolder
Removing Homegroup
This one is a little easier. Make sure you are not a member of any Homegroups and then disable two Homegroup related services in the services.msc utility.The services are;
- Homegroup Listener
- Homegroup Provider
After you have made the above changes simply reboot the machine and the explorer windows will look like this;
Ah, that's better. No SkyDrive or Homegroup tree nodes.
Monday, 2 September 2013
Windows Server 2012 Core Keyboard Input Method Changes
Here is an issue I just had with Windows Server 2012 installed as a server core system. For those not familiar with a core install, there is no desktop with just a command prompt for managing the system.
As it turned out on this system I was trying to manage, the default keyboard input was set to the UK keyboard. If you are using a US keyboard with a system set to the UK keyboard, some of the keys will be mapped incorrectly. A very good example is the pipe symbol. I was trying to use PowerShell to configure the server and discovered I could not pipe command objects.
Easy fix I would have thought only with Windows 8 and Windows Server 2012, Microsoft has moved the keyboard input configuration into the Metro start screen. A server core does not have the Metro interface at all.
After some searching I found the best way to fix the problem. One registry key change.
You can run the registry editor on the server core installations. So simply run regedit.exe and navigate to;
HKCU:\Keyboard Layout\Preload and change the key titled "1" to the desired input method. US is 00000409.
Here is some more detail about the registry keys;
http://support.microsoft.com/kb/102987/en-us
As it turned out on this system I was trying to manage, the default keyboard input was set to the UK keyboard. If you are using a US keyboard with a system set to the UK keyboard, some of the keys will be mapped incorrectly. A very good example is the pipe symbol. I was trying to use PowerShell to configure the server and discovered I could not pipe command objects.
Easy fix I would have thought only with Windows 8 and Windows Server 2012, Microsoft has moved the keyboard input configuration into the Metro start screen. A server core does not have the Metro interface at all.
After some searching I found the best way to fix the problem. One registry key change.
You can run the registry editor on the server core installations. So simply run regedit.exe and navigate to;
HKCU:\Keyboard Layout\Preload and change the key titled "1" to the desired input method. US is 00000409.
Here is some more detail about the registry keys;
http://support.microsoft.com/kb/102987/en-us
Monday, 29 April 2013
Remotely Connect to Hyper-V with Hyper-V Manager
On Windows 8 or Windows Server 2012 you can install the Hyper-V Management Console and use it to connect to a server or client running Hyper-V Services.
Microsoft has the basic configurations covered at this address;
http://technet.microsoft.com/en-us/library/jj647788.aspx
There is a rather important detail missing though. To connect to the Hyper-V Service running on a different machine, you need to run the Hyper-V Manager using a local account.
Now if you are like me you are thinking to yourself "I am using my local account!" Well you may not be. If you chose to use a Microsoft account when you installed Windows 8, then you are not using a local account.
So make sure you have a local administrative account on both the Hyper-V Server and the Remote Management machine. Hold down the Shift key and right click the Hyper-V Manager link and select to "Run as different user" and use your local account.
Have a read through the community comments on the bottom of the Technet page for more details.
Microsoft has the basic configurations covered at this address;
http://technet.microsoft.com/en-us/library/jj647788.aspx
There is a rather important detail missing though. To connect to the Hyper-V Service running on a different machine, you need to run the Hyper-V Manager using a local account.
Now if you are like me you are thinking to yourself "I am using my local account!" Well you may not be. If you chose to use a Microsoft account when you installed Windows 8, then you are not using a local account.
So make sure you have a local administrative account on both the Hyper-V Server and the Remote Management machine. Hold down the Shift key and right click the Hyper-V Manager link and select to "Run as different user" and use your local account.
Have a read through the community comments on the bottom of the Technet page for more details.
Wednesday, 24 April 2013
Export Hyper-V Virtual Machine to a File Share in a Workgroup
I have a number of Windows Server 2012 Hyper-V hosts that are not members of a Domain.
To export the Virtual Machines to a File Server we need to authenticate the System service account to the File Server before the Hyper-V Management Service can access the shares. I found this neat trick on Microsoft's Technet Forum which worked wonderfully using PSExec;
This is not a process you would want to perform for a nightly backup, but as a once off it does the trick.
To export the Virtual Machines to a File Server we need to authenticate the System service account to the File Server before the Hyper-V Management Service can access the shares. I found this neat trick on Microsoft's Technet Forum which worked wonderfully using PSExec;
1. Open an elevated command prompt: Click start, type CMD, and press
Ctrl+Shift+Enter, then accept the UAC dialog (if applicable).
2. Run:
psexec.exe \\<localServerName> /s cmd.exe
This will provide you with a new command prompt, but it will instead run under the SYSTEM context, instead of your user context.
3. Run:
net use \\<remoteServerName>\<sharename> /user:<domain>\<userName> <password>
This authenticates the SYSTEM account to the share you want to export to.
As an example, the line
could look like: "net use \\server2\c$ /user:mydomain\Administrator MyAw3s0m3Pwd"
4. Return to the Hyper-V MMC, and try your export again. It should work now.
5. When you're done, use:
net use \\<remoteServerName>\<sharename> /delete
This revokes the credentials from the SYSTEM account. Alternatively, you could reboot.
6. Type exit, press enter. You've dropped back to the original
command prompt. Type exit and press enter again, or simply close the
window.
This is not a process you would want to perform for a nightly backup, but as a once off it does the trick.
Monday, 18 February 2013
Disable Adobe Reader Updates
If you need to disable Adobe Reader from automatically updating or asking to be updated on Windows you can do so by creating a REG_DWORD registry key named bUpdater.
Here is the location to create the key;
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Adobe\Acrobat Reader\10.0\FeatureLockDown
Notice the \10.0\ in the above address. Replace this with the version you are trying to configure.
Inside the above address create this key;
REG_DWORD bUpdater 0x00000000
Setting this value will disable the updater and remove the "Check for updates" option in the help menu.
Here is the reference from Adobe's website.
I used the following PowerShell script to search for all FeatureLockDown keys and disable the Updater regardless of the version of Adobe Reader that is installed.
"Disabling Adobe Acrobat Reader Updates."
$featureLockDownKeys = Get-ChildItem -Path HKLM:/SOFTWARE/Policies/Adobe -Recurse | Where-Object -Property Name -Match "FeatureLockDown$"
foreach ($fldk in $featureLockDownKeys)
{
New-ItemProperty -Path $fldk.PSPath -Name "bUpdater" -Value 0 -PropertyType DWORD -ErrorAction SilentlyContinue | Out-Null
New-ItemProperty -Path $fldk.PSPath -Name "iDisablePromptForUpgrade" -Value 0 -PropertyType DWORD -ErrorAction SilentlyContinue | Out-Null
}
Here is the location to create the key;
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Adobe\Acrobat Reader\10.0\FeatureLockDown
Notice the \10.0\ in the above address. Replace this with the version you are trying to configure.
Inside the above address create this key;
REG_DWORD bUpdater 0x00000000
Setting this value will disable the updater and remove the "Check for updates" option in the help menu.
Here is the reference from Adobe's website.
I used the following PowerShell script to search for all FeatureLockDown keys and disable the Updater regardless of the version of Adobe Reader that is installed.
"Disabling Adobe Acrobat Reader Updates."
$featureLockDownKeys = Get-ChildItem -Path HKLM:/SOFTWARE/Policies/Adobe -Recurse | Where-Object -Property Name -Match "FeatureLockDown$"
foreach ($fldk in $featureLockDownKeys)
{
New-ItemProperty -Path $fldk.PSPath -Name "bUpdater" -Value 0 -PropertyType DWORD -ErrorAction SilentlyContinue | Out-Null
New-ItemProperty -Path $fldk.PSPath -Name "iDisablePromptForUpgrade" -Value 0 -PropertyType DWORD -ErrorAction SilentlyContinue | Out-Null
}
Monday, 11 February 2013
Create a bootable USB dirve for an existing WinPE wim file
I use this procedure to create a bootable USB disk for a WinPE image I use at work for setting up physical machines.
- Follow the steps on Technet to create the folder structure required;
Create a Bootable Windows PE RAM Disk on a USB Flash Disk - Copy your wim file into the \Boot\Sources folder and rename it to boot.wim.
Subscribe to:
Posts (Atom)
