Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Monday, September 25, 2023

Bulk add members in to MS Teams

 MS teams natively does not allow to bulk add members to new or existing teams. The process to add members one by one is pretty troublesome if you need to add 100+ members in one go. Powershell comes to you help in such a scenario.

First install the Microsoft Teams module in Powershell:

Install-Module -Name MicrosoftTeams

In case, its already installed but is of an older version, try to update it using:

Install-Module -Force -Name MicrosoftTeams

Once done, create a simple csv file with 2 columns : Email, Role and fill it up.

Next we need the group Id of the Team to which you want to add the members to. Yes there is powershell command for it as well but it was pretty slow specially when you member of 100's of Teams !!

Simple way was to pull it from the browser window. Just open Teams on the browser window and select the target Team, and look for the param groupId in the url:



Once done, just execute the below script:

#Get users from the CSV

$TeamUsers = Import-Csv -Path "<file_path>"

$TeamID = "<Team_Id / groupId>"

 

#Iterate through each user from the CSV and add to Teams

$TeamUsers | ForEach-Object {

       Add-TeamUser -GroupId $TeamID -User $_.Email -Role $_.Role

       Write-host "Added User:"$_.Email -f Green

}

You should see members getting added one by one:




Monday, January 19, 2009

SQL Server 2005: Change schema for Tables and SPs

SQL Server 2005 copied the schema concept from Oracle. Earlier the user and schema used to be same for SQL 2000 but from 2005, these are two different things.
Now when we migrate a SQL 2000 DB to SQL 2005 server, we face a problem. We find that the objects i.e. Tables and Schemas are owned by the user and not [dbo].
So now to make [dbo] (or some other schema own it) execute the following scripts:

Table
SELECT 'ALTER SCHEMA NewSchema TRANSFER ' + TABLE_SCHEMA + '.' + TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'OldSchema'

SP
SELECT 'ALTER SCHEMA NewSchema TRANSFER ' + s.Name + '.' + p.Name FROM sys.Procedures p INNER JOIN
sys.Schemas s on p.schema_id = s.schema_id WHERE s.Name = 'OldSchema'

Thursday, December 6, 2007

Setting $DISPLAY in bash and csh

For Bash, open the .bashrc file in you home directory in you favorite editor vi and append the following script at the end of it:

#
# Set the DISPLAY
#
if [ x"$DISPLAY" = x ]
then
TTYPORT=`tty`
if [ "$TTYPORT" = "/dev/console" ]
then
DISPLAY="localhost:0"
elif [ "$REMOTEHOST" = "" ]
then
TTYNAME=`echo $TTYPORT | cut -c6-`
REMOTEHOST=`who|grep "$TTYNAME"|awk '{print $5}'|sed 's/(//'|sed 's/)//'`
DISPLAY="${REMOTEHOST}:0"
else
DISPLAY="${REMOTEHOST}:0"
fi
fi


For Csh, open the .cshrc file in you home directory in you favorite editor vi and append the following script at the end of it:

#
# Set DISPLAY
#
if ( ! $?DISPLAY ) then
set TTYPORT=`tty`
if ( $TTYPORT == /dev/console ) then
setenv DISPLAY "localhost:0"
else if ( $?REMOTEHOST ) then
setenv DISPLAY "${REMOTEHOST}:0"
else
set TTYNAME=`echo $TTYPORT |cut -c6-`
set REMOTEHOST=`who|grep "$TTYNAME"|awk '{print $6}'|sed 's/(//'
|sed 's/)//'`
setenv DISPLAY "${REMOTEHOST}:0"
endif
endif

Note: The csh script is tested on Sun Solaris and the bash script is tested on Ubuntu and Fedora so is expected to work on other flavors of linux too. If you have a different *Nix system then check the output of 'who' and configure your awk accordingly.