lukesampson / psutils Goto Github PK
View Code? Open in Web Editor NEWCommand line utilities written in Powershell
License: MIT License
Command line utilities written in Powershell
License: MIT License
Mentioned by @guillermooo in ScoopInstaller/Scoop#1
sudo does not prompt for elevation? It simply tells you you have to be an admin.
A unique ID should be used instead of a string here:
https://github.com/lukesampson/psutils/blob/master/ln.ps1#L19
For example, my Windows 8.1's region is set to Germany, UI language to US English, and keyboard layout to Spanish. Chaos naturally ensues at times :)
InvalidOperation: C:\Users\nguyenc\scoop\apps\psutils\current\time.ps1:7
Line |
7 | & $cmd @args
| ~~~~
| The expression after '&' in a pipeline element produced an object that was not
| valid. It must result in a command name, a script block, or a CommandInfo object.
~#@❯ $PSVersionTable
Name Value
PSVersion 7.2.0-preview.6
PSEdition Core
GitCommitId 7.2.0-preview.6
OS Microsoft Windows 10.0.21390
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
I'm not 100% sure if this is an issue with gitignore or my bad powershell skills, but I thought I would just add this here because maybe it's an easy fix.
When I tried using the gitignore
util with the powershell command gitignore python >> .gitignore
the command produced the full python gitignore template but the template didn't seem to be recognised by git. One of the excluded directories in the template is /build
yet whenever I did a git add .
on a fresh repository the /build
directory was always included.
However, if I copied the template from gitignore.io to a new .gitignore
file then there was no issue and the build
folder wasn't staged. So I wonder if this is a text encoding issue, because when I copy and pasted the .gitignore file works but when piped it doesn't. I also noticed that the command line tool on gitignore.io adds -Encoding ascii
to their command
Here are the .gitignore
files that I generated.
not_working.txt
working.txt
It would be nice if we could do something as the following with sudo:
$ iwr -useb examplescript.com | sudo iex
When I start a batch job with sudo, terminating it will cause the shell to hang. It terminates but then the terminal gets all messed up, things are printed in the wrong place, keystrokes don't register anymore.
This happens too if you "sudo pwsh" and terminate a batch job started without sudo.
PowerShell 7.3.3, no profile
When checking a file against a given hash:
shasum 'filename' --check '903b7256397ebf8c9ba566bba2830a531353281a'
nothing happens, not 'true' nor 'false' output.
Not quite sure if it's a bug or just me not using it right.
I don't know what it is, but sudo
hangs on one of my machines. I don't get any info and don't know what else to tell you. Sorry :(
Details
sudo error ---- Using Windows Terminal. Don't show up the UAC dialog
error:
The Win32 internal error "The handle is invalid" 0x6 occurred while getting console output buffer information. Contact Microsoft Customer Suppor
t Services.
To reproduce:
scoop cache rm cowsay
sudo scoop install cowsay --global
Error
Exception calling "SetCursorPosition" with "2" argument(s): "The handle is
invalid.
downloading https://github.com/lukesampson/cowsay-psh/archive/master.zip...done
"
At C:\Users\luke\appdata\local\scoop\apps\scoop\current\lib\install.ps1:70
#...
Exception calling "SetCursorPosition" with "2" argument(s): "The handle is
invalid.
creating shim for cowthink.ps1
"
At C:\Users\luke\appdata\local\scoop\apps\scoop\current\lib\install.ps1:84
cowsay (0.2013.07.19) was installed successfully!
char:2
+ [console]::setcursorposition($left, $top)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
in runat scriptlet:
- $d.tostring("hh:mm")
+$d.tostring("HH:mm")
without this change every tasks scheduled before noon...
Quite bad bug because result echo is printed in correct format!
Maybe it does work in US locales PC {here in EU we have 24h locales time format),
but then powershell is broken (very stupidly).
Error running, for example:
sudo cmd.exe /c mklink flink .\foo.txt
The Win32 internal error "The handle is invalid" 0x6 occurred
while getting console output buffer information. Contact
Microsoft Customer Support Services.
PS> cd C:\Program` Files
PS> sudo Write-Output "aaa" | Out-File a.txt
Out-File: Access to the path 'C:\Program Files\a.txt' is denied.
I also tried
sudo 'Write-Output "aaa" | Out-File a.txt'
and
sudo Write-Output "aaa" > a.txt
and
sudo echo "aaa" > a.txt
but still not work.
Steps to reproduce
Command fails with The Win32 internal error "The handle is invalid" 0x6 occurred while getting console output buffer information. Contact Microsoft Customer Support Services.
Running the same command from: 'native' PowerShell prompt and a cmd hosted in ConEmu works
It seems that the sudo command gets caught by some antivirus programs.
Example from Bitdefender:
PowerShell tried to load a potentially malicious resource and was blocked.Your device is safe.
Do you know of any ways around this? (that isn't to put PowerShell on the exceptions list)
Just to be clear, it works fine so far using windows powershell, but it fails when switching to git bash (which is what i use almost always), and shows this error:
** Presuming my windows username is Lina Lina**
C:\Users\Lina : The term 'C:\Users\Lina' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ CategoryInfo : ObjectNotFound: (C:\Users\Lina:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Sudo uses a fixed entry point for powershell instance: https://github.com/lukesampson/psutils/blob/master/sudo.ps1#L62
Could this be customizable?
sudo
does not work in PowerShell 6.
Reproduce:
sudo echo 1
When I use ln, it creates the symbolic link using an absolute directory instead of relative.
Example:
cd C:\folder
mkdir test
ln -s test test2
dir /AL /S
Output:
04/24/2015 12:57 PM <SYMLINKD> test2 [C:\Folder\test]
sudo Get-VM
doesn't get any response.
Powershell version: 7.0.3
Running Windows Terminal as Administrator will get correct result.
When calling a .NET function, sudo
will incorrectly pass the command to the administrator instance, removing some characters.
PS> sudo [Environment]::SetEnvironmentVariable('Path', $value, 'Machine')
ParserError:
Line |
1 | [Environment]::SetEnvironmentVariable Path, 'C:\Users\bruno\desktop\D …
| ~~~~
| Unexpected token 'Path' in expression or statement.
sudo
removed the parenthesis, as well as the quotes on Path
, causing the command to be syntactically incorrect.
That really kills a console session. You're typing away and have to sudo something
PS> sudo foo
But the UAC dialog appears under your window or on your second monitor, not in focus. So you have to switch ALT+TAB
or use the mouse to focus the window and either click or press ALT+Y
.
Anyway, not sure if there's something you can do about it :)
Please see the following output
$ shasum.cmd -a 256 '.\calibre-portable-installer-2.85.1(1).exe'
You cannot call a method on a null-valued expression.
At C:\Users\talha\scoop\apps\shasum\current\getopt.ps1:28 char:6
+ if($arg.startswith('--')) {
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
shasum: .\calibre-portable-installer-2.85.1: no such file
On the other hand shasum.ps1 works fine.
$ shasum.ps1 -a 256 '.\calibre-portable-installer-2.85.1(1).exe'
2aa21727a54b2081bd96c6961cf91f4f88cf4124f7bcc816c28f836c40d062b8 *.\calibre-portable-installer-2.85.1(1).exe
I have my powershell profile in C:\Users\Username\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1. I added some custom functions and aliases there that need admin privileges which I can access without problems while running powershell as administrator and typing MyFunction
but on non-elevated powershell sudo MyFunction
doesn't even recognize the function name and throws error:
MyFunction : The term 'MyFunction' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ MyFunction
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (MyFunction:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Hi guys. I have this issue: if i start a cmd window using sudo, the history of typed commands is gone. Any way to make it works? Thank you!
try this:
New-Item -ItemType SymbolicLink
see this link: https://technet.microsoft.com/en-us/library/hh849795.aspx?f=255&MSPPError=-2147217396 for more detail.
Trojan:Win32/Ymacco.AA46
I noticed that if one of the $args
is a boolean like $false
it gets converted to a string and causes problems in some cmdlets.
> sudo Disable-NetAdapter -Name "Wi-Fi" -Confirm:$false
Disable-NetAdapter : Cannot convert 'System.String' to the type 'System.Management.Automation.SwitchParameter' required by parameter 'Confirm'.
> sudo powershell
# Disable-NetAdapter -Name "Wi-Fi" -Confirm:$false
# Enable-NetAdapter -Name "Wi-Fi" -Confirm:$false
shasum.cmd script splits file name at spaces. For example
$ shasum.cmd "SlackSetup 64.exe"
shasum: SlackSetup: no such file
shasum: 64.exe: no such file
I installed it via scoop.
$ scoop which shasum.cmd
Not a scoop shim.
C:\Users\talha\scoop\shims\shasum.cmd
When running sudo in PowerShell ISE, I get an error like "Error processing arguments: To open multiple files, provide a single list of individual filenames that are separated by commas." followed by some syntax examples.
No problem running sudo in PowerShell. Have not tested other utils in this repo.
I tried to install the time
package from this repository via the scoop installer
But the installation failed in Windows 11
When i tried to rerun scoop install time
this error was shown:
Most of my scripts calls Set-StrictMode -Version Latest;
initially, and I've noticed that touch fails in this mode:
Set-StrictMode -Version Latest;
touch <file>
The property 'A' cannot be found on this object. Verify that the property exists.
At ...\touch.ps1:45 char:4
+ if($opts.A) {
+ ~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : PropertyNotFoundStrict
This can either be fixed by not accessing hashtable contents as members, but using the indexer, or by calling Set-StrictMode -Off
at the beginning of the file.
Hope you fix this as I love your tools :-) And I'd be happy to make a PR with the change you'd prefer.
Most function did not adopt powershell standard:
If you are willing to change all the these, I can create a pull request to change them.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.