Linked Questions
27 questions linked to/from Is there a way to create an alias to a cmdlet in a way that it only runs if arguments are passed to the alias?
3 votes
0 answers
2k views
Powershell Set-Alias for long command [duplicate]
I'm trying to create a powershell alias for my ng build command which is fairly long. node --max_old_space_size=4096 .\node_modules\@angular\cli\bin\ng build --configuration=debug --watch Aliasing the ...
1 vote
0 answers
2k views
make new-alias run a specific python file [duplicate]
I have a python program that creates a numbered list up to the value i enter I have tried using new-alias numberlist "python C:\path\to\file\numberlist.py" to do this but it returns the ...
410 votes
22 answers
482k views
Using PowerShell to write a file in UTF-8 without the BOM
Out-File seems to force the BOM when using UTF-8: $MyFile = Get-Content $MyPath $MyFile | Out-File -Encoding "UTF8" $MyPath How can I write a file in UTF-8 with no BOM using PowerShell? ...
55 votes
10 answers
46k views
Pass function as a parameter
I've written function 'A' that will call one of a number of other functions. To save re-writing function 'A', I'd like to pass the function to be called as a parameter of function 'A'. For example: ...
17 votes
1 answer
14k views
PowerShell pass all parameters received in function, and handle parameters with spaces
I am a novice with PowerShell. In Msys2 (or Lnux), I have defined a function npp npp () { ${NPP_PATH} "$@" } such that if I call from the command prompt npp it launches Notepad++ (as ...
17 votes
1 answer
68k views
Powershell's equivalent to Linux/Unix 'ls -al'
Is there a PowerShell equivalent to the ls -al command in Linux/Unix? I tried to find something, but it said there wasn't an equivalent command in PowerShell.
9 votes
3 answers
2k views
How to use a function to get objects from a pipeline as strings?
Command that output the result in string instead of objects: ls | Out-String -Stream Output: Directory: C:\MyPath\dir1 Mode LastWriteTime Length Name ---- ...
4 votes
2 answers
3k views
Can you redirect Tee-Object to standard out?
I am writing a script and I want to pass the values but also see them displayed Get-Content data.txt | Tee-Object | data_processor.exe But Tee-Object always requests a file and I just want to see it ...
7 votes
1 answer
4k views
Powershell: What's the difference between Alias and Function?
Im setting up my powershell profile to create aliases of commonly used commands. On Microsoft's documentation it says, if I want to make an alias for a command with parameters, I should make the value ...
5 votes
3 answers
2k views
PowerShell Transcript is not capturing git output
I'm writing a script that will perform some git actions and I want to use Start-Transcript to monitor it. The transcript is however missing most of the git output. I've tried to pipe the git output ...
-4 votes
1 answer
6k views
Remove blank lines in powershell output... Generally
I am a newcomer to PS scripting. I have found that, generally speaking, PS adds a lot of newlines to output of its commands. I am giving below a couple of examples of what I found somewhat generalized ...
5 votes
2 answers
2k views
How to achieve @args splatting in an advanced function in Powershell?
Consider the following simple function: function Write-HostIfNotVerbose() { if ($VerbosePreference -eq 'SilentlyContinue') { Write-Host @args } } And it works fine: Now I want to ...
2 votes
1 answer
2k views
Add Write-Progress to Get-Job/Wait-Job
I'm using the below code to display the results of PowerShell Jobs with a timeout of 120 seconds. I would like to enhance this code by incorporating Write-Progress (based on number of jobs completed)....
2 votes
1 answer
2k views
What is the simplest way to make Alias in powershell?
I was wondering if there's any simple way to make aliases for powershell like cmd. For example: In cmd, doskey art=php artisan $* where $* is optional. Currently, I'm using the following alias in ...
1 vote
1 answer
1k views
Wrapper function for cmdlet - pass remaining parameters
I'm writing a function that wraps a cmdlet using ValueFromRemainingArguments (as discussed here). The following simple code demonstrates the problem: works function Test-WrapperArgs { Set-...