Link to home
Start Free TrialLog in
Avatar of GAC 2018
GAC 2018

asked on

Powershell to Set-CalendarProcessing

Hi all!

I have a list of 65 user names that I need to add to the Resource In-Policy Requests tab in Exchange for 15 different Conference Rooms.
I have all the user names in a csv called USERS.csv under the heading ALIAS
What I would like to do is user Exchange Powershell to call the CSV and add the permissions

I tried this: Set-CalendarProcessing "NAME OF CONFERENCE ROOM" -BookinPolicy "Username1","Username2","Username3","Username4","Username5"
It did nothing, no error no result!

Can I do something similar to this:  Get-Content c:\users.csv | Set-CalendarProcessing "NAME OF CONFERENCE ROOM" -BookinPolicy  ??
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

import-csv -path c:\users.csv  | % { Set-CalendarProcessing -Identity "NAME OF CONFERENCE ROOM" -AutomateProcessing AutoAccept -BookInPolicy $_.alias -AllBookInPolicy $false }
or as a tool
function Set-MyCalendarProcessing
{
  <#
      .SYNOPSIS
      Describe purpose of "Set-MyCalendarProcessing" in 1-2 sentences.

      .DESCRIPTION
      Add a more complete description of what the function does.

      .PARAMETER InputObject
      Describe parameter -InputObject.

      .EXAMPLE
      Set-MyCalendarProcessing -InputObject Value
      Describe what this call does

      .NOTES
      Place additional notes here.

      .LINK
      URLs to related sites
      The first link is opened by Get-Help -Online Set-MyCalendarProcessing

      .INPUTS
      List of input types that are accepted by this function.

      .OUTPUTS
      List of output types produced by this function.
  #>


  param
  (
    [Parameter(Mandatory = $true, ValueFromPipeline = $true, HelpMessage = 'Data to process')]
    [string] $InputObject
  )
  process
  {
    Set-CalendarProcessing -Identity 'NAME OF CONFERENCE ROOM' -AutomateProcessing AutoAccept -BookInPolicy $InputObject.alias -AllBookInPolicy $false 
  }
}
$csvpath = Read-Host -Prompt 'Input the Filename and Path of the CSV to Process'
if ( Test-Path -Path $csvpath)
{
  Write-Output -InputObject ('Processing')
  Import-Csv -Path $csvpath  | Set-MyCalendarProcessing
}
else 
{
  Write-Output -InputObject ('File Not Found:{0}' -f $csvpath)
}

Open in new window

Avatar of timgreen7077
timgreen7077

If you entered those cmdlets and you got no error, then the changes were most likely successful. Powershell doesn't normally give a confirmation of success. If it would have failed you would have got an error, but by you not getting an error it most likely was successful. Look to verify if it was successful or not.
Avatar of GAC 2018

ASKER

Thank you for your quick response!  I ran the Import-csv command, it took about 5 minutes but only added one person from the list.  It was a random name in the middle of the list.
Any idea?
Thanks Tim!
I didn't get an error and the perms weren't applied.  I gave it about 30 mins for 65 updates!
I tried this: Set-CalendarProcessing "NAME OF CONFERENCE ROOM" -BookinPolicy "Username1","Username2","Username3","Username4","Username5"

This should have worked. This is the cmdlets you mentioned you entered. Does this not work for you or you just want to use a csv file?
That was what I ran that sat there doing nothing, and yes, if possible, I would like to use the CSV I have setup
ASKER CERTIFIED SOLUTION
Avatar of timgreen7077
timgreen7077

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I feel like I'm real close, I'm just doing something stupid!  See the attached screen shot, please
PS-ERROR-MSG.jpg
Copy and paste it as you see it. dont add it all on 1 line
copy to notepad or word and make your changes and then paste into exchange shell.
Hey Dude!  First of all thank you for your patience with my ignorance, you'll get a very good rating when we're done!

ok  so I have this:

$userlist = Import-Csv C:\temp\filename.csv
 foreach ($user in $userlist){
 set-CalendarProcessing "conf room" -BookinPolicy $user.alias
 }

Are you saying, after replacing "filename" and "Conf Room" with the real names, I should be able to take all of that and paste it into PS?
That sounded wrong to me so I ran the first line to import the csv then tried to manipulate the rest in the set command. but got no where!
Would it be possible to type out the command just as I need to paste it into PowerShell, put into a word document and attach it?
this is the syntax

$userlist = Import-Csv C:\temp\filename.csv
foreach ($user in $userlist){
set-CalendarProcessing "conf room" -BookinPolicy $user.alias
}

yes, just add the correct filename of your csv and the correct conf room name.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok, that seemed to work, without error, EXCEPT, it only added the last name in the list.  Is the format in my csv wrong?  It looks like this:

alias
User1
User2
User3

Down to User63.  #63 was added but no one else
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The same result.  What's happening is User1 gets added, when User2 gets added, it removes User1, when User3 gets added it removes User2 and so on
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is this the whole thing?
Import-Csv C:\temp\filename.csv | set-CalendarProcessing "conf room" -BookinPolicy $_.alias
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It didn't like that!  I attached the error (I removed the user name from the picture)
Error.png
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It only took a second to run, there were no errors but it didn't add anyone...
I'm sorry to be such a P.I.T.A.
did you run 'Get-CalendarProcessing -Identity "Room 212" | Format-List" to check?
Originally, no.  I just looked at it in the console.  I just ran it and attached the results...BookInPolicy:  { }
Error2.jpg
GAC,
The users in your list- are you listing their default email address or their display names?  if it is a display name you MUST put it in quotes as there is spacing

'Doe, John'
'Jane, Mary'
I am using their "User Name", it is their employee ID Number.  I can try it with their display name in quotes.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial