SOLVED

Create meeting Using PowerShell, Graph API and CSV File

%3CLINGO-SUB%20id%3D%22lingo-sub-1595300%22%20slang%3D%22en-US%22%3ECreate%20meeting%20Using%20PowerShell%2C%20Graph%20API%20and%20CSV%20File%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1595300%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EI%20have%20successfully%20created%20the%20teams%20meeting%20using%20Graph%20API%20and%20PowerShell.%20Now%20i%20wan%20to%20import%20a%20csv%20and%20want%20to%20create%20meeting%20using%20that%20csv%20file.%20There%20are%20two%20columns%20in%20csv%20DisplayName%20and%20UPN.%20Can%20anyone%20please%20help%20me%20with%20this%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CSPAN%3EImport-Csv%20-Path%20%22C%3A%5CUsers%5CAwais%5COneDrive%20-%20CS%5CDesktop%5CGraphAPI.csv%22%20%7C%20foreach%20%7B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%24apiUrl%20%3D%20%22%3CA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fme%2Fevents%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fme%2Fevents%3C%2FA%3E%22%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%24bodyy%20%3D%20%40'%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22subject%22%3A%20%22Let's%20go%20for%20lunch%22%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22body%22%3A%20%7B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22contentType%22%3A%20%22HTML%22%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22content%22%3A%20%22Does%20noon%20work%20for%20you%3F%22%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%7D%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22start%22%3A%20%7B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22dateTime%22%3A%26nbsp%3B%3CSTRONG%3E%24_.StartTime%3C%2FSTRONG%3E%2C%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E%23%3C%2FSTRONG%3E%3CSPAN%3EWant%20to%20use%20csv%20data%20here%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22timeZone%22%3A%20%22Pakistan%20Standard%20Time%22%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%7D%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22end%22%3A%20%7B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22dateTime%22%3A%26nbsp%3B%3CSTRONG%3E%24_.EndTime%3C%2FSTRONG%3E%2C%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E%23%3C%2FSTRONG%3E%3CSPAN%3EWant%20to%20use%20csv%20data%20here%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22timeZone%22%3A%20%22Pakistan%20Standard%20Time%22%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%7D%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22location%22%3A%7B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22displayName%22%3A%3C%2FSPAN%3E%3CSTRONG%3E%24_.DisplayName%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%23%3C%2FSTRONG%3E%3CSPAN%3EWant%20to%20use%20csv%20data%20here%26nbsp%3B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%7D%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22attendees%22%3A%20%5B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22emailAddress%22%3A%20%7B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22address%22%3A%3C%2FSPAN%3E%3CSTRONG%3E%24_.UPN%3C%2FSTRONG%3E%3CSPAN%3E%2C%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E%23%3C%2FSTRONG%3E%3CSPAN%3EWant%20to%20use%20csv%20data%20here%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22name%22%3A%20%22Awais%20Khalid%22%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%26nbsp%3B%7D%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%22type%22%3A%20%22required%22%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%26nbsp%3B%7D%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%26nbsp%3B%5D%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%26nbsp%3B%22allowNewTimeProposals%22%3A%20true%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%26nbsp%3B%22isOnlineMeeting%22%3A%20true%2C%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%26nbsp%3B%22onlineMeetingProvider%22%3A%20%22teamsForBusiness%22%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%26nbsp%3B%7D%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%26nbsp%3B'%40%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%3E%24DataPOST%20%3D%20Invoke-RestMethod%20-Headers%20%40%7BAuthorization%20%3D%20%22Bearer%20%24(%24Tokenresponse.access_token)%22%7D%20-Uri%20%24apiUrl%20-Method%20POST%20-Body%20%24bodyy%20-ContentType%20'application%2Fjson'%7D%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1595300%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAPI%20Management%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1595592%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20meeting%20Using%20PowerShell%2C%20Graph%20API%20and%20CSV%20File%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1595592%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F279761%22%20target%3D%22_blank%22%3E%40AwaisKhalid%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETry%20to%20use%20this%20body%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%24bodyy%20%3D%20%40%22%0A%7B%0A%22subject%22%3A%20%22Let's%20go%20for%20lunch%22%2C%0A%22body%22%3A%20%7B%0A%22contentType%22%3A%20%22HTML%22%2C%0A%22content%22%3A%20%22Does%20noon%20work%20for%20you%3F%22%0A%7D%2C%0A%22start%22%3A%20%7B%0A%22dateTime%22%3A%20%24(%24_.StartTime)%2C%0A%22timeZone%22%3A%20%22Pakistan%20Standard%20Time%22%0A%7D%2C%0A%22end%22%3A%20%7B%0A%22dateTime%22%3A%20%24(%24_.EndTime)%2C%0A%22timeZone%22%3A%20%22Pakistan%20Standard%20Time%22%0A%7D%2C%0A%22location%22%3A%7B%0A%22displayName%22%3A%24(%24_.DisplayName)%0A%7D%2C%0A%22attendees%22%3A%20%5B%0A%7B%0A%22emailAddress%22%3A%20%7B%0A%22address%22%3A%24(%24_.UPN)%2C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23Want%20to%20use%20csv%20data%20here%0A%22name%22%3A%20%22Awais%20Khalid%22%0A%20%7D%2C%0A%22type%22%3A%20%22required%22%0A%20%7D%0A%20%5D%2C%0A%20%22allowNewTimeProposals%22%3A%20true%2C%0A%20%22isOnlineMeeting%22%3A%20true%2C%0A%20%22onlineMeetingProvider%22%3A%20%22teamsForBusiness%22%0A%20%7D%0A%22%40%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EManfred%20de%20Laat%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1595607%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20meeting%20Using%20PowerShell%2C%20Graph%20API%20and%20CSV%20File%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1595607%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20You%20so%20much%2C%20That%20worked.%3CBR%20%2F%3EKind%20Regards%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F412431%22%20target%3D%22_blank%22%3E%40Manfred101%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

I have successfully created the teams meeting using Graph API and PowerShell. Now i wan to import a csv and want to create meeting using that csv file. There are two columns in csv DisplayName and UPN. Can anyone please help me with this


Import-Csv -Path "C:\Users\Awais\OneDrive - CS\Desktop\GraphAPI.csv" | foreach {
$apiUrl = "https://graph.microsoft.com/v1.0/me/events"
$bodyy = @'
{
"subject": "Let's go for lunch",
"body": {
"contentType": "HTML",
"content": "Does noon work for you?"
},
"start": {
"dateTime": $_.StartTime,                                #Want to use csv data here
"timeZone": "Pakistan Standard Time"
},
"end": {
"dateTime": $_.EndTime,                                    #Want to use csv data here
"timeZone": "Pakistan Standard Time"
},
"location":{
"displayName":$_.DisplayName                      #Want to use csv data here 
},
"attendees": [
{
"emailAddress": {
"address":$_.UPN,                                            #Want to use csv data here
"name": "Awais Khalid"
 },
"type": "required"
 }
 ],
 "allowNewTimeProposals": true,
 "isOnlineMeeting": true,
 "onlineMeetingProvider": "teamsForBusiness"
 }
 '@

$DataPOST = Invoke-RestMethod -Headers @{Authorization = "Bearer $($Tokenresponse.access_token)"} -Uri $apiUrl -Method POST -Body $bodyy -ContentType 'application/json'}
}

2 Replies
Highlighted
Best Response confirmed by AwaisKhalid (New Contributor)
Solution

@AwaisKhalid 

Try to use this body:

 

$bodyy = @"
{
"subject": "Let's go for lunch",
"body": {
"contentType": "HTML",
"content": "Does noon work for you?"
},
"start": {
"dateTime": $($_.StartTime),
"timeZone": "Pakistan Standard Time"
},
"end": {
"dateTime": $($_.EndTime),
"timeZone": "Pakistan Standard Time"
},
"location":{
"displayName":$($_.DisplayName)
},
"attendees": [
{
"emailAddress": {
"address":$($_.UPN),                                            #Want to use csv data here
"name": "Awais Khalid"
 },
"type": "required"
 }
 ],
 "allowNewTimeProposals": true,
 "isOnlineMeeting": true,
 "onlineMeetingProvider": "teamsForBusiness"
 }
"@

 

Manfred de Laat

Highlighted

Thank You so much, That worked.
Kind Regards
@Manfred101