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

Capture

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"
}
Else
{
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.

Jointool.txt

[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.

Resolution:

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

VM3

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.

VM4

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:


Get-QADGroupMember GROUP-NAME-HERE

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.


@ECHO OFF

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

All.

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

1

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

VMWare: vSphere 5.5 Client Windows XP SP3

Author: WallaceTech  |  Category: VMware, Windows XP

So it would seem the latest vSphere client will not run on Windows XP. I know XP is about to go extinct but it’s not gone yet.

 When installing the 5.5 client on XP you may receive the message below. VMware response and the link to the KB article is below.

27-09-2013 12-27-08

VMWare response:

For Windows Server 2003, 64-bit Windows XP, or 32-bit Windows XP, take either of the following actions:

Before installing the vSphere Client or vSphere PowerCLI, upgrade the Windows operating system on the host machine to Windows Vista or later.

VMWare KB Article

VMWare: vSphere 5.5 is here! – KBs you need to know about

Author: WallaceTech  |  Category: VMware

vSphere 5.5 has been released for all to download. We’re sure vSphere users are all eager to install a copy and start kicking the tires, and we’re just as eager to see that you get started on the right foot. With this in mind, we have created the following list of Knowledge base articles that are brand new, or have been updated for vSphere 5.5 You’ll notice lots of best practices KBs here.

LINK HERE

VMware: Make your VMNics blink

Author: WallaceTech  |  Category: VMware

Great post over on Jonathan Medds blog on how to make your VMNics blink


ethtool -p vmnic0 5

Original link to to Jonathan Medd below.

LINK

Powershell: Query Software Install

Author: WallaceTech  |  Category: Active Directory, Powershell Scripts, Server 2003, Server 2008, Server 2012, Windows 7, Windows 8, Windows XP

Hi Guys, So here is a Powershell script that I have been working on. The script will connect to Active Directory and export a list of servers where the OSName contains SERVER. It will then ask you what software you would like to search for on the servers. You can search and return everything or something specific. It will output this all to .CSV file. You can change the Get-QADComputer command to return the type of machine you want.

#Script Start Time

$ScriptStart = (Get-Date)

# Connect to Active Directory and return all computers where the OS name contains SERVER 
Get-QADComputer -OSName '*SERVER*' | %{$_.name} | Sort-Object $_.name | Out-File S:ADServers.txt

# Error Action</span>
$erroractionpreference = "SilentlyContinue"

# The directory to put your csv file of results
$outputDir = "S:InstalledSoftware.csv"

# Path to your txt file with a list of computers and testing to see if it's online
Write-Host -fore Blue "Checking for computers that are online, this may take a while for many machines."
$arrComputers = get-Content -Path "S:ADServers.txt" | Where-Object {Test-Connection -ComputerName $_ -Quiet -Count 2}

# What software are you searching for?
# % is the wildcard
Write-Host
Write-Host "Type the name of the software you're looking for. (ex. McAfee% or Windows%)"
$filter = Read-host "The % sign is the wildcard character."
if (!$filter) {
Write-Host -fore Red "No filter set, stopping script!"
Break
}
$(foreach ($strComputer in $arrComputers){
$osVersion=Get-WmiObject -class win32_operatingsystem | select Caption,CSDVersion
$osVersion=($osVersion.Caption + $osVersion.CSDVersion) -join ""
get-wmiobject -Class win32_product -computername $strComputer -Filter "Name like '$filter'" |
Select `
@{n="ComputerName";e={$strComputer}},
@{n="OSVersion";e={$osVersion}},
Name, Version, InstallDate

}) | Export-csv -notypeinformation $outputDir
Write-Host
Write-Host -fore Blue "Script Complete"

# Script End Time

$ScriptEnd = (Get-Date)

$RunTime = New-Timespan -Start $ScriptStart -End $ScriptEnd

"Elapsed Time: {0}:{1}:{2}" -f $RunTime.Hours,$Runtime.Minutes,$RunTime.Seconds

Powershell: Exchange 2003 Item Count

Author: WallaceTech  |  Category: Exchange 2003, Powershell Scripts

I was asked to obtain a mailbox item count for Exchange 2003. Not the easiest method as you have to drop back to WMI

 


$ExportCSV = 'C:mailboxReport_YYYYMMDD.csv'

$ExportCSV = $ExportCSV -replace 'YYYYMMD',(Get-Date -f 'yyyMMdd')

$computers = "COMPUTER-NAME-HERE"

Get-Wmiobject -namespace rootMicrosoftExchangeV2 -class Exchange_Mailbox -computer $computers |
Select-Object MailBoxDisplayName,StorageGroupName,StoreName,Size,TotalItems,LastLogonTime |

Export-Csv $ExportCSV -NoType

Powershell: Export AD Users + Secretary Name + Extension

Author: WallaceTech  |  Category: Active Directory, Powershell Scripts

 So I had a request to export some data from Active Directory in to a CSV file. Easy I thought as exported data out loads of times. The issue came when I needed to export out the users Secretary and the Secretary extension number.

 If you was to run something like

Get-QADUser ABC -IncludeAllProperties -SizeLimit 0 | Select-Object SamAccountName , Secretary

 Then you would see that the results for the secretary are the CN=LastName, FirstName,OU=blah blah blah. That is no good and can’t have that in the CSV export. Now I can’t take full credit for the code below as Art over on the PowerGUI forums has been most helpful in working with me to produce something that achieves what I need Read more…