Add Resource Calendar Room List
Hi all!
I have been on the lookout for a PowerShell script or something that can help in adding resources (meeting rooms from Exchange) to clients Outlook.
The idea is that via PowerShell or whatever works run the file on their clients so in Outlook it adds resource rooms into running Outlooks calendar on users clients.
I have had some luck in finding this code below: BUT it does not add all the rooms stated as strName (it just adds 3). Overall I am not happy about the idea of hijacking the Outlook process. I know that we love full contact IT but this time it is not what I am going for.
Can this be remade to a PowerShell?
-------------------------------------------------------------------------------------------------------------------------------
Dim objApp
Dim objNS
Dim objFolder
Dim strName(5) 'Array size
Dim objDummy
Dim objRecip
Dim calendar
'Names for resource accounts (alias)
strName(0) = "1"
strName(1) = "2"
strName(2) = "K"
strName(3) = "L"
strName(4) = "S"
strName(5) = "T"
Const olMailItem = 0
Const olFolderCalendar = 9
'This section will start outlook.exe - wait 9 seconds - Changes the Focus to Outlook - Wait another second
'then add calendars
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "outlook"
WScript.Sleep 9000
WshShell.AppActivate "Outlook"
WScript.Sleep 1000
'For Each Next Loop while adds each calendar from strName(array) to the users Shared Calendars
For Each calendar In strName
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = Nothing
Set objDummy = objApp.CreateItem(olMailItem)
Set objRecip = objDummy.Recipients.Add(calendar)
objRecip.Resolve
If objRecip.Resolved = True Then
On Error Resume Next
Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar)
On Error GoTo 0
Else
MsgBox "Could not find ", , _
"User not found"
End If
Next
Set GetOtherUserCalendar = objFolder
Set objApp = Nothing
Set objNS = Nothing
Set objFolder = Nothing
Please sign in to leave a comment.
Comments
1 comment