Comments (4)
Even if it may not show, this is not my first PowerShell rodeo, so I'm aware about the contents of the linked article. I thought about which Write-
to use before. The topic is still open for discussion, but consider these:
- First and foremost, it should be possible to use the script with the least effort possible. Since it's being used by unskilled BFUs for which even right-clicking and selecting Run in PowerShell is a complex task,
Write-Verbose
would either require manually entering the command or using$VerbosePreference = "Continue"
. Moreover all messages are prepended by"VERBOSE: "
string. This may be matter of personal preference, but I personally don't like it. - It should be also possible to use the script as a base for provisioning automation and incorporate the functions into another PS script. Possible candidate would then be
Write-Output
but since the messages are intended to be informational for the user, redirecting such script to a log would eat them too. I'm aware aboutTee-Object
cmdlet but that doesn't help if the whole process output gets redirected. This again is a matter of personal preference, whether to "force" the information to show or whether to leave the decision on the downstream maintainer.
So I needed a Write-
which would not be redirected but at the same time which would be always visible without any extraneous information or setting. Hence I got stuck with Write-Host
.
What would your preference be and why?
from win10-initial-setup-script.
My apologies, I never meant to call into question your Powershell knowledge - you clearly know your stuff!
I only decided to bring this up as a best practices type of deal, but it seems you've clearly thought hard about the consequences of each possibility. From your explanations, I'd tend to agree with your choice of Write-Host in this case, although I've only been using Powershell for about 1 year now, so my opinion may not be 100% valid :)
I've switched my copy of the script with Write-Output for my own consistency and fixed the WaitForKey issue, but for complete novice users, Write-Host will do the trick just fine.
Thank you for keeping this up to date and writing it in the first place - it's incredibly useful!
from win10-initial-setup-script.
Just to chime in, I replaced all the Write stuff with Write-Output and it breaks the script, it just keeps asking for parameters now. Clearly it isn't just a case of find-replace.
from win10-initial-setup-script.
Just to chime in, I replaced all the Write stuff with Write-Output and it breaks the script, it just keeps asking for parameters now. Clearly it isn't just a case of find-replace.
That's just the Write-Host
without parameter in WaitForKey
function. It can't handle colors either. Can be replaced with
Function WaitForKey {
Write-Output "`nPress any key to continue..."
[Console]::ReadKey($true) | Out-Null
}
(Although this particular function won't be used in automation anyway due to the key press)
from win10-initial-setup-script.
Related Issues (20)
- What are "ModernUI applications" - or how do I recognize them? HOT 5
- Transparency not being disabled on 2004 HOT 2
- Request: Disable/Enable Print Spooler Serivce. HOT 1
- Windows Defender Attack Surface Reduction Rules (ASR) HOT 1
- Wi-Fi Sense is no longer available HOT 2
- Disassembler intermintently stops when running through selected items in .preset file
- Disable Domain Firewall HOT 1
- How to find "Quick acces" and classical incon on taskbar HOT 1
- EnableActionCenter not work after DisableActionCenter HOT 3
- Open command window here
- PowerShell and ampersand issues HOT 1
- Add command option to read current settings and output as preset file
- Add short description column to the preset file
- NumLock
- Add Disable Caps Lock HOT 1
- DisableF1HelpKey completely disables F1 and F2 keys HOT 1
- How to undo these changes? HOT 3
- Consider putting all MsftBloat in separate script file HOT 1
- Administrative shares not working
- Remove photos viewer from msft bloat
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from win10-initial-setup-script.