How to Change File Properties (ReadOnly, CreationTime etc.) Using PowerShell

Changing file properties is quite easy with PowerShell.

 

Remove ReadOnly attribute:

Set-ItemProperty -Path 'C:\Program Files\desktop.ini' -Name IsReadOnly -Value $false

 

Change CreationTime (90 days back in time):

Set-ItemProperty -Path 'C:\Program Files\desktop.ini' -Name CreationTime -Value ((Get-Date).AddDays(-90))

 

 

 

Hyper-V on Windows 8 (Pro or Enterprise)

Looking for a hypervisor on Windows 8? Look no further. If your Windows 8 is Pro or Enterprise Hyper-V is available as a feature, and can be enabled easily as long as your system complies with there requirements:

  • Windows 8 Pro or Windows 8 Enterprise (64-bit Operating System)
  • Minimum of 4GB of RAM
  • Hardware Assisted Virtualization (HAV) – (This may appear as Intel VT)
  • Dynamic Execution Prevention or No Execute (DEP/NX)
  • Second Level Address Translation (SLAT)

 

Open Windows Features to check if Hyper-V is enabled:

WindowsFeatureNoHyperV

 

To enable the Hyper-V feature check the box and press OK:

WindowsFeatureEnableHyperV

 

 

When the Hyper-V feature is enabled your computer needs to be restarted:

WindowsFeatureEnableHyperV_Restart

 

After restart Hyper-V will appear on your Start Screen:

StartScreenHyperV2

 

Hyper-V on your Windows 8 can be managed using Hyper-V Manager as any Hyper-V running on a Windows Server:

HyperV_Manager

PDF Search missing in Windows 7 (64-Bit)

For some reason the 64-bit versions of Windows has a problem indexing PDF files. Windows Search uses IFilter to help it index files, and the PDF IFilter for 64-bit Windows is missing. (This probably applies to 64-bit Vista and 64-bit XP as well).

To detect whether a computer has the IFilter installed or not open Indexing Options from Control Panel:

IndexingOptions

 

Choose Advanced:

IndexingOptionsAdvanced

 

Find the PDF extension on File Types tab:

IndexingOptionAdvancedFileTypesNotFound

As shown above PDF Filter Description says Registered IFilter Is Not Found

 

 

To fix this problem download and install:

Adobe PDF iFilter 64-bit

 

When everything is installed your filter description for pdf extensions should say “PDF Filter” instead of “Registered IFilter Is Not Found” in Indexing Advanced Options:

IndexingOptionAdvancedFileTypesOK

 

Before being able to search PDF-files the Index has to be rebuild. This is done by clicking Rebuild i Indexing Advanced Options:

 

IndexingOptionsAdvancedRebuild

 

Please note: Rebuilding index can take a long time if your disks contains large amount of data.

 

Running a headless VirtualBox

 

Use this command to start headless VirtualBox named NameOfVirtualBox:

Start /b 'C:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe' -s "NameOfVirtualBox"

Or using PowerShell:

Start-Process -FilePath 'C:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe' -ArgumentList @("-s","NameOfVirtualBox") -NoNewWindow

 

Note: If you close your command prompt the processes with your headless VirtualBox will get killed.

 

Link to VirtualBox manual : http://www.virtualbox.org/manual/ch07.html#vboxheadless

Atheros AR5007 failed to connect (WiFi/Internet)

Problem:
This behaviour is seen when connecting a Vista computer with Atheros AR5007 Wireless LAN adapter installed to a new wireless accesspoint. (In this case a HP laptop computer with preinstalled Vista Home Premium connecting to Cisco Linksys EA6500).

When inspecting network configuration you will find DHCP-address is assigned correctly – BUT no traffic is recieved on the wireless adapter. You are unable to ping any network devices, and renewing DCHP-address will also fail.
Other devices have no problem using the wireless network.

Resolution:
Install SP53261 from hp.com

This new Atheros Wireless LAN Driver will replace the preinstalled driver, and resolve the problem for these Atheros adapters:

  • Atheros AR5006 802.11a/b/g WiFi Adapter
  • Atheros AR5007 802.11b/g WiFi Adapter
  • Atheros AR5009 802.11a/g/n WiFi Adapter
  • Atheros AR9285 802.11b/g/n WiFi Adapter
  • Atheros AR9380 802.11a/g/n WiFi Adapter
  • Atheros AR9382 802.11a/g/n WiFi Adapter
  • Atheros AR9485 802.11 b/g/n WiFi Adapter

 

