Folks,
Thanks for coming out last night and listening to me talk about PowerShell. As I thought about the presentation I gave last night I wondered…“Do I really want to be a developer?” The answer is no I believe but I think I could be a full time PowerShell scripter and enjoy it. Now if I could just incorporate PowerShell into my BBQ I’d be like a pig in sh*t.
Meanwhile are the links I promised:
Spiceworks PowerShell Group
Spiceworks Scrip Center
Microsoft Script Resources
Martin9700’s AD Password Expiration Script
And here’s a couple of really useful lines of code:
This gets all of the servers in your AD environment.
Get-ADComputer -Filter * -Properties operatingsystem | Where operatingsystem -match 'server'
This is where things can go wrong if you’re not careful. Using the line above (which is one of many ways to get the same info by the way) you can pipe that to a command that performs an action
#This is a variable. It holds the list of AD objects that are computers running a server OS
$servers = Get-ADComputer -Filter * -Properties operatingsystem | Where operatingsystem -match 'server'
#This was my biggest learning curve
#The Foreach loop does exactly what it says. For each hit in the variable above run the invoke-gpudate command
Foreach ($Server in $servers)
{Write-Host "Forcing GPUpdate on $Server"
Invoke-GPUpdate -Computer $Server -Force
Write-Host "$Server Group Policy Updated"}
With that little bit of code you can go a long way. I’m happy to help with any questions you have and if you’d like me to share a script I’d be happy to. I’ll need time to scrub them for company info as I’m sure you’ll understand.
Thanks again all for coming last night. This is a great group Marty has put together.
4 Spice ups
kevinmann
(Kevin Mann)
2
Thanks for all of the great info Mike!