Powershell: Chrome – FireFox Browser : ADFS

Author: WallaceTech  |  Category: Active Directory, ADFS


Anyone who works with Microsoft ADFS for single sign-on and also might have a requirement to use a non-Microsoft browser (Chrome) for example, will need to make some changes to Microsoft ADFS

Firefox, Chrome for example will not sign you in to services using SSO unless you turn off extended protection. I am not going to explain how to switch this off as this should not even be an option to make these browsers work.  If you switch this setting off you are exposing your ADFS to man in the middle attacks. Please don’t even entertain such an idea just to work with a Chrome Browser.

Read more…

DNS: Scavenging

Author: WallaceTech  |  Category: DNS, Microsoft
Below is some code to check what DNS A Records are going to be removed when you have DNS Scavenging
switched on. You will need to download DNSShell Powershell snap-in for this to work. LINK HERE


I have this set a scheduled task to run once each morning.
Import-module "C:\Windows\System32\WindowsPowerShell\v1.0\DnsShell\DnsShell.psd1"

#Email Variables
$smtpServer = "SMTP.Domain.com"
$mailsender = "Sender@Domain.com"
$mailreceiver = "Receiver@Domain.com"

#DNS Zone
$DNSzone = "Domain.com"

$agedrecords = $null
$aging = (Get-ADDnsZone $DNSzone).NoRefreshInterval.TotalMilliseconds + (Get-ADDnsZone $DNSzone).RefreshInterval.TotalMilliseconds

foreach ($record in (Get-ADDNSZone $DNSZone | Get-ADDnsRecord))


if (($record.timestamp -ne "Static") -and ((Get-Date).Addmilliseconds((-1)*$aging) -ge $record.timestamp))
$agedrecords += $record.name + "`r`n"




if ($agedrecords -ne $null)

#Email Results
$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = $mailsender
$msg.Subject = "[Warning] Domain.com DNS Records To be Scavenged"
$msg.Body = $agedrecords

Powershell: Local Admin Report

Author: WallaceTech  |  Category: Active Directory, Powershell Scripts
Hi all. 

So below is some code I have been working on. The script is using the Quest Active Roles snapin so you
will need to install that first. 

What will this script do?

1) Ask the person running the script which AD OU they wish to scan
2) It will then ping each machine in the OU to see if its Live
3) It will then loop through each machine obtaining a list of members from the local admin group.
4) Will export it out to .CSV format to C:\Temp

Read more…

Server 2012 R2: Windows XP Clients

Author: WallaceTech  |  Category: Server 2012 R2, Windows XP



Server: Windows Server 2012 R2

Client: Windows XP


Read more…

VMware: Get-VM Get-Cluster MemLimit CPUSharesLimit MemShareLimit

Author: WallaceTech  |  Category: VMware


Below are some Powershell one liners that you can use to set VMware Memory allocation to unlimited and also set Mem and CPUSharesLimit from Low Medium or High back to normal. So in an effort to bring some consistency to my VMware environment I used the Get-VM more, but should you want to target this to just individual Clusters then the code is there as well. Read more…

DFS Server 2012 R2 HP 3PAR SAN issue

Author: WallaceTech  |  Category: Server 2012

Hi Guys.

I have been banging my head against a DFS issue for a number of weeks now. To give you a low down on the issue, I had created two new Server 2012 R2 servers (this issues also exists on non R2 2012) and created a replication group between a folder on each server.

So the issue was that replication would work successfully for around 3 to 4 hours and then if you created a new folder or file  you would receive the message

“The action can’t be completed because the folder or file in it is open in another program” Read more…

Apple – iCloud Drive Yosemite

Author: WallaceTech  |  Category: Windows XP, YouTube Videos

Hey. I have just installed Yosemite OSx and loving it. However the one item that is annoying is the lack of ability to add the Apple iCloud drive to your desktop. I don’t use finder that much and like to have my connected devices on the desktop. A way around this is to follow the procedures below. Open your Home / Profile and then click on the drop down cog. Click on ‘Show View Options’

Screen Shot 2014-10-18 at 12.07.13

Read more…

Powershell: Start multiple remote windows services

Author: WallaceTech  |  Category: Powershell Scripts

I had to start the Remote Registry service on a whole bunch of Windows boxes. This post is coming from two angles. 1) I wanted to show how the code below can be reused time and time again for multiple servers / workstations. 2) I wanted to show you the command for setting the service to enable and then starting it.

The Set-Service cmdlet is quite good. I had been used to using WMI but Set-Service fits the bill perfect. So you could replace the Set-Service with any other command you would like to use. The foreach query is a good one to have kicking around.

$ComputerList = "C:\Computers.txt"

$Computers = Get-Content $ComputerList

#Query Event Log
foreach($Computer in $Computers)
Set-Service -ComputerName $Computer -Name RemoteRegistry -StartupType Automatic -Status Running

Powershell: Query Multiple Remote EventLog

Author: WallaceTech  |  Category: Powershell Scripts

I had a need to query multiple remote systems looking for Event ID of 1000 in the Application log with Event Type of Error. I also only wanted to return the items if the word Outlook was contained in the message body.  The script below can be changed to fit your needs. You may want to omit the $WindowsMessageMatch variable unless you are also looking to return Outlook.

Everything has been set as a variable so you should just need to adjust and run.

Read more…

Batch File: Powershell Dot Sourcing

Author: WallaceTech  |  Category: Batch Scripts, Powershell Scripts

So I had a need to launch a Powershell script that I had developed from within a Windows batch file. The issue was that I am Dot Sourcing.  Typically in a Powershell window I would type

So in a folder called C:\Powershell-Scripts

. .\WallaceTech.PS1
Service-Desk -GetBackup Read more…

SQL: Cannot generate SSPI context

Author: WallaceTech  |  Category: Powershell Scripts, SQL Server

So had this interesting message when trying to connect a SQL System DSN. Logged on with a domain account , the domain account had access to SQL and SysAdmin rights. When trying to view the list of databases I was presented with

Connection failed:
SQL State: ‘HY000’
SQL Server Error: 0
[Microsoft][ODBC SQL Server Driver]Cannot generate SSPI context


OK so time to start digging around. On this particular SQL setup the SQL service was running under a domain user with no admin rights apart from local admin rights on the server. Using the Power of the shell I issued the command below which returned no values.

Read more…

Powershell: Check Multiple File Paths

Author: WallaceTech  |  Category: Powershell Scripts

So I had a need to check if the 32 or 64bit Quest Software  – Active Directory Management tools were installed. I just wanted to give an example of how easy it is to perform this check and maybe give you ideas of how you could use it in your day-to-day scripting.

$Isx64QuestInstalled = Test-Path 'C:\Program Files\Quest Software\Management Shell for AD'
$Isx32QuestInstalled = Test-Path 'C:\Program Files (x86)\Quest Software\Management Shell for AD'

If ($Isx64QuestInstalled -eq "True" -or $Isx32QuestInstalled -eq "True")
Write-Host "Quest Installed"
Write-Host "Quest not installed"


Powershell: UNC Path

Author: WallaceTech  |  Category: Powershell Scripts

So working with UNC paths in some Powershell was fun recently with the script not performing how I wanted. So thinking there must be a better way of achieving this I set about having a hunt around in the Powershell Cmdlets. And of course there was, our good old friend New-PSDrive which ashamedly I don’t take advantage of more

So an example of how to use PSDrive is below. I found this massively helpful

New-PSDrive -Name UNCPath -PSProvider FileSystem -Root \\SERVER-NAME-HERE\SHARE-NAME-HERE\
Copy-Item C:\SOME-LOCAL-FILE.txt UNCPath:\

Powershell: Edit Text File

Author: WallaceTech  |  Category: Powershell Scripts

So here is a quick bit of Powershell code to read the contents of a .txt file called Config.txt on the root of the C:. It will read the text file and then edit it when it finds “Hello the date is”. Once finished it will save it out to a new text file called ConfigNew.txt

I have included $Date so that you can see how easy it is to include a variable in to the text file.

$Date = Get-Date -Format D

(Get-Content C:Config.txt | Foreach-Object {$_ -replace "Hello the date is" , "Hello the date is $Date"} | Set-Content C:ConfigNew.txt)

Powershell: Unblock File

Author: WallaceTech  |  Category: Powershell Scripts, Server 2003, Server 2008, Windows 7

Had an issue where a new imaged Windows 7 machine via MDT threw up warning messages for the Intel graphics cards and do I wish to trust them.

It would seem that as I downloaded them from HP site, Windows had set the file-blocked check mark.  To get around this issue the Powershell one liner below. Of course this can be used on any file that you have downloaded and need to unblock.

Get-ChildItem PATH-TO-FILES-HERE -Recurse | Unblock-File

Powershell: Zip Folders

Author: WallaceTech  |  Category: Powershell Scripts

So here is a small script I have been using to create a .ZIP file using Powershell.  The first thing you need to do is download the Powershell

Community Extensions from the link below.

Powershell Community Extensions 

I am deleting any backups from the folder D:FolderToBackup that are older than 7 days and then backing up a folder called C:FolderToBackup to D:FolderToBackup

Import-Module Pscx

$Date = Get-Date

Get-ChildItem D:FolderToBackup'' -Recurse | Where {$_.creationtime -lt (Get-Date).AddDays(-7)} | Remove-Item -Force

Write-Zip C:FolderToBackup -OutputPath D:FolderToBackup_$((get-date).tostring("MMddyyyyHHmmss")).zip -IncludeEmptyDirectories

VMware: Error 28039. Setup cannot join vCenter Server to the Linked Mode group

Author: WallaceTech  |  Category: VMware

So installing VMware vCenter 5.5 update 1 host to a brand new linked mode setup. I was presented with an error message

Error 28039. Setup cannot join vCenter Server to the Linked Mode group

I had a look in Status.txt which is in C:Users%USERPROFILE%AppDataLocalTemp on Server 2012 and saw the contents below.


Failed to determine LDIF path from command line or environment.
Initialization error.

I had a look in jointool.txt which is in C:Users%USERPROFILE%AppDataLocalTemp on Server 2012 and saw the contents below.


[2014-03-14 20:59:12,513 com.vmware.vim.jointool] Failed to find instance config at: “C:ProgramDataVMwareVMware VirtualCenterinstance.cfg”, assuming defaults
[2014-03-14 20:59:12,518 com.vmware.vim.jointool] Storage directory not found in instance.cfg.
[2014-03-14 20:59:12,707 com.vmware.vim.jointool] Failed to determine LDIF path from command line or environment.
[2014-03-14 20:59:12,718 com.vmware.vim.jointool] Initialization error.


Read more…

Powershell: Add Pictures to Active Directory

Author: WallaceTech  |  Category: Active Directory, Powershell Scripts

Below is a little script to add pictures from a local or remote source and add them to Active Directory.

There are a couple of  assumptions.

1) The name of the .JPG matches the SamAccountName , so for example if you have a user who logs on with an account name of ABC then you must also have a ABC.JPG in your ADPictures directory.

2) The .JPG should ideally be 10k in size but of course depends on how many users you have in AD

As you will see in my scripts I have a Live Location and a Test Location. Please un-comment based on your needs. In my script I am also being specific on the users in an OU.

#Live Location##
#$ADPictures = '\RemoteServerShare'

#Test Location##
$ADPictures = 'C:ADPictures'

Get-ADUser -Filter * -SearchBase 'OU=PATH-HERE' | ForEach {

$photoFile = Join-Path -Path $ADPictures -ChildPath "$($_.SamAccountName).jpg"

$photo = [byte[]](Get-Content $photoFile -Encoding Byte)

Set-ADUser $_ -Replace @{thumbnailPhoto=$photo}


VMware: The Evaluation Mode license assigned to Host has expired. Recommend updating the license

Author: WallaceTech  |  Category: VMware


This caught me off guard a little today. Brand new install of ESXi 5.1 , just built and then tried to add it to v Center. On trying this I received the message below.

The Evaluation Mode license assigned to Host has expired. Recommend updating the license


This was odd because when I logged direct in to the host I was prompted that I had 59 days left. The issue was that the date and time on the host was way out. I changed this to point to a NTP server , rebooted the host and everything was good to go.


OSx: MAC Outlook 2011

Author: WallaceTech  |  Category: Exchange 2010, Exchange 2013, MAC OSx, Office 2011(MAC)

So have been having an issue with Office 2011 on my Macbook and specifically Outlook 2011. I run two Exchange accounts on my MAC, One with Exchange 2013 and one with Exchange 2010. The Exchange 2013 account is fine with no issues but the Exchange 2010 account keeps prompting for my credentials every few minutes. It has become so annoying that I actually had to do something about it.

So I have checked all the basics like my password is correct, it’s not expired etc. The issue seems to be with the username field. Typically you would expect to type DOMAINUsername and all would be good with the world. It would seem for some reason that on my install I need to type DOMAINUsername

Anyway hope this saves someone some time and less frustration than it did for me.

Screen Shot 2013-11-16 at 16.02.44

OSx: MAC Profile in SkyDrive

Author: WallaceTech  |  Category: Apple, MAC OSx, Mountain Lion, SkyDrive

I have been meaning to write this blog post for sometime. Ever since SkyDrive launched I have been using it as a backup to my Macbook profile. How you may ask? Well below I am going to show you how to redirect say your Mac Documents to a Documents folder in your SkyDrive and have the Mac behave like before. The benefit of this is that you can continue to use your Mac as you normally would but with the added benefit that should you loose or rebuild your Mac that the data is already up in SkyDrive. Now before we go any further, its worth making a point that you must have a backup of any files or folders in your profile that you want to move to SkyDrive. As you are going to see, we are going to be deleting some folders.

For the purpose of this post. I have a 256 GB solid state drive which I have partitioned so that I have the Mac OS on one partition and my Mac profile and other stuff along the way on the second partition. Also you are going to need to change the path names to match your own setup but I hope you get the idea.

So as you can see this is a standard Mac profile and I have already downloaded and installed SkyDrive which is fully synchronised

Screen Shot 2013-11-16 at 13.14.16

Read more…

Powershell: MAK KMS Activate Windows

Author: WallaceTech  |  Category: Powershell Scripts, Server 2003, Server 2008, Server 2012, VMware, Windows 7, Windows 8
Working with a Server 2012 VMware template and how to deal with activating the server during build time.
Part of the issue is that I did not want the template to be part of the KMS activation. I wanted the
option of MAK or KMS and so below is a Powershell script I knocked up to give you the option.

Write-Host "********************************************"        -ForegroundColor Green
Write-Host "Global Server 2012 Activation MAK or KMS"            -ForegroundColor RED
Write-Host "By: Craig Wallace"                                   -ForegroundColor RED
Write-Host "Created: 14/10/2013"                                 -ForegroundColor RED
Write-Host "********************************************"        -ForegroundColor Green
Write-Host " "
Write-Host "Press E - Exit Script"                               -ForegroundColor Magenta
Write-Host "Press M - MAK Activation SERVER 2012 TEMPLATE ONLY"  -ForegroundColor Magenta
Write-Host "Press K - KMS Activation"                            -ForegroundColor Magenta
Write-Host " "

$Response = Read-Host "Exit Script[E], MAK Activation[M], KMS Activation[K]"

If($Response -eq "E"){powershell -noexit}
If($Response -eq "M"){Write-Host Activating Windows Server 2012 MAK... Please be patient}
If($Response -eq "M"){cscript //B "C:Windowssystem32slmgr.vbs" /ipk MAK PRODUCT CODE HERE}
If($Response -eq "K"){Write-Host Activating Windows Server 2012 KMS... Please be patient}
If($Response -eq "K"){cscript //B "C:Windowssystem32slmgr.vbs" /ipk KMS PRODUCT CODE HERE}
If($Response -eq "K"){cscript //B "C:Windowssystem32slmgr.vbs" -skms KMS HOST NAME HERE}
If($Response -eq "K"){cscript //B "C:Windowssystem32slmgr.vbs" /ato}

Powershell: Get-QADGroupMember -Indirect

Author: WallaceTech  |  Category: Powershell Scripts

One Powershell CMDLet I like and use quite a bit is Get-QADGroupMember and using it for example thus:


The issue comes when you want to display the members of any nested groups. When going through the properties of the Get-QADGroupMember CMDLet I noticed that there is a -Indirect switch. This switch will retrieve the nested member.

Get-QADGroupMember -Indirect  GROUP-NAME-HERE

Batch: PSEXEC remove software

Author: WallaceTech  |  Category: Batch Scripts

So using PSEXEC to remove software is an oldie but a goodie. I had a situation where trying to remote uninstall software on Windows XP via Powershell , VBScript and even SMS 2003 was not quite playing ball. The PSEXEC method is a little dirty but it’s very fast and effective. You could of course substitute the msiexec command for anything else that you would like to run on the remote PC.

First thing is download PSEXEC from LINK HERE

 Once downloaded and extracted I would copy the .exe to the WindowsSystem32 directory.

Next create a .txt file called Computers.txt and add in all the computer names that you wish to uninstall the software from.  Then create a .CMD with the text below.


For /F "tokens=1" %%i IN (COMPUTERS.TXT) DO (
  psexec <a href="file://%25%25i/">\%%i</a> -u USERNAME-HERE -p PASSWORD-HERE -i msiexec.exe /x "{blah blah blah}" /q

I try to do everything in Powershell but I guess there is life in the old dog (DOS Windows Commands) yet.

VMWare: The server fault ‘SystemError’ had no message

Author: WallaceTech  |  Category: VMware


I stumbled across an issue on a vShere 4.1 and 4.1 vCenter. I was trying to deploy a server from template which kept on crashing out. When I converted the template to a VM I was unable to edit the settings.

I was receiving  the message below

The server fault ‘SystemError’ had no message


I was able to get around this issue by shutting down the VM and then removing it from the Inventory and then adding it back in again