Windows Server 2016 Optimisation Script

Windows Server 2016 Optimization Script.

Tested on: Windows Server 2016 build 14393.0.

Description: This script disables services, removes  scheduled tasks and imports registry values to optimise system performance on Windows Server 2016 running in a Citrix SBC environment.

Warning: This script makes changes to the system registry and other configurational change  and as such a full backup of the machine or # snapshot if running in a virtual environment is strongly recommended. Carry out full testing before introducing image to production.

Note: You should review ALL optimisations this script makes and determine if they fit in to your environment. Not every optimisation suits all environments. For example, this script disables key Hyper-V services for use in non-Hyper-V environments. If you use Hyper-V, you must enable these services.

Instructions: To avoid failure, run PowerShell as an administrator.

Download (click below):

Windows Server 2016 Optimisation Script (3747 downloads)

Any problems with the script or if you want to make your own improvement suggestions then comment below.

Open the script using a text editor or PowerShell ISE to see what exactly the script does.


128 Comments

  • Steve Elgan

    April 14, 2017

    Great script. You may want to consider setting power to high performance and also disabling Server Manager task.

    Reply
    • George Spiers

      April 15, 2017

      Thanks. I did consider including disabling Server Manager on startup at the time however that is an HKCU key. I’ve included High Performance.

      Reply
  • RICHARD HUGHES-CHEN

    May 18, 2017

    Was looking for some 2016 optimizations to test in my POC.

    If using Citrix App Layering would it be best to run in the OSLayer or as another layer?

    There seems to be a similar script configured with Citrix App Layering in the OS machine tools scripts folder C:\windows\setup\scripts\Optimize.html

    What is the best thing to do?

    Reply
    • George Spiers

      May 18, 2017

      Run optimisations in the OS Layer. The script I provide is specifically for Windows Server 2016 and does contain a tonne of optimisations that have been checked and evaluated thoroughly. The Optimisation builder you mention does contain probably the same optimisations that my script has but not as many.

      Reply
  • eltjo

    May 19, 2017

    Hello George,

    how does your script compare the Base Image Script Framework (BIS-F) that Login has released?

    Regard,

    Eltjo

    Reply
  • George Spiers

    May 19, 2017

    BIS-F can run defragmentations, clean out profiles, rearm Office, run Antivirus etc. and many other preparation type tasks. My script is purely disabling Services, disabling Scheduled Tasks, removing Active Setup, decreasing Event Logs size and much more to get the best performance out of your image.

    Reply
    • Matthias Schlimm

      June 14, 2017

      You can use this Optimization Script in a combination with BIS-F, copy it to the custom preparation folder in BIS-F and it would be automatically executed if you BIS-F starts.

      Reply
    • George Spiers

      May 31, 2017

      Thanks – I had a review. I’m going to include 8 more services to be disabled. The document also says to disable some services but I’m not going to disable via the script. Examples are Print Spooler (required to see printers so not wise to disable). The document also doesn’t specify to disable services such as Remote Access Connection Manager. My script disables it since there is no need to manage dial-up and VPN connections. Also the script disables superfetch (service that improves performance over time) – not useful for stateless machines.

      Reply
      • Steve Elgan

        May 31, 2017

        Cool. What are your thoughts on configuring the script in such a way that you can pass a variable for a Citrix config vs. just a general 2016 server config? Right now I just comment out lines that are specific to Citrix workloads when I want to use it on a general 2016 server. I’m still learning PoSh but i’d be willing to work up a PoC for you to review.

        Reply
        • George Spiers

          May 31, 2017

          The script is focused on SBC regardless of whether the image is deployed via Citrix, RDS, VMware. Everyone’s taste will be different in terms of what to keep and remove. That is why I think it’s easier to suggest that each person reviews what this script does and then remove or comment out lines to their liking.

          Reply
      • RICHARD HUGHES-CHEN

        June 1, 2017

        Hi George, have you included the additional services to be disabled in the script? Thanks

        Reply
        • George Spiers

          June 1, 2017

          Hey. Yes they are included now.

          Reply
  • RICHARD HUGHES-CHEN

    June 1, 2017

    just noticed the comments around Hyper-V which is what I am using.

    # in non-Hyper-V environments. If you use #

    # Hyper-V, you must enable these services.

    Reply
    • George Spiers

      June 1, 2017

      That’s right. Edit the script and remove the lines relating to disabling Hyper-V services.

      Reply
  • Jochen

    June 23, 2017

    Hello,
    I used this script in my test environment and it is great, Much more responsive Xenapp Server.
    The only thing I have now is that during logon I am stuck for about 20-30 seconds on the following message: please wait for user profile service.
    After this everything is lightning fast.
    Any idea why i have to wait for the user profile service? (We use roaming profiles)

    Reply
    • George Spiers

      June 23, 2017

      Thanks for the feedback. Have you tried taking roaming profiles out of the equation to see if it still occurs? That would be my first action, pick a machine, put it in maintenance mode, disable roaming profiles and test.

      Reply
  • Frank

    July 10, 2017

    hi george
    i take also bis-f script from matthias schlimm, and now there is the CTXOE supported. so your script is awesome, but did you test if CTXOE make the same now, or did you make some additional special things, so that both scripts will be good for optimization?
    regards
    frank

    Reply
    • George Spiers

      July 10, 2017

      The Citrix Optimizer tool has 71 different types of optimisations for Windows Server 2016. The script here has 170+ different optimisations. There are about 5-7 different unique optmisations in Citrix Optimiser with the majority of those left out of my script intentially. So my script has 90% of optimisations that are included in the Citrix Optimizer tool but around 80+ additionals. For example Citrix Optimizer does not disable Xbox related Scheduled Tasks whereas my script does. You are safe to use both, which I highly recommend.

      Reply
  • Steve Elgan

    August 1, 2017

    George,

    Have you considered adding any of the optimizations mentioned in Rory’s blog post here? http://rorymon.com/blog/?p=3951

    For example the other offload options. Or what about disabling power management on the NIC card?

    Reply
    • George Spiers

      August 1, 2017

      No to disabling power management on NIC as I’ve not encountered that setting interfering with VDAs before and the script sets power to High Performance anyway. The script does disable TCP Large Send Offload but no other of the offload settings. I’ll have a look in to them to decide if they should go in the script. Thanks

      Reply
  • Jonathan Aumont

    August 23, 2017

    HI,
    this is an awsome script. I was wondering if you have a word or excel document that list all the features that you do modify in your script?

    Reply
    • George Spiers

      August 23, 2017

      Sure, I have your email so I’ll send the Excel document across.

      Reply
      • Jonathan Aumont

        August 24, 2017

        thank’s for this. I’ll wait for it.

        Reply
  • Vincent Caberas

    September 2, 2017

    Hi george,

    Thank you for your very good Word. I m interesting too, about the Excel file with the optimization. Thank you

    Reply
    • George Spiers

      September 3, 2017

      No problem, I’ll send it to you soon.

      Reply
  • Mikael Laine

    September 7, 2017

    Great work George. I’ll have a rundown in our lab environment and provide some feedback. Would it be ok to drop me the excel sheet?

    Reply
    • George Spiers

      September 8, 2017

      Thanks and sure – I’ll get that across to you later today.

      Reply
  • jonathan Aumont

    September 8, 2017

    Hi George,
    One quick question for you. Is there any part in your script that might affect the Microsoft supportability of the Windows 2016 OS?

    Regards.

    Reply
    • George Spiers

      September 8, 2017

      I can’t exactly comment for sure on Microsoft’s support terms and conditions. I can’t imagine they would deny support because you have disabled a Scheduled Task or Service, they would likely just ask you to enable it. If system settings are configurable then they are there to be changed and modified. The script itself does not perform anything that is irreversible.

      Reply
      • jonathan Aumont

        September 8, 2017

        Thanks for your quick reply. I agree with you on this. I was juste checking if you hade face a situation that it could break support. Thank again. really appreciated.

        Reply
        • George Spiers

          September 8, 2017

          No problem at all! 🙂

          Reply
  • Reinhard

    September 13, 2017

    Hi George,

    great script, thanks for sharing! Could you please also send me the Excel?

    Reply
    • George Spiers

      September 13, 2017

      Thanks. Yes I have just sent it.

      Reply
  • Owen Reynolds

    September 15, 2017

    Amazing!
    I ran this on a XD 7.15 / Win 2016 in my home lab tonight, and noted a huge performance in logon and over-all UI latency!

    Great work , George!

    One question – would this script be appropriate for non Citrix Windows Server 2016 installs? Looking over the various changes, they seem appropriate for Win 2016 as it’s used in other roles: File servers, active directory controllers, store front , SQL , etc.

    Owen

    Reply
    • George Spiers

      September 15, 2017

      Cool, it’s nice to hear good results! In regards to running it on other servers, I guess it is up to you. Personally I do not run optimisations on non Citrix servers, but it would not be a bad practice at all.

      Reply
      • Owen Reynolds

        September 15, 2017

        I’ll give it a shot on my other servers, thx again.
        Wold you be able to send me the xls that contains the items changed by this script?

        Reply
        • George Spiers

          September 15, 2017

          Have sent it.

          Reply
  • Gareth

    September 18, 2017

    George this is amazing work! Thank you for sharing, you’ve saved me hours of work. Could I push my luck a little further and trouble you for a copy of your excel document please.

    Reply
    • George Spiers

      September 18, 2017

      Thanks – I will send you the document shortly.

      Reply
  • Michael

    September 28, 2017

    George – great job! Love the script! Thank you so much for sharing! Could I also have a copy of the Excel spreadsheet? Thanks!

    Reply
    • George Spiers

      September 28, 2017

      Thanks. I have sent it across to you.

      Reply
  • Zach

    September 29, 2017

    Will this also disable/remove Windows Ink Workspaces?

    Reply
    • George Spiers

      September 29, 2017

      No I can confirm it doesn’t.

      Reply
  • Alexander Schwarz

    October 5, 2017

    Hello George
    I´m very happy that I found this great script!
    Thank´s a lot for sharing 🙂
    Can you also send me the excel sheet?

    Reply
    • George Spiers

      October 5, 2017

      Thanks. Glad you like it. I’ve just sent the sheet across.

      Reply
  • Tommy

    October 8, 2017

    Thansk George

    Will this work on Windows 2016 RDP server ?

    Regards
    /Tommy

    Reply
    • Tommy

      October 8, 2017

      Hi Goerge

      Actual my Questions was is it possible to run this script on Windows 2018 RDP server
      that running in vmware as guest?

      /Tommy

      Reply
      • George Spiers

        October 8, 2017

        Hi Tommy, yes this will work fine on RDSH.

        Reply
  • Tommy

    October 9, 2017

    Great George and Thanks!

    Sorry for my bad English 🙂

    Regards
    Tommy

    Reply
  • George Spiers

    October 9, 2017

    Your English is great actually! 🙂

    Reply
  • Aaron

    October 10, 2017

    FYI
    Your ClearPageFileAtShutdown setting isn’t correct, its re-running the NtfsDisableLastAccessUpdate command.

    Reply
    • George Spiers

      October 10, 2017

      Thanks for pointing that out. I’ve corrected it.

      Reply
  • Srinivas

    November 7, 2017

    Hi George,

    can this script run on Win2k12 R2.

    Thanks,
    Sri

    Reply
    • George Spiers

      November 7, 2017

      No I do not advise this as the script was created for WS2016 and may contains Services, Scheduled Tasks and so on that are not available on WS2012 R2.

      Reply
      • Jos van Rijn

        December 20, 2017

        Your script runs just fine on 2012 R2. I’m seeing the same performance boost as in 2016. Services and tasks that aren’t available in 2012 R2 get skipped, so no problem there.

        Thanks so much for sharing this with us.

        Reply
        • George Spiers

          December 21, 2017

          Brilliant thanks for sharing that feedback with us.

          Reply
  • Brian Mooney

    November 10, 2017

    George,
    How does your script work compared to the Citrix latest Citrix optimization tool? Have you compared the two?

    Reply
    • George Spiers

      November 10, 2017

      I haven’t checked recently but last time I did check the script had over 80+ additional customisations.

      Reply
  • Steve Turnbull

    November 23, 2017

    Hi George, thanks for all your hard work on this script. Please could you send over the excel sheet too for reference. Many thanks!

    Reply
    • George Spiers

      November 24, 2017

      Have sent it.

      Reply
  • Tom

    November 30, 2017

    Great work, George. Can you please send me the Excel sheet? Thank you.

    Reply
    • George Spiers

      November 30, 2017

      Sent!

      Reply
  • Satya

    December 15, 2017

    George , Please send me the excel sheet. Thank you.

    Reply
  • Satya

    December 15, 2017

    Great work, George. Can you please send me the Excel sheet? Thank you.

    Reply
    • George Spiers

      December 15, 2017

      Hi, yes I have just sent it.

      Reply
  • Pingback: Image Optimization Tools Comparison Matrix - Dennis Span

  • Rene

    December 25, 2017

    Hi this helped me alot can you also send me the excel sheet please ?

    Reply
    • George Spiers

      December 28, 2017

      No problem I have sent it.

      Reply
  • SRasschaert

    December 29, 2017

    Hi George, have you considered creating a VMware OSOT template? (https://labs.vmware.com/flings/vmware-os-optimization-tool)
    Or a Citrix Optimizer template (https://support.citrix.com/article/CTX224676)

    Reply
    • George Spiers

      December 29, 2017

      Hi, I have had plans to create a Citrix Optimizer Template, just have not got round to it yet 🙂

      Reply
  • Ivan

    December 29, 2017

    Hi, can you send me a word or excel, with changes in script?

    Reply
    • George Spiers

      December 29, 2017

      Sent.

      Reply
  • Fadi

    January 2, 2018

    Hello George,

    I would like to test the script but wanted to check the excel/word sheet so I can review the services/task that are configured.

    Thank you!

    Reply
    • George Spiers

      January 2, 2018

      No problem I have sent it.

      Reply
  • Aasim

    January 6, 2018

    Hi, I would like to test the script but wanted to check the excel/word sheet so I can review the services/task that are configured.

    Thank you!

    Reply
    • George Spiers

      January 8, 2018

      Sent.

      Reply
  • Njordur

    January 10, 2018

    Excellent script, sped up my server a lot.

    I’m also interested in the excel/word sheet… Do you mind sending that to me as well

    /Thanks for your hard tuning 🙂

    Reply
    • George Spiers

      January 10, 2018

      No problem, thanks. I have sent the spreadsheet.

      Reply
  • Chassidy

    January 10, 2018

    I’m also interested in the excel/word sheet. Thanks for suck an awesome script!

    Reply
    • George Spiers

      January 10, 2018

      No problem I have sent it.

      Reply
  • Daniel Gifford

    January 11, 2018

    Looks like a great script for Server 2016. Been encountering lots of slowdowns on Server 2016 especially in RDS/Citrix environments. Can you send me the Excel sheet as well? Thanks!

    Reply
    • George Spiers

      January 11, 2018

      Yes have sent it.

      Reply
  • mart

    January 18, 2018

    I’m also interested in the excel/word sheet. Thanks for suck an great script!

    Reply
    • George Spiers

      January 18, 2018

      Sent!

      Reply
  • Anonymous

    January 18, 2018

    Hi George, great script.

    I have applied these optimations to 2x XenApp 7.15 servers running on VMWare. When I rebooted them I keep getting a warning on my network card (no internet). It appears as though I can still access the internet and local network OK. Outlook won’t connect though, to my internal Exchange server. I have tried turning off the firewall, wicksock reset on the NIC, removing and readding the NIC. No luck. Anything else you can think of from your script that might be causing this? It was working before I applied the script.

    Reply
    • George Spiers

      January 18, 2018

      Is your OS up to date? Are you using a VMXNET3 NIC? I’ve tested the script against Windows Server 2016 with December patches on VMware and I don’t see the same.

      Reply
    • Anonymous

      February 14, 2018

      I have this issue on several occasions using this script.

      Windows does indeed check a Microsoft site for connectivity, using the Network Connectivity Status Indicator site. There are a few variations of the connection checking process:

      NCSI performs a DNS lookup on http://www.msftncsi.com, then requests http://www.msftncsi.com/ncsi.txt. This file is a plain-text file and contains only the text Microsoft NCSI.
      NCSI sends a DNS lookup request for dns.msftncsi.com. This DNS address should resolve to 131.107.255.255. If the address does not match, then it is assumed that the internet connection is not functioning correctly.

      This happens.

      The only workaround for me was:

      HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NlaSvc\Parameters\Internet

      Under the Internet key, double-click EnableActiveProbing, and then in Value data, type: 0.The default for this value is 1. Setting the value to 0 prevents NCSI from connecting to a site on the Internet during checks for connectivity.

      Reply
  • Brad

    January 22, 2018

    Hello
    Great Script, can i get a copy of the excel document.

    Reply
    • George Spiers

      January 22, 2018

      Sent.

      Reply
  • Mayur

    January 23, 2018

    Please send me a link and or the excel doc.
    Many thanks!

    Reply
    • George Spiers

      January 23, 2018

      Sent!

      Reply
      • Mayur

        January 24, 2018

        I received it, thanks!
        Had a question on the disablement of Active Setup for speeding up logon times. I have used it for Win7 VDI with local profiles and it does make a big difference. I had learned that from Unidesk a while back. However, I have run into a small problem with XenApp 7.12 WS2012R2. For some strange reason, the published Outlook 2013 (transform) first time MAPI profile is not being created automatically and I am curious to find out if having disabled Active Setup might be the cause of this issue because if I understand it right it is required for roaming profiles.

        Reply
        • George Spiers

          January 24, 2018

          What happens the first time, is autodiscover becoming stuck? The second time it works? I’ve not experienced the same issue, I’m using Outlook 2016 – have not used 2013.
          Thanks

          Reply
          • Anonymous

            January 25, 2018

            Yes, in my case it consistently keeps failing and throws up a ambiguous pop up message:

            “Cannot start Microsoft Outlook. Cannot open the Outlook window. The set of folders cannot be opened. Your profile is not configured.”

            At first I thought the issue was related an AppLocking GPO settings but that didn’t solve the issue.

            I am contemplating whether to restore the Active setup registry settings. I deleted both the 32bit and 64bit settings and I did that on the VDA template image.

          • George Spiers

            January 25, 2018

            Restore them even temporarily to see if that fixes your issue?

          • Anonymous

            January 25, 2018

            I did restore the reg settings and it now works.

          • George Spiers

            January 26, 2018

            Thanks, I also tried using WS2016 and Outlook 2013 and did not have the same problem.

          • Mayur

            January 26, 2018

            In my case i had deleted the active setup stubs on a WS2012R2 and it seems to be breaking the auto discovery and mapi profile creation for published Outlook 2013. MS must have changed the use of Active Setup to speed up logon performance.

            Btw – A side question do you happen to have any example scripts for the customization of the default profile for published desktop? Having to do it manually is really a pain and it breaks the unattended build process of a Xenapp server.

          • George Spiers

            January 29, 2018

            I don’t nope. What do you mean by customising the default profile? I normally perform NTUSER.DAT customisations which apply then to users logging on to the box. I have a script for that, but they are just registry modifications.
            P.s. I did not experience the same issue as you regarding Outlook 2013 and WS2012 R2 but glad you have resolved the issue for yourself.

          • Mayur

            January 30, 2018

            I am trying to build a pooled MCS Win7 Image using MDT and would like to try and make it zero touch. I have tried various ways to import the registry settings which are mainly to do with setting the Visual Effects to custom and only enabling “Use visual styles on windows and buttons” into the NTUSER.DAT but for some reason I just can’t seem to get this to apply for any new users who logon.

          • George Spiers

            January 30, 2018

            Using a template machine, set the visual effects to custom and then uncheck/check the effects you want/don’t want. Then grab the value of “UserPreferencesMask” under “HKCU\Control Panel\Desktop”.

            You then want to make sure this UserPreferencesMask binary value is created for all users via WEM/GPO or else by using the NTUSER.dat method. You also want to make sure VisualEffects is set to 0x3 using the same methods (WEM/GPO/NTUSER.DAT).

          • Mayur

            January 30, 2018

            Yes, I have managed to get the correct hex value as the below plus there are other settings:
            [HKEY_USERS\Temp\Control Panel\Desktop]
            “UserPreferencesMask”=hex:98,12,03,80,10,00,00,00

            I place the above with other settings into a reg file called VisualEffects.reg

            I have a batch file for importing the reg into default profile but for some reason the settings do not seem to be applying to new profiles. I have done this before but it does not seem to be working for Visual Effects.

            REG LOAD HKU\Temp C:\Users\Default\NTUSER.DAT

            REM Configure the default user profile

            REM Customise Visual Effects Theme.
            REG IMPORT VisualEffects.reg

            REM Unload the default profile hive
            REG UNLOAD HKU\Temp
            exit

          • George Spiers

            January 31, 2018

            Someone else had the same issue and had to edit NTUSER.dat manually.

          • Mayur

            January 31, 2018

            Yes, the default user profile customization has always been tricky to automate. I will have to resort to suspend the MDT task sequence. Do the manual changes and copy the NTUSER.DAT.

  • Anonymous

    January 24, 2018

    Hello George,

    how are you?

    Thank you for the script. Do you have one for windows 10 as well?

    Cheers,
    Pavan

    Reply
    • George Spiers

      January 25, 2018

      Not at this time unfortunately.

      Reply
  • Dan

    January 25, 2018

    I would also greatly appricate a link to the excel doc please

    Reply
    • George Spiers

      January 25, 2018

      Sent

      Reply
  • Anonymous

    February 8, 2018

    George,

    I’m running into some issues with this script. I’m using 7.15.1000 on server 2016 with MCS as my provisioning method. After running the script on my master image some of my users are not loading the default background or any start menu icons. All of these settings are configured through WEM 4.5 and were working before the script. Is there a registry change in the script that I missed that could cause this?

    Your feedback and work on this script are much appreciated.

    Reply
    • George Spiers

      February 8, 2018

      Nothing that I know about. I use MCS, WEM and so on but do not see the same. Seems like the WEM agent is failing to apply settings periodically. I would expect this to happen to all users if it was a registry change. Have you checked WEM logs to see why actions are failing?

      Reply
      • Anonymous

        February 12, 2018

        That was my thought as well. I looked at the log parser and didn’t find anything. Maybe the WEM cache on the VDA is corrupt? Not really sure why WEM would be having such a problem. Have you run into WEM doing these kinds of things?

        Reply
        • George Spiers

          February 12, 2018

          I use a Scheduled Task on system startup which runs an Agent cache refresh and Norskale Agent Host service restart. Details are referenced at http://www.jgspiers.com/citrix-workspace-environment-manager/#Troubleshooting

          Otherwise, if settings are failing to apply you should be getting something in the “Citrix WEM Agent Init” or “Citrix WEM Agent” log files under %UserProfile%.

          Reply
  • Alejandro V.

    February 8, 2018

    George,

    I just applied the script to my Terminal Server that is running Windows Server 2016. However, after the reboot, I was no longer able to RDP to it. I had to restart the RDS service. I restarted the server again and the same issue. Do you know what might be the issue?

    Reply
    • George Spiers

      February 9, 2018

      What Hypervisor are you running on?

      Reply
  • Gwyn Llewelyn

    February 12, 2018

    Hi George, thanks for your time on this script. I came across it whilst trying to troubleshoot slow logon times for my 2016 XenApp server PVS vDisk. Could you send the spreadsheet for further info? Thanks.

    Reply
    • George Spiers

      February 12, 2018

      Sent.

      Reply
  • David M.

    February 12, 2018

    Great Script. Could you send me a copy of the Spreadsheet as well.

    Thanks

    Reply
    • George Spiers

      February 12, 2018

      Yes sent.

      Reply
  • nhr

    February 13, 2018

    Awsome info. Please George, could u send me spreadsheet info copy? thanks in advanced

    Reply
    • George Spiers

      February 13, 2018

      Sent.

      Reply
  • Morten

    February 14, 2018

    I too really like a copy of the Excel sheet, please.. 🙂

    Morten T

    Reply
    • George Spiers

      February 14, 2018

      Sent.

      Reply
      • Anonymous

        February 15, 2018

        Thanx! 🙂

        Reply
  • Bastuaab

    February 15, 2018

    I also would like to receive a copy of the excel sheet. Thnx

    Reply
    • George Spiers

      February 15, 2018

      Sent.

      Reply
      • Paul

        February 20, 2018

        This looks fantastic, can I get a copy of the spreadsheet please?

        Reply
        • George Spiers

          February 22, 2018

          Hi I’ve sent the document across.

          Reply

Leave a Reply