-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows 11 check script - was it written for compatibility with old PS versions? #4
Comments
I did not write anything specifically for an older version, I was really only thinking of Windows 10. It is absolutely possible I am writing something in an outdated way. I am happy to look into correcting it, are there any specific lines or cmdlets, in particular, that strike you as odd? |
To give some specific examples:
This could be done more efficiently in one line as follows:
This just seems unusual in that it is reading in the file line by line. I would have written:
|
I love the first example, that is absolutely a more efficient way to write that. I will work to get the script updated for that. I have found I often lean back on when I was first learning PowerShell and stick with what is familiar to me over what might be best. For the Get-Content vs StreamReader, that is something I learned from Josh King's presentation on scripting for speed. Get-Content does actually read each line individually and is significantly slower than streamreader. In the case of this script the file from running dxdiag is small enough that the difference is probably not noticeable, but I have tried to default to streamreader for those times I do end up working with larger files. This Link will give you a breakdown of how Get-Content operates under the hood: This Link goes into speed testing the different options: |
I got pointed to the Windows 11 check script on here when I was looking for a way to get PDQ Inventory to report on Windows 11 readiness. However I notice some parts of it have been written in what seems like a strange manner compared to Windows PowerShell 5.1 which comes with Windows 10.
I was wondering if this was because the script was written specifically to be compatible with older versions of PowerShell?
The text was updated successfully, but these errors were encountered: