Earlier quoted context omitted.
As a Unix person, 'Restart-Service' seems a lot easier to remember than 'systemctl'. Edit: Restart-Service is also easier to remember than /etc/init.d was. Edit 2 (rate limit): `service` on RHEL is great, but it's a Red Hat-ism. Which is fine, I used to work at Red Hat, but still. It's also pretty limited: you use service to start/stop/restart, but you still use systemctl to list services, or list /etc/init.d (techni…
Regarding your edit: service works just fine on ubuntu as well
In defense of PowerShell
71–80 of 82 posts
Re: In defense of PowerShell
#72The tab completion in powershell is frustrating to me. I never want to cycle through every available option (especially when many PSH commands have literally hundreds of switches). I want the tab-completion to only show options for which I've started typing the prefix. I want double-tab to print a listing of said options so that I can see them all at once. Is this possible? Right now it feels like there's a major lac…
Re: In defense of PowerShell
#73I dislike windows (and by extension, powershell) because a solution such as changing the port the webserver runs on looks something like: New-ItemProperty IIS:\sites\DemoSite -name bindings -value @{protocol="http";bindingInformation=":8081:"} http://www.iis.net/learn/manage/powershell/powershell-snap-i... What did I just modify? Is it persisted to the hard disk? How do i back that up? How do I revert the change? How…
So how would you accomplish the same task on Linux using bash? What script would you write to set the web server's port to 1234?
What these generally do is parse the entire configuration file into an abstract syntax tree, apply the modifications you have asked for to the tree, then serialize the result back into the configuration file format. This ensures that the input and the output are both at least syntactically valid; as a result it is less error-prone than sed/awk. Unlike with configuration file templates (e.g., Ansible's Jinja2 templates) the changes can be applied on top of the distribution's default configuration if desirable and reapplied when that default configuration is updated.
Re: In defense of PowerShell
#74The tab completion in powershell is frustrating to me. I never want to cycle through every available option (especially when many PSH commands have literally hundreds of switches). I want the tab-completion to only show options for which I've started typing the prefix. I want double-tab to print a listing of said options so that I can see them all at once. Is this possible? Right now it feels like there's a major lac…
In PowerShell 5 (at least in Windows 10), Ctrl-Space yields a list of matching completions. You can then use the arrow keys (ip, down, left, right) to pick one and hit enter or space to select.
It works for commands as well as for options/parameters and parameter values.
I.e. you can type get-pr[ctrl-space] and powershell responds with:
Get-PrintConfiguration Get-PrinterDriver Get-PrinterProperty Get-Process
Get-Printer Get-PrinterPort Get-PrintJob Get-ProvisionedAppxPackage
Choose Get-Process (right,right,right,space). Now the cmdline shows Get-Process _
Hit [-][ctrl-space]. Powershell now shows: PS C:\Users\zaphod> Get-Process -Name
Name IncludeUserName FileVersionInfo ErrorAction ErrorVariable OutVariable
Id ComputerName Verbose WarningAction WarningVariable OutBuffer
InputObject Module Debug InformationAction InformationVariable PipelineVariable
Pick "Name" and hit space: PS C:\Users\zaphod> Get-Process -Name _
Now hit [ctrl-space] again. PowerShell now completes on running processes on the system, offering the list of all of the process names.Re: In defense of PowerShell
#75The tab completion in powershell is frustrating to me. I never want to cycle through every available option (especially when many PSH commands have literally hundreds of switches). I want the tab-completion to only show options for which I've started typing the prefix. I want double-tab to print a listing of said options so that I can see them all at once. Is this possible? Right now it feels like there's a major lac…
The usual PowerShell guru's response to your complaint is 'This is what PowerShell ISE is for'. Personally I don't think this is elegant, but that's what I usually encounter in the wild.
Re: In defense of PowerShell
#76I started reading this article not knowing anything about powershell, and finished horrified by the issues he tried to dispel in it. No remoting, no scripting? Are they serious?
Get-Help about_Execution_Policies # Tells you everything you need to know about
So the first thing I typically do in PowerShell in user accounts I control is:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
After that I can run all the scripts I want to run. (From there it's a quick jump over to Chocolatey for application installs and PsGet for useful PowerShell scripts like PoshGit that adds your friendly Git branch info to the PowerShell prompt.)
Re: In defense of PowerShell
#77I work primarily in a Microsoft environment, although I have Linux shell experience as well, and I totally don't get Powershell. What is a cmdlet? Why does it need a stupid made-up name like that? Why are all the commands incredibly verbose and hard to remember? I avoid using it at every opportunity.
A cmdlet is a PowerShell native command. It reads and writes objects, where as Unix commands read and write plain text. Try this in PowerShell: get-command get-command | where CommandType -eq "alias" Notice the lack of parsing. In Unix you'd typically do this kind of thing with grep, but then you'd have to watch out that you don't accidently include the wrong rows because some other column happened to contain the str…
Re: In defense of PowerShell
#78I dislike windows (and by extension, powershell) because a solution such as changing the port the webserver runs on looks something like: New-ItemProperty IIS:\sites\DemoSite -name bindings -value @{protocol="http";bindingInformation=":8081:"} http://www.iis.net/learn/manage/powershell/powershell-snap-i... What did I just modify? Is it persisted to the hard disk? How do i back that up? How do I revert the change? How…
Why the colons surrounding the port !?
IP Address:Port:Virtual Host
For example: 172.16.1.1:80:www.example.com
The raw values reside in an XML config file called "applicationHost.config" which replaces the old school and rather opaque IIS6 metabase.Admittedly that example is a bit old school, there's better commandlets available now that wrap having to manipulate these string values directly. e.g. the New-WebBinding and Set-WebBinding examples shown in sibling comments in this sub-thread.
A site config looks like:
None of this is particularly mysterious, and the documentation is pretty good.Re: In defense of PowerShell
#79Re: In defense of PowerShell
#80Earlier quoted context omitted.
Or /etc/rc.d/apache2 restart, as one would find in the BSD world (and Slackware, with a bit of modification). This isn't to mention that it should be relatively trivial to map "restart-service $foo" to "/etc/rc.d/$foo restart" or "systemctl $foo.service restart" or whatever if one so chooses.
FreeBSD uses the service command these days too.