On server 2008r2 you can do import-module servermanager & then add-windowsfeature to configure features etc.. from PowerShell, this doesn’t exist out of the box on 7, however if you install this: http://code.msdn.microsoft.com/PSClientManager you have an equivalent set of modules
Handy eh!
Rob
Recently had a problem un-installing the first Exchange 2003 Server in the organisation even after moving off all the Users, Offline Address Book, removing the RUS etc. etc.
“One or more users currently use this mailbox store. These users must be moved to a different mailbox store or be mail disabled before deleting this store”.
Doing an AD Search for Exchange recipients and either sorting by the Exchange Server I want to remove or explicitly searching for Exchange Home Server came up with nothing….. hmmm
Tried running an advanced AD find and hey presto, it found two users that seem to have some details of once being enabled on that Exchange Server. Once I had removed the Exchange attributes from those accounts I could un-install Exchange.
Here is how to perform the advanced search:
- In Active Directory Users and Computers right-click your domain and choose ‘Find’
- Click ‘Advanced’ and then choose ‘User’ from the Field menu
- Now choose ‘Exchange Home Server’ from the list.
- Set the condition to ‘Ends With’ and type the name of your Exchange Server
- Click ‘Find’
Good luck
We came across an issue recently where-by we had a DL385 G1 running Windows 2008 R2. As this OS is not on the supported matrix for this Server it means that there isn’t a PSP for it and therefore no monitoring for us. If you run the setup you will received a ‘Failed Dependencies’ alert against the HP Insight Management Agents and HP Insight Diagnostics Online Edition and when you view those failures you will see them as listed below.

How do we fix this then? We need these dependencies on so we can monitor the status of the Server.
Easy peasy….. well, it is now I figured out how to do it
Right-click the setup.exe file and properties, select the Compatibility tab and enable the ‘Run this program in compatibility mode for:’ option then select ‘Windows Server 2008 (Service Pack 1)’ from the drop down. Apply and Ok and you are now good to go.

Run the setup.exe again and this time it will meet the requisites and let you install all the agents etc.
Good luck.
Neil
Whilst trying to automate some reporting automation and analysis , I overcome a requirement to reformat a csv ( loosest sense of the term) so that PowerShell will process it. The following is a useful demonstration of how to manipulate text data and reformat it, also the use of regex (Regular Expression) in PowerShell to identify the current days file.
This has been tested against PowerShell 1.0 on Microsoft Windows Server 2003
##
# A csv Files report is created but you are unable to load it as a csv File due to irregular formatting of the report.
# this will serve as a good example of string manipulation.
#
# Issues with csv file
# remove top 6 lines, header information not required.
# headers contain , but are not quoted, so you now have more columns than data
# trailing , stop PowerShell loading csv as you can not have a blank header
# the data is includes a % sign. this then stop it being a number when imported into SQL / Excel
#———————————————————–
#
#
$tmpfile = “temp.csv”
$mydat = (get-date ((get-date).adddays(-1))-uformat “%Y%m%d”) # get yesterdays date in the correct format
$filter = [regex] “^Daily-View.*$mydat[0-9]{6}.csv$” # Use regex to find today’s file
$csvfile = Get-ChildItem -Path “c:Joetest*.csv” | Where-Object {$_.Name -match $filter} # return 1 filename
# use PowerShell to drop the first 6 lines of unwanted text at the beginning of the file
#
$csvContent = get-content $csvfile
$csvContent | select -last ($csvContent.count -6) | Out-File $tmpfile
# replace “, %” with ” %”
#
$csvContent = “”
$csvContent = get-content $tmpfile
$csvContent[0] = $csvContent[0].replace(“, %”,” %”)
# remove trailing , on header line
#
$csvContent[0] = $csvContent[0].substring(0,($csvContent[0].length)-1) # remove the last char on the line
# remove all the “%” signs from the data ( but not the header)
#
$counter = 0
foreach ($line in $csvContent)
{
if ($counter -ne 0) # skip the header line
{
$csvContent[$counter] =$csvContent[$counter].replace(“%”,”")
}
$counter++
}
# output the plain txt file
#
$csvContent | out-file $tmpfile
# now you can import the file as a csv with no errors
#
$csvdata = import-csv $tmpfile
$csvdata
# ————————————–
# now you can do stuff with the data here
# ————————————–
# Remove old temp file
#
if (test-path $tmpfile)
{
remove-item -path $tmpfile -force
}
As part of a larger project I’ve been involved with which uses an IIS7 web application (I’ve been helping the client with their infrastructure and integrating the application with AD) we hit an issue where some 3rd party pieces of code were using absolute links *tut tut*! rather than relative ones, this had the side effect that a user would start off their session using an SSL secured https session & after performing certain tasks would find themselves on http. Not ideal! The application also has a requirement that the web servers are able to connect to themselves on port 80 – this could not be changed & interfering with this connection would break functionality.
To resolve this I’ve implemented the Microsoft URL Rewrite module 2 for IIS7, with the following configuration:
- Download and install the IIS URL re-writing module: http://www.iis.net/download/urlrewrite
- Go to the site in IIS manager & navigate to URL Rewrite in the right hand pain
- Create a new inbound rule with the following settings:
- Match URL:
- Requested URL: ‘Matches the pattern’
- Using: ‘Regular Expressions’
- Pattern: ‘(.*)’
- Ignore Case: ‘True’
- Conditions:
- Input ‘{HTTPS}’ Type ‘Matches the pattern’ Pattern ‘^OFF$’
- Input ‘{LOCAL_ADDR}’ Type ‘Does not match the pattern’ Pattern ‘127.0.0.1’
- Action: ‘Redirect’ Redirect URL: ‘https://{HTTP_HOST}/{R:1}’ Append Query String: True Redirect type: ‘See Other (303)’
This will not only correct broken URLs which get returned but will redirect users who hit the site via http to https which is a requirement for the service.
Handy fix – I’d often use TMG / ISA to resolve this but this customer’s solution does not feature those products (the site is being deployed internally).
Rob
I have built a new VM recently using VirtualBox and needed to use it as my base image, I stop the VM and copied the disk files to a new name and location. I then tried to create a new VM and attach the copied disk, only to get the following error
“Failed to open the hard disk”
“Cannot register the hard disk ‘testdisk2.vdi’ with UUID {UUID} because a disk ‘Testdisk1.vdi’ with {UUID} already exists in the media registry””

The solution is to use the command line tool to clone the drive as follows:
open a command window (start > Run > cmd)
cd C:Program FilesOracleVirtualBox (move to the program files folder)
VBoxManage.exe clonevdi “testdisk1.vdi” “f:VirtualBoxtestdisk2.vdi”
This will clone the drive to the new file and location which you can then use. This will need to be done for each subsequent copy.