Categories
Scripts

Automatically clean folders in batch (Powershell Scripts)

Categories
Scripts

Read all services and scheduled tasks in your server environment (including Server 2003)

At one point we found out that many system administrators had used their own administrator account for Windows Services and scheduled tasks.
This became a problem only when a few colleagues decided to leave for another company. 

Accounts were turned off and all kinds of services fell out.
Among other things, an SQL server that turned out to run under one of these administrator accounts. 

To know for certain where these accounts were running, I wrote a script that can help with identifying these accounts.
Because scheduled tasks can not be read out with the powershell variant on server 2003, I used a legacy command and changed the layout of the output.
The script asks a number of questions (such as the domain, among other things) on the basis of which two files are generated with all scheduled tasks and services. 

I hope this helps you clean up these scheduled tasks and services. 

Here you can download the script:
https://gallery.technet.microsoft.com/Read-and-Scheduled-tasks-f0621080 

 

 

 

Categories
Scripts

Sync AD Groups with Microsoft Teams (BETA)

Microsoft Teams doesn’t allow you to define a group for membership (dynamically).
When you add an Azure AD group to a Team, all users will be added once.
Once someone is added to that group, it won’t be added to the team automatically.

For this I created this script.
You define an Active Directory group and a Microsoft Team to manage.
All users that are in the AD group, but aren’t in the Team will be added (as a member).
All users that aren’t in the AD group, but are in the Team will be removed from the Team.
Offcourse except owners.
If an owner is in the Team, but isn’t in the AD Group it will generate a warning and continue.

You can find it on Technet Gallery:
https://gallery.technet.microsoft.com/Sync-AD-Group-with-Teams-74598786

Step 1:
Create an Service Account in your Active Directory domain.
This service account needs an UPN suffix with a verified Office 365 domain.

For example: It can be user1@contoso.com, but cannot be user1@contoso.local.
Where contoso.com is added as a verified domain in Office 365.

Sync your Active Directory domain with Azure AD (it normally does every 30 minutes automatically).
Also make sure the Service Account has read-rights in your Active Directory.

Step 2:
Go to Office 365 and add an Office 365 license to the Service Account (with the Teams subscription).

Step 3:
Go to teams.microsoft.com and add the service account as an owner of the Teams you want to manage from AD.

Step 4:
Add the users of the Teams you want to manage to the AD groups you want to sync.

Step 5:
Add AD Groupname and Team name you want to sync to Teams.csv (example csv is in the zip-file), with a comma as a delimiter.
Every line is an Active Directory group and Team that needs to be synced.

WARNING: MAKE SURE YOU ADD ALL MEMBER USERS THAT ARE CURRENTLY IN THE TEAM TO THE RESPECTIVE AD GROUP, ALL MEMBERS THAT ARE IN THE TEAM BUT AREN’T THE AD GROUP ARE REMOVED FROM THE TEAM.
WITH AN EXCEPTION OF OWNERS OFFCOURSE.

Step 6:
Run Powershell as the service user and browse to the location.
run Set-SecureTeamUserInfo.ps1 and type in the credentials of the service account (UserPrincipalName, not SamAccountName).
Credentials are now securely saved in the folder so the script can sign in to Office 365.

Posted in Scripts, Teams