Add-publicfolderclientpermission input file for multiple users

Need some help with this script:

 $users = import-csv "Usernames.csv"
foreach ($user in $users) {
Get-PublicFolder "PublicFolder"
add-publicfolderclientpermission -accessrights PublishingEditor -user $user

If you look at the error below it looks like it is trying to add the user in line 1 of the CSV file to each user in the csv file

Error:

Cannot process argument transformation on parameter 'User'. Cannot convert value "@{user_in_line1=User_in_line2}" to type "Microsoft.Exchange.Management.StoreTasks.MailboxFolderUserIdParameter". Error: "Cannot convert hashtable to an object of the

following type: Microsoft.Exchange.Management.StoreTasks.MailboxFolderUserIdParameter. Hashtable-to-Object conversion is not supported in restricted language mode or a Data section."

March 30th, 2015 1:12pm

please try to use Get-Content instead of Import-CSV ?
Free Windows Admin Tool Kit Click here and download it now
March 31st, 2015 1:28am

any update on this ?
April 1st, 2015 1:40am

Hi Chang,

Please try to use $UserList=IMPORT-CSV C:\Imports\Users.csv

For more details, please try to refer following threads:

1. Hashtable-to-Object conversion is not supported

https://social.msdn.microsoft.com/Forums/office/en-US/1765335e-fd1c-4886-9fac-b2f15d5a493a/hashtabletoobject-conversion-is-not-supported?forum=exchangesvrdevelopment

2. Retrieve all Inbox Rules from my tenant (Office365)

https://social.technet.microsoft.com/Forums/en-US/e165730f-1373-40f0-8f14-73dedc207553/retrieve-all-inbox-rules-from-my-tenant-office365?forum=winserverpowershell

3. Use PowerShell to Read a CSV file and Create Active Directory User Accounts

http://blogs.technet.com/b/heyscriptingguy/archive/2011/12/22/use-powershell-to-read-a-csv-file-and-create-active-directory-user-accounts.aspx

 

Thanks

Free Windows Admin Tool Kit Click here and download it now
April 1st, 2015 2:22am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics