Forums Online

Mucking around with some forum software, and have made a forum available at http://forum.stott.asia

You need to register to post, which will probably put most people off posting – The alternative is a forum full of Indonesian viagra spam, which the internet already has enough of.

You can post threads and request assistance with anything you come across here, or any other server issues which you would like to discuss.

Posted in Uncategorized | Leave a comment

RDS Broken after Virtual Machine reconfiguration

After migrating a few virtual machines across datacentres (using vConverter in this instance, but the same error could occur with any type of VM configuration, specifically when adding and removing virtual NICs), I was no longer able to RDP a server previously configured with Remote Desktop Services (RDS). I actually forgot to screenshot the RDP error, but it was “Remote Desktop can’t connect to the remote computer for one of these reasons: 1) Remote accces to the server is not enabled 2) The remote computer is turned off 3) The remote computer is not available on the network.  Make sure the remote computer is turned on and connected to the network, and that remote access is enabled.”

On the affected host, navigate to RDS Administration (Start > Admin Tools > Remote Desktop Services > Remote Desktop Session Host Configuration:

Right-click the RDP-Tcp connection & select Properties:

RDS1

The error message is displayed when switching to the Network Adapter tab:

RDS2

“Remote Desktop Session Host Configuration tool is not able to obtain the properties for this connection. The connection has either been deleted or the internal state of this connection has been corrupted. Please close all property pages, and select refresh from the menu.”

You can see here the defined Network Adapter is missing completely, but can’t be changed:

RDS3

Start Regedit and navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp

Set the ‘LanAdapter’ value to 0

Restart RDS services or server, and retry RDP!

RDS4

Posted in Server 2008, Server 2012, Uncategorized | Tagged , , , , | Leave a comment

Macro Enabled Purchase Order Template

It’s been two years since I uploaded my Macro Enabled Purchase Order Template, and it’s been one of the most popular pages & downloads on my site to date…. I’ve recently updated this to fit some new requirements & I thought I’d share this with you all as it’s a bit shinier than before (oooh)

Purchase Requisition Template 63.4 KB

It has the same requirements as before:

  • Unique purchase order number on each request
  • Reduce the number of manual steps required to get approval from line manager
  • Provide centralised logging & archive of purchase orders raised

The updated template now also does the following:

  • Macro added to add & remove rows as required
  • Removed rows are deleted to prevent contribution to the total when non-visible
  • Protects cell formatting against pasted formatting
  • Conditional formatting to make the form look a bit neater
  • Only emails the range as it displays within Excel, not the entire worksheet

Important Steps:

  • You will need to add a reference to the Microsoft Office Object Library from Excel
  • Macros must be enabled (make the XLSX file a trusted document)
  • You must have Outlook & a valid MAPI profile for Outlook to be called
  • The email macro does not look up against exchange – The names you use must match the display name or exchange alias of the users as they appear in your GAL. As long as the name matches, Outlook will add the address and the mail will send. You could also use email addresses instead of names
  • You must update the paths to Purchase Order Log and the Archive PDF output, relative to your system. If you try and use the root of C:\ or any protected system folders the code will not run
  • The worksheet is protected except for editable cells, but there is no password. If unprotected, the worksheet will re-protect itself during various actions performed by the user

The Process Explained:

  • The user opens Purchase Requisition Form.xlsx. The PO number automatically increments by one & the file saves
  • User enters the details as required to the form. Once completed, the user his the Generate button
  • Email is generated & a PDF copy attached. Email is addressed To: {Approval field}; Cc: {Requested By field}
  • If there is a value inserted to the Service Request field, then our servicedesk@company.com address is CC’d to the email, and the SR# is added to the subject line for email integration
  • The PDF is written to disk, using the variables from the spreadsheet & today’s date/time for the filename to ensure no accidental file overwrites
  • The summary on the ‘Data’ worksheet is copied & pasted to the Purchase Order Log.xlsx sheet. You can hide the ‘Data’ worksheet once you’ve finished modifying anything
  • The visible portion of the purchase order is copied as a range & pasted to the email ready to send
  • User closes the workbook without saving changes (leaving the blank template ready for other staff)
  • In order to raise two consecutive PO’s, simply hit the ‘Reset Fields’ button to wipe input data, and increment to the next PO number

The Code:

I have added comments throughout the code which will assist you in editing this to fit your requirements. There code is broken down on the prior version of this post here, it’s not changed enough to warrant me reposting the same  information. To edit the VBA, press ALT+F11 in Excel. The different parts of the code can be found in the following locations:

Microsoft Excel Objects > ThisWorkbook
Autorun macros

Modules > Module1
Required fields validation
Create email
Save archive PDF
Update log

Modules > Module2
Reset form button

Modules > Module 4:
Add Row / Delete Row

The empty form:

PReq1a

Once completed, the generated email:

PReq2

 

 

 

 

Posted in Macro, MS Excel, VBA | Leave a comment

Scripting Automatic Uninstall of Internet Explorer 10 and 11

I had to find a way of rolling back a bunch of Windows 7 workstations to Internet Explorer 9, due to a vendor’s specified supported platform. I thought scripting  an automatic uninstall via Group Policy to remove the Internet Explorer 10 and 11 KB updates on logon would be the best way to do this.

The requirements for this were:

  • Automatic silent un-installation
  • If a user manually upgrades Internet Explorer, automatically running again to remove the update
  • Some basic output for troubleshooting
  • Ignores 64bit OS-es

Below is the batch script I wrote, which checks the registry keys to find the installed version of Internet Explorer, and then if found, issues the relevant uninstall command. It writes a couple of files locally to check if it’s been run before, and keeps a time stamped log on a central file share of each action taken against each machine.

Also, used the Microsoft ADM templates as part of the same policy to prevent automatic redeployment of IE 10 and IE 11 via Windows Updates:

Toolkit to Disable Automatic Delivery of Internet Explorer 11
http://www.microsoft.com/en-au/download/details.aspx?id=40722

Toolkit to Disable Automatic Delivery of Internet Explorer 10
http://www.microsoft.com/en-us/download/details.aspx?id=36512

The script will check through the registry for the value of two registry keys which  contain the current version number of Internet Explorer:
HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Version
HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\SvcVersion

Once the version number is determined, the appropriate action is taken:

  • Version 11: Silently issue uninstall of KB2841134​, rolling the computer back to IE9
  • Version 10: Silently issue uninstall of KB2718695, rolling the computer back to IE9
  • Version 9: No action taken, script logs an exit & the values matched
  • Version 8: As above. WSUS will push out IE9 to this machine if it hasn’t done already

The script also writes some text files to a local directory, under C:\TEMP\. The script uses these files as flags to determine if it needs to run again or not.

If a previously uninstalled V10 or V11 is upgraded again, the script should detect this and reset these flags.

Because of the way Internet Explorer updates apply, expected behaviour of this is as follows (assuming a user has just installed IE11 manually):

  • User logs on, already has V9 installed. Script runs & detects no action is required
  • User installs IE10 or IE11. Reboot is required to finalise installation (if user does not reboot, they will have IE10 / IE11 for the duration of this session)
  • User reboots computer
  • Windows presents ‘Configuring updates’ on shutdown & again on start-up to apply IE10 / IE11
  • Computer presents CTRL+ALT+DEL. Script runs, detects & uninstalls upgraded IE10 / IE11
  • When the user logs back in, they will have IE10 or IE11 available to them, however it has already been uninstalled (just not applied via Windows Updates yet)
  • User reboots
  • Windows presents ‘Configuring updates’ on shutdown & again on start-up to apply IE9
  • Computer presents CTRL+ALT+DEL. Script runs and detects IE9 installed and no action required
  • User logs in, and is presented withIE9Might not be the cleanest / most efficient way of doing this, but by crikey it works.
setlocal ENABLEEXTENSIONS

REM Set current date & time
for /f "tokens=1-3 delims=/- " %%a in ('date /t') do set XDate=%%a-%%b-%%c 
for /f "tokens=1-2 delims=: " %%a in ('time /t') do set XTime=%%a.%%b 

IF NOT EXIST "C:\TEMP" (MKDIR C:\TEMP\)

Echo Beginning script @ %XDate% %XTime% on machine %COMPUTERNAME% >> \\SERVERNAME\IEScripts\%COMPUTERNAME%.txt


:OSTest
IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT)


:64BIT
Echo 64Bit OS detected, exiting.. >> \\SERVERNAME\IEScripts\%COMPUTERNAME%.txt
exit


:32BIT
Echo 32Bit OS detected, continuing... >> \\SERVERNAME\IEScripts\%COMPUTERNAME%.txt
 

:CHECKVER
REM Checking HKLM\Software\Microsoft\Internet Explorer\Version key value and setting versionNumber value

set "KEY_NAME=HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer"
set "VALUE_NAME=Version"
For /F "tokens=2*" %%A IN ('REG QUERY "%KEY_NAME%" /v "%VALUE_NAME%"') Do (
 set "versionNumber=%%B"
)
for /f "delims=." %%a in ("%versionNumber%") do set "versionNumber=%%a"
Echo Internet Explorer v%versionNumber% detected in reg key 'VERSION'>> \\SERVERNAME\IEScripts\%COMPUTERNAME%.txt


:CHECKVER1
REM Checking HKLM\Software\Microsoft\Internet Explorer\SvcVersion key value and setting versionNumber1 value

set "KEY_NAME=HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer"
set "VALUE_NAME=svcVersion"
For /F "tokens=2*" %%A IN ('REG QUERY "%KEY_NAME%" /v "%VALUE_NAME%"') Do (
 set "versionNumber1=%%B"
)
for /f "delims=." %%a in ("%versionNumber1%") do set "versionNumber1=%%a"
Echo Internet Explorer v%versionNumber1% detected in reg key 'SVCVERSION' >> \\SERVERNAME\IEScripts\%COMPUTERNAME%.txt

:CHECKER
REM Checks if previous uninstallation has been reverted. If so, deletes .txt flags from computer to allow script to run again. If registry returns 8 or 9 for either value & the .txt file exists, file will exit.
if %versionNumber1% GEQ 11 del C:\Temp\IE*.txt
if %versionNumber% GEQ 11 del C:\Temp\IE*.txt
if %versionNumber1% GEQ 10 del C:\Temp\IE*.txt
if %versionNumber% GEQ 10 del C:\Temp\IE*.txt
IF EXIST "C:\TEMP\IE8.txt" GOTO EOF
IF EXIST "C:\TEMP\IE9.txt" GOTO EOF
IF EXIST "C:\TEMP\IE10.txt" GOTO V9
IF EXIST "C:\TEMP\IE11.txt" GOTO V10


:V11
REM Set date & Time, then issue uninstall commands if VERSION or SVCVERSION values are 11

for /f "tokens=1-3 delims=/- " %%a in ('date /t') do set XDate=%%a-%%b-%%c 
for /f "tokens=1-2 delims=: " %%a in ('time /t') do set XTime=%%a.%%b

if %versionNumber1% GEQ 11 wusa /uninstall /KB:2841134 /quiet /norestart
if %versionNumber1% GEQ 11 Echo %XDate% %XTime% Issued uninstall of KB2841134 (IE v11) due to VALUE_NAME=SVCVERSION=%versionNumber1% >> \\SERVERNAME\IEScripts\%COMPUTERNAME%.txt

if %versionNumber% GEQ 11 wusa /uninstall /KB:2841134 /quiet /norestart
if %versionNumber% GEQ 11 Echo %XDate% %XTime% Issued uninstall of KB2841134 (IE v11) due to VALUE_NAME=Version=%versionNumber% >> \\SERVERNAME\IEScripts\%COMPUTERNAME%.txt

if %versionNumber1% GEQ 11 Echo %XDate% %XTime% Issued uninstall of IE v11. Please check \\SERVERNAME\iescripts\%computername%.txt for verbose logging >> C:\TEMP\IE11.txt
if %versionNumber% GEQ 11 Echo %XDate% %XTime% Issued uninstall of IE v11. Please check \\SERVERNAME\iescripts\%computername%.txt for verbose logging >> C:\TEMP\IE11.txt

if %versionNumber1% GEQ 11 GOTO EOF
if %versionNumber% GEQ 11 GOTO EOF


:V10
REM Set date & Time, then issue uninstall commands if VERSION or SVCVERSION values are 10

for /f "tokens=1-3 delims=/- " %%a in ('date /t') do set XDate=%%a-%%b-%%c 
for /f "tokens=1-2 delims=: " %%a in ('time /t') do set XTime=%%a.%%b

if %versionNumber1% GEQ 10 wusa /uninstall /KB:2718695 /quiet /norestart
if %versionNumber1% GEQ 10 Echo %XDate% %XTime% Issued uninstall of KB2718695 (IE v10) due to VALUE_NAME=SVCVERSION=%versionNumber1% >> \\SERVERNAME\IEScripts\%COMPUTERNAME%.txt

if %versionNumber% GEQ 10 wusa /uninstall /KB:2718695 /quiet /norestart
if %versionNumber% GEQ 10 Echo %XDate% %XTime% Issued uninstall of KB2718695 (IE v10) due to VALUE_NAME=Version=%versionNumber% >> \\SERVERNAME\IEScripts\%COMPUTERNAME%.txt

if %versionNumber1% GEQ 10 Echo %XDate% %XTime% Issued uninstall of IE v10. Please check \\SERVERNAME\iescripts\%computername%.txt for verbose logging >> C:\TEMP\IE10.txt
if %versionNumber% GEQ 10 Echo %XDate% %XTime% Issued uninstall of IE v10. Please check \\SERVERNAME\iescripts\%computername%.txt for verbose logging >> C:\TEMP\IE10.txt

if %versionNumber1% GEQ 10 GOTO EOF
if %versionNumber% GEQ 10 GOTO EOF


:V9
REM If version 9 is detected by this point, log and exit
if %versionNumber1% GEQ 9 Echo v%versionNumber1% detected - exiting without changes. VALUE_NAME=SvcVersion=%versionNumber1%. Please check \\SERVERNAME\iescripts\%computername%.txt for verbose logging >> C:\TEMP\IE9.txt
if %versionNumber% GEQ 9 GOTO EOF

:V8

REM If version 8 is detected by this point, log and exit
Please check \\SERVERNAME\iescripts\%computername%.txt for verbose logging >> C:\TEMP\IE8.txt
if %versionNumber% GEQ 8 GOTO EOF

:EOF
for /f "tokens=1-3 delims=/- " %%a in ('date /t') do set XDate=%%a-%%b-%%c
for /f "tokens=1-2 delims=: " %%a in ('time /t') do set XTime=%%a.%%b
Echo Finished script @ %XDate% %XTime% >> \\SERVERNAME\IEScripts\%COMPUTERNAME%.txt
Echo ====================================================================================== >> \\SERVERNAME\IEScripts\%COMPUTERNAME%.txt
exit

 

Posted in Batch, Group Policy | Tagged , , | Leave a comment