Favorite PowerShell Commands?
-
Good reference! Thanks!
-
I don't think I'll ever get to the stage where I write my own Powershell scripts from scratch. Mostly, I just cut and paste commands that people have posted on the internet.
I use it for Exchange a bit. For example, the last command I ran was
Get-ADGroupMember “Remote Users” | %($name) {Get-Mailbox $_.name | set-casmailbox –owaenabled:$true –activesyncenabled:$true}I couldn't write that myself, I must have nicked it from somewhere.
-
I love using Select-String. Nothing quite as cool as taking a huge log file, parsing out EXACTLY what you want out of it and making a custom object. Version 5 of PowerShell now has the ConvertFrom-String cmdlet that'll make doing this much easier than using RegEx. But where's the challenge?!?!
-
@Carnival-Boy said:
I don't think I'll ever get to the stage where I write my own Powershell scripts from scratch. Mostly, I just cut and paste commands that people have posted on the internet.
I use it for Exchange a bit. For example, the last command I ran was
Get-ADGroupMember “Remote Users” | %($name) {Get-Mailbox $_.name | set-casmailbox –owaenabled:$true –activesyncenabled:$true}I couldn't write that myself, I must have nicked it from somewhere.
I'm sort of the same way. I also type very little. Love Tab completion with Intellisense!
-
C'mon! Send-MailMessage for the win. Just the fact that it took so much coding in VBScript in comparison to do this very thing. Very useful to pop at the end of a script designed to gather some stats or other stuff.
-
Hard to beet old fashioned BASH and mailx...
mail -s "This is the Subject" [email protected] < message.txt
-
@scottalanmiller said:
Hard to beet old fashioned BASH and mailx...
mail -s "This is the Subject" [email protected] < message.txt
what does this do? I assume it sends an email if you're using in house exchange?
-
@Hubtech said:
what does this do? I assume it sends an email if you're using in house exchange?
Sends an email regardless of what you run. No Exchange needed. In Linux, there is an SMTP MTA on every system by default (of course you can opt out of that) so ever server can send emails right out of the box. The only extra package in use here is mailx which is commonly installed because it is so handy. Just do ...
yum -y install mailx
It gives you the handy "mail" command syntax. Otherwise you need to know more complicated syntax and no reason to do that.
-
On my systems it would leverage Postfix, which is what most people run on Linux today. There are many MTA options but Postfix and Sendmail are the leaders that own, I would guess, over 99% of the single server market.
-
I'll vote for Postfix on Linux too. Great email handler. But I think that we've diverged from the point of the thread considerably.
-
This is one script we did when me and James used to work together at the town. It was mainly to make sure users where restarting to get updates from WSUS as well as new GPOs that needed restarts. We were tempted to take the okay button away after 14 days and make it only a Restart now but that got shot down of course.
http://community.spiceworks.com/scripts/show/1478-uptime-notification