get-remotemailbox not working in script
Home › Forums › Messaging Software › Exchange 2007 / 2010 / 2013 › get-remotemailbox not working in script
- This topic has 2 replies, 2 voices, and was last updated 1 year, 7 months ago by
[email protected].
-
AuthorPosts
-
[email protected]MemberMay 28, 2019 at 11:55 am #617564Hello,
I’m fairly new to Powershell and trying to process a list of users to report, change and set customattributes. Currently just trying to ready the current value and it’s not working.
The following script keeps keeps given the wrong variable when I output to screen.
here’s the Output:
[PS] C:\scripts\Exchange-Tools>.\ExAttribute-Editor.ps1
Enter name of the .csv file in C:\Scripts\Exchange-Tools?: 625-ADD.csv
Enter the value number for the Attribute?: 5
Enter the Custom Attribute Number or Name?:
@{-CustomAttribute5=} Result output!!!
Attribute value for List is: LOUIS BAXTER
Value for CustomAttrib2 is: -CustomAttribute5
Result @{-CustomAttribute5=} is currently set for user: LOUIS BAXTERScript:
import-module activedirectory
$File01 = “C:\Scripts\Exchange-Tools”
$File02 = (Read-Host “Enter name of the .csv file in C:\Scripts\Exchange-Tools?”)
$AttribValue = (Read-Host “Enter the value number for the Attribute?”)
$CustomAttrib = (Read-Host “Enter the Custom Attribute Number or Name?”)
$CustomAttrib2 = “-CustomAttribute” + $AttribValue.Trim()
$Path = “$file01\$File02″
$csv = Get-Content $Path
foreach($item in $csv)
{
$List = $item
$OutFile = Get-RemoteMailbox -Identity:”$List” |Select $CustomAttrib2
$out2 = $OutFile
Write-host $out2 “Result output!!!”
#$Result = Get-RemoteMailbox “$List” |Select-Object $CustomAttrib2
#(get-mailbox “$List”).$CustomAttrib2
Write-Host “Attribute value for List is: ” $List
Write-Host “Value for CustomAttrib2 is: ” $CustomAttrib2
#Write-Host “Attribute value for Result is: ” $Result
#Start-Sleep -s 4
Write-Output “Result $OutFile is currently set for user: $List”Any help you can provide as to why the $OutFile variable is not working is much appreciated!
-
AuthorPosts
You must be logged in to reply to this topic.