locked
Powershell running slowly on Win2019 compared to Win2016 RRS feed

  • Question

  • Hi All, 

    I have an issue where a script i have made takes about 10x longer to execute on windows 2019 than on a windows 2016 machine. 

    Both machines are virtual and identically placed on the same host with the same configuration of ram,cpu,storage etc. 

    Powershell version on 2019: 

    5.1.17763.316 

    Powershell version on 2016:

    5.1.14393.2791 

    This is what the script looks like, i have shortened it a bit to give this example. 

    $UserFile = Import-Csv -delimiter "," -Path "C:\temp\UserFile.txt" -Encoding Default `
    
    foreach ($User in $UserFile){
    
        $SSN = $user.SocialSecurityNumber
        $Samaccountname = $User.UserID
        $UserFirstname = $User.Firstname
        $UserLastname = $User.Lastname
        $Titel = $User.Title
        $ManagerSocialSecurityNumber = $user.Manager.substring(2)
        $ManagerSamaccountname = ($UserFile | Where-Object {($_.SocialSecurityNumber -eq $Manager)} | Select UserID).UserID
    
        }


    I am importing a file with data every night which will enter the data in our AD. 

    The file in question does not contain any information about the managers UserID in AD, so i am mapping the managers userID with this line here: 

    $ManagerSamaccountname = ($UserFile | Where-Object {($_.SocialSecurityNumber -eq $Manager)} | Select UserID).UserID

    Identical script running on Win2016 using Measure-command: 

    Minutes           : 0
    Seconds           : 12
    Milliseconds      : 786

    Same script running on Win2019 using Measure-Command

    Minutes           : 2
    Seconds           : 24
    Milliseconds      : 121

    Win2019 version: 

    1809 (OS Build 17763.316)

    Win2016 version: 

    1607 (OS Build 14393.2791)

    Does anyone know if there are some known bugs in powershell for Win2019 causing this issue? 

    Or is this just some issue local to myself? 

    Best regards

    Joakim


    • Edited by Joakim201 Wednesday, February 20, 2019 11:24 AM adding windows version
    Wednesday, February 20, 2019 11:22 AM

All replies

  • It is not an issue.  Different host will have differing performance due to hardware, configuration and load.  There is no way to compare this.


    \_(ツ)_/

    Wednesday, February 20, 2019 7:05 PM
  • Hi, 

    That's the strange part. 

    The virtual machines are placed on the same host. The host has virtually no load 5-8% load on CPU (2x8core xeon e5-2690) and 48GB Ram available. Both VHDX are stored on the same NAS cluster

    Both machines are newly installed about a week ago. 

    I have ran the tests multiple times at different times during the day - same issue. 

    I will try reinstalling the Win2019 and see what happens. 

    Best Regards

    Thursday, February 21, 2019 9:16 AM
  • I am seeing a similar issue with a Powershell script that is importing data from multiple CSV files and building out a table. I was running on Win10 for development and then we put it on a 2019 VM with similar resources and it runs 10x slower.
    Friday, February 14, 2020 3:25 PM
  • For 5.1, I believe you could report this "bug" here:

    https://windowsserver.uservoice.com/forums/301869-powershell

    You may want to try this in PS6 though.

    Saturday, February 15, 2020 6:34 PM