On a domain? You can do something to all machines on a domain with this quick little script here. Your best bet is to open up an elevated (admin) Powershell Prompt on a domain controller and then run that here: Get-ADComputer –filter * | foreach { < do the thing > } Here are some examples that have really helped me in my administrative journeys: Force GPUpdate for all machines on the domain: Get-ADComputer –filter * | foreach { Invoke-GPUpdate –computer $_.name -force } Force … [Read more...] about The “do something to all machines” PowerShell Script
Scripting
Powershell script won’t run portion requiring Excel in Scheduled Task
Some of the scripting I've recently done requires Excel to be launched (non interactively) on a domain controller to gather usernames and whatnot. For some reason, the entire script would work perfectly besides the portion that requires Excel. I could run the script as an admin in ISE and it would work, but not via the Task Scheduler. Here's the fix: Create these two folders on your server: C:\Windows\System32\config\systemprofile\Desktop … [Read more...] about Powershell script won’t run portion requiring Excel in Scheduled Task
Exchange: Export a list of all public facing distribution groups
Public facing isn't the right term here. It simply means that the authentication requirement to send mail to the distro has been disabled to give anyone anywhere the ability to send an email to it. That makes it publicly accessible. If you want a list of all of the distribution groups that have the authentication requirement disabled you can use this little one-liner. Open Exchange Management Shell as an Administrator and type the following: Get-DistributionGroup | ? … [Read more...] about Exchange: Export a list of all public facing distribution groups
Use PowerShell to list your folders on a server or share
Here's a quick script to list all of the folders on a share or on a server. This script will use PowerShell to export a list of folders to a CSV file. We'll be using the Get-ChildItem cmdlet to accomplish this. Get-ChildItem \\FS01\Shared -Recurse -Name -Directory | Out-File "C:\misc\Folders.csv" Let's break this down: Get-ChildItem is the cmdlet. It is just like "dir" or "ls" where it's main job is to tell you the contents of a folder. You can learn more about Get-ChildItem … [Read more...] about Use PowerShell to list your folders on a server or share
Log on as Batch Job Rights for Task Scheduler
Scenario: You just created a scheduled task that needs to be run even when nobody is logged on. You have a service account to mange the job and it will run with the highest privileges. Unfortunately, you run the task and nothing happens when the task is triggered. Solution: This could be the result of many things, but there's a good chance the service account you chose doesn't have "Log on as Batch Job" rights in the local security policy of the server. Here's how to enable that: Go to … [Read more...] about Log on as Batch Job Rights for Task Scheduler
PowerShell – Export Enabled Users and other Data from Active Directory
I made a script that does a few things: Gets all users that are enabled Creates a table, listing all the the users with a few account details I want Export the table to a .csv file with a unique name, appending the date the export happens Here's the whole thing. I'll explain what it does at the bottom: Import-Module ActiveDirectory # All of the properties you'd like to pull from Get-ADUser $properties=@( 'displayname', 'lastlogondate', 'passwordneverexpires', … [Read more...] about PowerShell – Export Enabled Users and other Data from Active Directory
Recent Activity