The new driver is compatible with a wide range of Windows versions:

  • Microsoft Windows 7 Enterprise 32 Edition
  • Microsoft Windows 7 Home Basic 32 Edition
  • Microsoft Windows 7 Home Premium 32 Edition
  • Microsoft Windows 7 Professional 32 Edition
  • Microsoft Windows 7 Starter 32 Edition
  • Microsoft Windows 7 Ultimate 32 Edition
  • Microsoft Windows 7 Enterprise 64 Edition
  • Microsoft Windows 7 Home Basic 64 Edition
  • Microsoft Windows 7 Home Premium 64 Edition
  • Microsoft Windows 7 Professional 64 Edition
  • Microsoft Windows 7 Ultimate 64 Edition
  • Microsoft Windows XP Home Edition
  • Microsoft Windows XP Media Center Edition
  • Microsoft Windows XP Professional
  • Microsoft Windows XP Tablet PC Edition
  • Microsoft Windows XP Professional x64 Edition
  • Microsoft Windows Vista Enterprise 32 Edition
  • Microsoft Windows Vista Home Basic 32 Edition
  • Microsoft Windows Vista Home Premium 32 Edition
  • Microsoft Windows Vista Business 32 Edition
  • Microsoft Windows Vista Starter 32 Edition
  • Microsoft Windows Vista Ultimate 32 Edition
  • Microsoft Windows Vista Enterprise 64 Edition
  • Microsoft Windows Vista Home Basic 64 Edition
  • Microsoft Windows Vista Home Premium 64 Edition
  • Microsoft Windows Vista Business 64 Edition
  • Microsoft Windows Vista Ultimate 64 Edition

 

Easy validating parameter input using ValidateCount, ValidateLength, ValidatePattern, ValidateRange, ValidateSet and ValidateScript in PowerShell

Windows PowerShell introduced parameter validation which drastically reduces lines of validation code – and replaces it with a couple of markup tags:

 

ValidateCount (int minLength, int maxlength)
How many arguments are allowed for a parameter.

[ValidateCount(1,3)]
[String[]]
$Collection

ValidateLength (int minLength, int maxlength)

Length (in characters) of a parameter argument.

[ValidateLength(1,8)]
[String[]]
$Phone

ValidatePattern (string regexString, Named Parameters)
Valid patterns for a parameter argument.

[ValidatePattern("[0-9][0-9][0-9][0-9]")]
[String[]]
$Pin

ValidateRange (object minRange, object maxRange)
Valid range for a parameter argument.

[ValidateRange(18,120)]
[Int]
$Number

ValidateSet (string[] validValues, Named Parameters)
Possible values for a parameter argument.

[ValidateSet("One","Two","Three","Four")]
[String]
$TextString

ValidateScript (scriptblock validValues)
Custom script for validation

[ValidateScript({Test-Path $_ -PathType 'Container'})]
[String]
$Path

ValidateNotNull ()
Input is not null

[ValidateNotNull()]
[String]
$Id

ValidateNotNullOrEmpty ()
Input is neither null or empty

[ValidateNotNullOrEmpty()]
[String[]]
$UserName

 

Read more about validating parameters on MSDN:

Or use PowerShell built-in help:

 

SCOM Health Service Events when troubleshooting certificate authentication

These Events are common when troubleshooting problems related to Health Service certificates i System Center Operations Manager 2007:

 

21021 – Could not load Certificate
Check if certificate exists and the Health Service has permissions to read it.

 

20052 – Certificate not loaded (name does not match)
Make sure Issued To match the actual computername.

 

20053 – Certificate loaded
The certificate is loaded – and everything should be working.

 

 

Browse FTP site in Windows Explorer (triggered from Internet Explorer 9)

By default the option to view FTP site in Windows Explorer is hidden in Internet Explorer 9 (IE9).

To enable it you have to go to Internet Options -> Advanced -> Enable FTP Folder View as shown below:

Once this option is enabled you should see Open FTP Site in Windows Explorer in the View-menu.
(Keep in mind that this option is only visible when you are on an FTP page).

Note: Press ALT to show Internet Explorer menus.

Blue Screen of Death (BSoD) when putting Windows 7 to sleep

All of a sudden my Windows 7 ended up crashing with Blue Screen of Death when put to sleep, and I started investigating this behavior.

After a couple of crashes a pattern started to emerge: Blue Screen of Death was only an issue when the laptop was running on batteries – and NOT when AC was plugged in.

This led me to investigate the memory crash dump using Debugging Tools for Windows which indicated the problem was probably caused by dne64x.sys (part of DNE – Deterministic Network Extender)

Even though Citrix indicates DNE is practically flawless…..

With tens of millions of copies of DNE installed and over 12 years in the market, there are no known crash issues with DNE. However, because DNE is a kernel-level NDIS module that relies on packets from other drivers, we sometimes see crashes that appear to be in DNE. Generally these are caused by bugs in other products or drivers

… I decided to reinstall DNE using Citrix guidelines:

  1. Uninstall programs using DNE
    Citrix suggest trying to uninstall the program that uses DNE (e.g. a VPN client) before reinstalling DNE.
  2. Run Winfix
    Run the Citrix utility called Winfix (ftp://files.citrix.com/winfix.exe) that can clean up most Windows operating systems to enable installation of products that use DNE and other products like DNE.
  3. Download and install the latest DNE
    32-bit: ftp://files.citrix.com/dneupdate.msi
    64-bit: ftp://files.citrix.com/dneupdate64.msi
  4. Reinstall the product that uses DNE

 

This solved the problem – and my laptop sleeps tight again without crashing!

 

Write Event to Windows Event Log using PowerShell

 

Creating an EventLog entry using PowerShell is shown below:

Write-EventLog -LogName 'Application' -Source 'MyEventSource' -EventID 1000 -EntryType Warning -Message "This is a test of writing to the Event Log using PowerShell."

 

Note: The Event Source needs to be created before writing entries to the Event Log. (See this post for further info: Create Event Source with PowerShell)